22buildscript {
33 repositories {
44 mavenCentral()
5- jcenter()
6- maven {
7- name = " forge"
8- url = " http://files.minecraftforge.net/maven"
9- }
5+ maven { url = ' https://maven.minecraftforge.net' }
106 }
117 dependencies {
12- classpath group : ' net.minecraftforge.gradle' , name : ' ForgeGradle' , version : ' 3 .+' , changing : true
8+ classpath group : ' net.minecraftforge.gradle' , name : ' ForgeGradle' , version : ' 5.1 .+' , changing : true
139 }
1410}
1511
1612plugins {
17- // For people who want stable
18- // id "net.minecraftforge.gradle.forge" version "2.0.2"
1913 id ' com.matthewprenger.cursegradle' version ' 1.4.0'
2014}
2115
2216apply plugin : ' net.minecraftforge.gradle'
2317apply plugin : ' idea'
24- apply plugin : ' maven'
25-
26- import net.minecraftforge.gradle.common.task.SignJar
27-
28- loadProperties()
29-
30- version = config. mod_version
18+ apply plugin : ' maven-publish'
19+
20+ import net.minecraftforge.gradle.common.tasks.SignJar
21+
22+ // Determine build number
23+ String build_number = " DEV" // this will be referenced as simply build_number from now on.
24+ if (System . getenv(). BUILD_NUMBER )
25+ build_number = System . getenv(). BUILD_NUMBER
26+ if (System . getenv(). TRAVIS_BUILD_NUMBER )
27+ build_number = System . getenv(). TRAVIS_BUILD_NUMBER
28+ if (System . getenv(). GITHUB_RUN_ID )
29+ build_number = System . getenv(). GITHUB_RUN_NUMBER
30+ if (System . getenv(). RELEASE || System . getenv(). TRAVIS_TAG )
31+ build_number = " RELEASE"
32+ logger. lifecycle " BUILDING VERSION: " + build_number
33+
34+ // Set mod details
35+ version = project. mod_version
3136group = " org.cyclops.structuredcrafting"
3237archivesBaseName = " StructuredCrafting"
38+
39+ // Set Java details
3340sourceCompatibility = 1.8
3441targetCompatibility = 1.8
3542
36- def loadProperties () {
37- // Config file with custom properties
38- ext. configFile = file " build.properties"
39- configFile. withReader {
40- def prop = new Properties ()
41- prop. load(it)
42- ext. config = new ConfigSlurper (). parse prop
43+ // Load secrets
44+ def getSecrets () {
45+ Properties props = new Properties ()
46+ if (file(' ./secrets.properties' ). exists()) {
47+ props. load(new FileInputStream (file(' ./secrets.properties' )))
4348 }
44-
45- // grab buildNumber
46- ext. buildnumber = " DEV" // this will be referenced as simply project.buildnumber from now on.
47- if (System . getenv(). BUILD_NUMBER )
48- project. buildnumber = System . getenv(). BUILD_NUMBER
49- if (System . getenv(). TRAVIS_BUILD_NUMBER )
50- project. buildnumber = System . getenv(). TRAVIS_BUILD_NUMBER
51- if (System . getenv(). GITHUB_RUN_ID )
52- project. buildnumber = System . getenv(). GITHUB_RUN_NUMBER
53- if (System . getenv(). RELEASE || System . getenv(). TRAVIS_TAG )
54- project. buildnumber = " RELEASE"
55- logger. lifecycle " BUILDING VERSION: " + project. buildnumber
49+ return props
5650}
51+ Properties secrets = getSecrets();
5752
5853sourceSets {
59- api
54+ api {
55+ resources. srcDirs = []
56+ }
6057 main {
6158 compileClasspath + = sourceSets. api. output
6259 runtimeClasspath + = sourceSets. api. output
@@ -68,7 +65,8 @@ sourceSets {
6865}
6966
7067configurations {
71- apiCompile. extendsFrom(compile)
68+ apiImplementation. extendsFrom(implementation)
69+ apiRuntimeOnly. extendsFrom(runtimeOnly)
7270 javadoc. classpath + = sourceSets. api. output
7371}
7472
@@ -86,21 +84,24 @@ repositories {
8684}
8785
8886dependencies {
89- minecraft " net.minecraftforge:forge:${ config .minecraft_version} -${ config .forge_version} "
87+ minecraft " net.minecraftforge:forge:${ project .minecraft_version} -${ project .forge_version} "
9088
91- // Add something like 'cyclopscore_version_local=0.1.0-DEV' to your gradle .properties if you want to use a custom local CyclopsCore version.
92- if (project . hasProperty( " cyclopscore_version_local" ) ) {
93- compile " org.cyclops.cyclopscore:cyclopscore:${ config .minecraft_version} -${ project .cyclopscore_version_local} :deobf"
89+ // Add something like 'cyclopscore_version_local=0.1.0-DEV' to your secrets .properties if you want to use a custom local CyclopsCore version.
90+ if (secrets . cyclopscore_version_local) {
91+ implementation " org.cyclops.cyclopscore:cyclopscore:${ project .minecraft_version} -${ secrets .cyclopscore_version_local} :deobf"
9492 } else {
95- compile " org.cyclops.cyclopscore:cyclopscore:${ config .minecraft_version} -${ config .cyclopscore_version} :deobf"
93+ implementation " org.cyclops.cyclopscore:cyclopscore:${ project .minecraft_version} -${ project .cyclopscore_version} :deobf"
9694 }
9795
9896 // Project lombok
99- compileOnly " org.projectlombok:lombok:1.16.4"
97+ compileOnly ' org.projectlombok:lombok:1.18.22'
98+ annotationProcessor ' org.projectlombok:lombok:1.18.22'
99+ testCompileOnly ' org.projectlombok:lombok:1.18.22'
100+ testAnnotationProcessor ' org.projectlombok:lombok:1.18.22'
100101}
101102
102103minecraft {
103- mappings channel : " ${ config .mcp_mappings_channel} " , version : " ${ config .mcp_mappings_version} "
104+ mappings channel : " ${ project .mcp_mappings_channel} " , version : " ${ project .mcp_mappings_version} "
104105
105106 accessTransformer = file(' src/main/resources/META-INF/accesstransformer.cfg' )
106107
@@ -110,21 +111,15 @@ minecraft {
110111 // property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
111112 property ' forge.logging.console.level' , ' debug'
112113 mods {
113- structuredcrafting {
114- source sourceSets. main
115- source sourceSets. api
116- }
114+ structuredcrafting. sources((SourceSet []) [sourceSets. main, sourceSets. api])
117115 }
118116 }
119117
120118 server {
121119 workingDirectory project. file(' run' )
122120 property ' forge.logging.console.level' , ' debug'
123121 mods {
124- structuredcrafting {
125- source sourceSets. main
126- source sourceSets. api
127- }
122+ structuredcrafting. sources((SourceSet []) [sourceSets. main, sourceSets. api])
128123 }
129124 }
130125
@@ -133,34 +128,38 @@ minecraft {
133128 property ' forge.logging.console.level' , ' debug'
134129 args ' --mod' , ' structuredcrafting' , ' --all' , ' --output' , file(' src/generated/resources/' )
135130 mods {
136- structuredcrafting {
137- source sourceSets. main
138- source sourceSets. api
139- }
131+ structuredcrafting. sources((SourceSet []) [sourceSets. main, sourceSets. api])
140132 }
141133 }
142134 }
143135}
144136
145- if (project . buildnumber . equals(" RELEASE" ))
146- version = " ${ config .minecraft_version} -${ config .mod_version} "
137+ if (build_number . equals(" RELEASE" ))
138+ version = " ${ project .minecraft_version} -${ project .mod_version} "
147139else
148- version = " ${ config .minecraft_version} -${ config .mod_version} -${ buildnumber } "
140+ version = " ${ project .minecraft_version} -${ project .mod_version} -${ build_number } "
149141
150142jar {
151143 manifest {
152144 attributes([
153145 " FMLAT" : " accesstransformer.cfg" ,
154146 " Specification-Title" : " ${ project.name} " ,
155147 " Specification-Vendor" : " rubensworks" ,
156- " Specification-Version" : " ${ config .mod_version} " ,
148+ " Specification-Version" : " ${ project .mod_version} " ,
157149 " Implementation-Title" : " ${ project.name} " ,
158- " Implementation-Version" : " ${ config .mod_version} " ,
150+ " Implementation-Version" : " ${ project .mod_version} " ,
159151 " Implementation-Vendor" :" rubensworks" ,
160152 " Implementation-Timestamp" : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
161153 ])
162154 }
163155}
156+ jar. finalizedBy(' reobfJar' )
157+
158+ javadoc {
159+ source = [sourceSets. main. allJava]
160+ // prevent java 8's strict doclint for javadocs from failing builds
161+ options. addStringOption(' Xdoclint:accessibility,html,reference,syntax' , ' -quiet' )
162+ }
164163
165164task signJar (type : SignJar , dependsOn : jar) {
166165 onlyIf {
@@ -184,9 +183,9 @@ task deobfJar(type: Jar) {
184183 " FMLAT" : " accesstransformer.cfg" ,
185184 " Specification-Title" : " ${ project.name} " ,
186185 " Specification-Vendor" : " rubensworks" ,
187- " Specification-Version" : " ${ config .mod_version} " ,
186+ " Specification-Version" : " ${ project .mod_version} " ,
188187 " Implementation-Title" : " ${ project.name} " ,
189- " Implementation-Version" : " ${ config .mod_version} " ,
188+ " Implementation-Version" : " ${ project .mod_version} " ,
190189 " Implementation-Vendor" :" rubensworks" ,
191190 " Implementation-Timestamp" : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
192191 ])
@@ -200,33 +199,36 @@ task apiJar(type: Jar) {
200199 include ' structuredcrafting/api/**'
201200}
202201
203- task sourceJar (type : Jar ) {
204- classifier = " sources"
202+ task sourcesJar (type : Jar ) {
203+ duplicatesStrategy(DuplicatesStrategy . FAIL )
204+ archiveClassifier. set(' sources' )
205205 from sourceSets. main. allJava
206206}
207207
208208task javadocJar (type : Jar , dependsOn : javadoc) {
209+ duplicatesStrategy(DuplicatesStrategy . FAIL )
210+ archiveClassifier. set(' javadoc' )
209211 from javadoc. destinationDir
210- classifier ' javadoc'
211212}
212213
213214artifacts {
214215 archives deobfJar
215216 archives apiJar
216- archives sourceJar
217+ archives sourcesJar
217218 archives javadocJar
218219}
219220
220221curseforge {
221- if (project . hasProperty( " curseforge_key" ) ) {
222- apiKey = project . curseforge_key
223- } else if (( System . getenv(). TRAVIS || System . getenv() . GITHUB_ACTIONS ) && System . getenv(). CURSEFORGE_KEY_SECRET ) {
222+ if (secrets . curseforge_key) {
223+ apiKey = secrets . curseforge_key
224+ } else if (System . getenv(). GITHUB_ACTIONS && System . getenv(). CURSEFORGE_KEY_SECRET ) {
224225 apiKey = System . getenv(). CURSEFORGE_KEY_SECRET
225226 }
226227
227228 project {
228229 id = " 233151" // my project url is http://minecraft.curseforge.com/mc-mods/233151/
229- releaseType = project. config. release_type
230+ releaseType = project. project. release_type
231+ addGameVersion project. minecraft_version
230232 mainArtifact(jar) {
231233 relations {
232234 requiredDependency ' cyclops-core'
@@ -239,74 +241,43 @@ curseforge {
239241 }
240242
241243 addArtifact deobfJar
242- addArtifact sourceJar
244+ addArtifact sourcesJar
243245 addArtifact javadocJar
244246 }
245247}
246248
247- configurations {
248- deployerJars
249- }
250-
251- dependencies {
252- deployerJars " org.apache.maven.wagon:wagon-ftp:2.2"
253- }
254-
255- uploadArchives {
249+ publishing {
256250 repositories {
257- add getProject(). repositories. mavenLocal()
258- }
259- repositories. mavenDeployer {
260- configuration = configurations. deployerJars
261-
262251 if (project. hasProperty(" filesmaven_url" )) {
263252 logger. info(' Publishing to files server' )
264- repository(url : project. filesmaven_url) {
265- authentication(userName : project. filesmaven_username, password : project. filesmaven_key)
253+ maven {
254+ url project. filesmaven_url
255+ credentials {
256+ username = project. filesmaven_username
257+ password = project. filesmaven_key
258+ }
266259 }
267- } else if (System . getenv() . MAVEN_URL ) {
260+ } else if (System . getenv(" MAVEN_URL" ) ) {
268261 logger. info(' Publishing to files server' )
269- repository(url : System . getenv(). MAVEN_URL ) {
270- authentication(userName : System . getenv(). MAVEN_USERNAME , password : System . getenv(). MAVEN_KEY )
262+ maven {
263+ url System . getenv(" MAVEN_URL" )
264+ credentials {
265+ username = System . getenv(" MAVEN_USERNAME" )
266+ password = System . getenv(" MAVEN_KEY" )
267+ }
271268 }
272269 } else {
273- logger. info(' Publishing to repo folder' )
274- repository(url : ' file://localhost/' + project. file(' ~/.m2/repository' ). getAbsolutePath())
270+ logger. error(' No maven repo was set!' )
275271 }
272+ }
276273
277- pom {
278- groupId = project. group
279- version = project. version
280- artifactId = project. archivesBaseName. toLowerCase()
281- }
282- pom. project {
283- name project. archivesBaseName
284- packaging ' jar'
285- description ' todo'
286- url ' https://github.com/CyclopsMC/StructuredCrafting'
287-
288- scm {
289- url ' https://github.com/CyclopsMC/StructuredCrafting'
290- connection ' scm:git:git://github.com/CyclopsMC/StructuredCrafting.git'
291- developerConnection ' scm:git:git@github.com:CyclopsMC/StructuredCrafting.git'
292- }
293-
294- issueManagement {
295- system ' github'
296- url ' https://github.com/CyclopsMC/StructuredCrafting/issues'
297- }
298-
299- developers {
300- developer {
301- id ' rubensworks'
302- name ' rubensworks'
303- roles { role ' developer' }
304- }
305- }
274+ publications { PublicationContainer publicationContainer ->
275+ publicationContainer. register(" maven" , MavenPublication ) { MavenPublication publication ->
276+ publication. artifacts = [jar, javadocJar, deobfJar, sourcesJar]
277+ publication. artifactId = project. archivesBaseName. toLowerCase() // GH can't handle uppercase...
306278 }
307279 }
308280}
309- uploadArchives. dependsOn build
310281
311282idea {
312283 module {
0 commit comments