· 5 years ago · May 08, 2020, 11:36 AM
1// For those who want the bleeding edge
2buildscript {
3 repositories {
4 jcenter()
5 mavenCentral()
6 maven {
7 name = "forge"
8 url = "http://files.minecraftforge.net/maven"
9 }
10 maven {
11 url "https://plugins.gradle.org/m2/"
12 }
13 }
14 dependencies {
15 classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
16 classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.3'
17 }
18}
19plugins {
20 id "com.matthewprenger.cursegradle" version "1.1.0"
21}
22
23apply plugin: 'net.minecraftforge.gradle.forge'
24apply plugin: 'maven-publish'
25apply plugin: 'org.junit.platform.gradle.plugin'
26apply plugin: 'idea'
27apply plugin: 'java'
28
29repositories {
30 maven { // The repo from which to get VS
31 url "https://maven.daporkchop.net/"
32 }
33 maven { // The repo from which to get waila
34 url "http://mobiusstrip.eu/maven"
35 }
36 maven { // the repo from which to get NEI and stuff
37 url "http://chickenbones.net/maven/"
38 }
39 maven { url 'https://jitpack.io' }
40 maven {
41 url "https://maven.cil.li/"
42 }
43 maven { // the repo from which to get EnderIO and tterrags mods
44 url "https://maven.tterrag.com/"
45 }
46 maven {
47 name "ic2"
48 url "http://maven.ic2.player.to/"
49 }
50 maven {
51 url "https://tehnut.info/maven"
52 }
53 maven {
54 url "https://maven.ironhide.de/"
55 }
56 maven { // JEI
57 url "https://dvs1.progwml6.com/files/maven"
58 }
59 //maven { url = "http://dl.tsr.me/artifactory/libs-release-local" }
60 maven { // CoFH
61 name = "Covers Maven"
62 url = "http://maven.covers1624.net"
63 }
64 maven {
65 url 'https://maven.mcmoddev.com'
66 }
67 maven {
68 url = "https://files.minecraftforge.net/maven"
69 }
70}
71
72sourceCompatibility = targetCompatibility = 1.8
73compileJava {
74 sourceCompatibility = targetCompatibility = '1.8'
75}
76
77version = "${mod_version}"
78if (hasProperty('appendBuildNumber')) {
79 version = version + "-" + appendBuildNumber.toString()
80} else {
81 version = version + "-0"
82}
83
84group = "${group_id}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
85archivesBaseName = "${mod_id}-${minecraft_version}"
86
87String omlib_max_version= omlib_version.toString().replaceAll("[0-9]-[0-9]*", "99-9999")
88
89minecraft {
90 version = "${forge_version}"
91 runDir = "run"
92
93 replace "@VERSION@", project.version
94 replace "omlib@[0.0.0,)", "omlib@[" + omlib_version + "," + omlib_max_version + ")"
95
96 // the mappings can be changed at any time, and must be in the following format.
97 // snapshot_YYYYMMDD snapshot are built nightly.
98 // stable_# stables are built at the discretion of the MCP team.
99 // Use non-default mappings at your own risk. they may not always work.
100 // simply re-run your setup task after changing the mappings to update your workspace.
101 mappings = "snapshot_20171212"
102 //makeObfSourceJar = true // an Srg named sources jar is made by default. uncomment this to disable.
103 useDepAts = true
104}
105
106
107processResources {
108 // this will ensure that this task is redone when the versions change.
109 inputs.property "version", project.version
110 inputs.property "mcversion", project.minecraft.version
111
112 // replace stuff in mcmod.info, nothing else
113 from(sourceSets.main.resources.srcDirs) {
114 include 'mcmod.info'
115
116 // replace version and mcversion
117 expand 'version': project.version, 'mcversion': project.minecraft.version
118 }
119
120 // copy everything else, thats not the mcmod.info
121 from(sourceSets.main.resources.srcDirs) {
122 exclude 'mcmod.info'
123 }
124}
125
126configurations {
127 runtime.exclude group: 'ValkyrienWarfareRevamped', module: 'valkyrienwarfare'
128}
129
130def omlib_local = false
131if (project.allprojects.findAll({ it.name == "OMLib" }).size() > 0) {
132 omlib_local = true
133}
134if (rootProject.name == "OMTControl") {
135 omlib_local = true
136}
137def ompd_local = false
138if (project.allprojects.findAll({ it.name == "OpenModularPassiveDefense" }).size() > 0) {
139 ompd_local = true
140}
141
142dependencies {
143
144 deobfProvided "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
145 testCompile "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
146 deobfProvided "mcp.mobius.waila:Hwyla:${hwyla_version}:sources"
147 testCompile "mcp.mobius.waila:Hwyla:${hwyla_version}:sources"
148 deobfProvided "cofh:RedstoneFlux:${minecraft_version_short}-${redstoneflux_version}:universal"
149 testCompile "cofh:RedstoneFlux:${minecraft_version_short}-${redstoneflux_version}:universal"
150 deobfProvided "mcjty.theoneprobe:TheOneProbe-${minecraft_version_short}:${minecraft_version_short}-${top_version}"
151 testCompile "mcjty.theoneprobe:TheOneProbe-${minecraft_version_short}:${minecraft_version_short}-${top_version}"
152 deobfProvided "li.cil.oc:OpenComputers:MC${minecraft_version}-${oc_version}"
153 testCompile "li.cil.oc:OpenComputers:MC${minecraft_version}-${oc_version}"
154 deobfProvided "net.industrial-craft:industrialcraft-2:${ic2_version}"
155 testCompile "net.industrial-craft:industrialcraft-2:${ic2_version}"
156 deobfProvided "net.darkhax.tesla:Tesla-${minecraft_version}:${tesla_version}"
157 testCompile "net.darkhax.tesla:Tesla-${minecraft_version}:${tesla_version}"
158 if (!omlib_local) {
159 compileOnly "omtteam:omlib:${minecraft_version}-${omlib_version}:dev"
160 testCompile "omtteam:omlib:${minecraft_version}-${omlib_version}:dev"
161 } else {
162 compile project(':OMLib')
163 testCompile project(':OMLib')
164 }
165 if (ompd_local) {
166 runtime project(':OpenModularPassiveDefense')
167 }
168 testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
169 testCompile("org.junit.jupiter:junit-jupiter-api:5.2.0")
170 testCompile("org.junit.platform:junit-platform-launcher:1.1.0")
171 testRuntime("org.junit.jupiter:junit-jupiter-engine:5.2.0")
172}
173
174junitPlatform {
175 platformVersion '1.0.3'
176 enableStandardTestTask true
177}
178
179task deobfJar(type: Jar) {
180 from sourceSets.main.output
181 classifier = 'dev'
182}
183
184tasks.build.dependsOn deobfJar, sourceJar
185
186publishing {
187 tasks.publish.dependsOn 'build'
188 publications {
189 mavenJava(MavenPublication) {
190 groupId group_prefix
191 version minecraft_version + "-" + project.version
192 artifactId mod_id
193 artifact jar
194 artifact sourceJar
195 artifact deobfJar
196 }
197 }
198 repositories {
199 mavenLocal()
200 }
201}
202
203//// DETECTING COMMIT NAME AND ACTIVATING CURSE RELEASE \\\\
204
205def commit_release_type = getCommmitReleaseType()
206
207def getCommmitReleaseType() {
208 if (project.hasProperty("curseforge_key")) {
209 def stdout = new ByteArrayOutputStream()
210 try {
211 exec {
212 commandLine 'git', 'log', '-1', '--pretty=tformat:%s'
213 standardOutput = stdout
214 }
215 } catch (Exception e) {
216 System.print("SKIPPING CURSE RELEASE - FAILED TO RETRIEVE LAST COMMIT")
217 e.printStackTrace()
218 return 'none'
219 }
220 String commit = stdout.toString().trim()
221
222 if (commit.startsWith("CRelease") || commit.startsWith("crelease")) {
223 System.out.println("FOUND NEW RELEASE - COMMIT: ".concat(commit)); return 'release'
224 } else if (commit.startsWith("CBeta") || commit.startsWith("cbeta")) {
225 System.out.println("FOUND NEW BETA - COMMIT: ".concat(commit)); return 'beta'
226 } else if (commit.startsWith("CAlpha") || commit.startsWith("calpha")) {
227 System.out.println("FOUND NEW ALPHA - COMMIT: ".concat(commit)); return 'alpha'
228 } else {
229 System.out.println("SKIPPING CURSE RELEASE - COMMIT: " + commit); return 'none'
230 }
231 }
232 System.out.println("SKIPPING CURSE RELEASE - NO CURSE API KEY")
233 return 'none'
234}
235
236tasks.curseforge.enabled = project.hasProperty("curseforge_key") && commit_release_type != 'none'
237curseforge {
238 if (project.hasProperty("curseforge_key") && commit_release_type != 'none') {
239 System.out.println("ATTEMPTING CURSE RELEASE")
240 apiKey = project.properties["curseforge_key"]
241 } else {
242 return
243 }
244 project {
245 id = curse_project_id
246 addGameVersion '1.12.2'
247
248 relations {
249 requiredDependency 'omlib'
250 optionalDependency 'ompd'
251 optionalDependency 'ender-io'
252 optionalDependency 'redstone-flux'
253 optionalDependency 'thermal-expansion'
254 optionalDependency 'mekanism'
255 optionalDependency 'opencomputers'
256 optionalDependency 'computercraft'
257 }
258
259 mainArtifact(jar) {
260 releaseType = commit_release_type
261 changelog = file("${projectDir}/change_log.html").text
262 changelogType = 'html'
263 }
264
265 addArtifact(sourceJar) {
266 releaseType = 'alpha'
267 changelog = file("${projectDir}/change_log.html").text
268 changelogType = 'html'
269 }
270
271 addArtifact(deobfJar) {
272 releaseType = 'alpha'
273 changelog = file("${projectDir}/change_log.html").text
274 changelogType = 'html'
275 }
276 }
277}