1
- // version: 1644894948
1
+ // version: 1650343995
2
2
/*
3
3
DO NOT CHANGE THIS FILE!
4
4
5
5
Also, you may replace this file at any time if there is an update available.
6
6
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
7
7
*/
8
8
9
- import org.gradle.internal.logging.text.StyledTextOutput
10
- import org.gradle.internal.logging.text.StyledTextOutputFactory
11
- import org.gradle.internal.logging.text.StyledTextOutput.Style
12
9
13
10
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
14
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
12
+ import org.gradle.internal.logging.text.StyledTextOutput.Style
13
+ import org.gradle.internal.logging.text.StyledTextOutputFactory
15
14
16
15
import java.util.concurrent.TimeUnit
17
16
@@ -104,6 +103,7 @@ checkPropertyExists("usesShadowedDependencies")
104
103
checkPropertyExists(" developmentEnvironmentUserName" )
105
104
106
105
boolean noPublishedSources = project. findProperty(" noPublishedSources" ) ? project. noPublishedSources. toBoolean() : false
106
+ boolean usesMixinDebug = project. findProperty(' usesMixinDebug' ) ?: project. usesMixins. toBoolean()
107
107
108
108
String javaSourceDir = " src/main/java/"
109
109
String scalaSourceDir = " src/main/scala/"
@@ -180,18 +180,27 @@ catch (Exception ignored) {
180
180
}
181
181
182
182
// Pulls version first from the VERSION env and then git tag
183
+ String identifiedVersion
184
+ String versionOverride = System . getenv(" VERSION" ) ?: null
185
+ try {
186
+ identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
187
+ }
183
188
catch (Exception ignored) {
184
189
out. style(Style.Failure ). text(
185
190
' This mod must be version controlled by Git AND the repository must provide at least one tag,\n ' +
186
191
' or the VERSION override must be set! ' ). style(Style.SuccessHeader ). text(' (Do NOT download from GitHub using the ZIP option, instead\n ' +
187
192
' clone the repository, see ' ). style(Style.Info ). text(' https://gtnh.miraheze.org/wiki/Development' ). style(Style.SuccessHeader ). println (' for details.)'
188
193
)
189
194
versionOverride = ' NO-GIT-TAG-SET'
195
+ identifiedVersion = versionOverride
190
196
}
191
- String versionTag = gitVersion(). split(" -" )[gitVersion(). split(" -" ). length - 1 ]
192
- version = minecraftVersion + ' -' + versionTag
197
+ version = minecraftVersion + ' -' + identifiedVersion
193
198
ext {
194
- modVersion = versionTag
199
+ modVersion = identifiedVersion
200
+ }
201
+
202
+ if (identifiedVersion == versionOverride) {
203
+ out. style(Style.Failure ). text(' Override version to ' ). style(Style.Identifier ). text(modVersion). style(Style.Failure ). println (' !\7 ' )
195
204
}
196
205
197
206
group = modGroup
@@ -205,13 +214,17 @@ else {
205
214
def arguments = []
206
215
def jvmArguments = []
207
216
208
- if (usesMixins. toBoolean()) {
217
+ if (usesMixins. toBoolean()) {
209
218
arguments + = [
210
- " --tweakClass org.spongepowered.asm.launch.MixinTweaker"
211
- ]
212
- jvmArguments + = [
213
- " -Dmixin.debug.countInjections=true" , " -Dmixin.debug.verbose=true" , " -Dmixin.debug.export=true"
219
+ " --tweakClass org.spongepowered.asm.launch.MixinTweaker"
214
220
]
221
+ if (usesMixinDebug. toBoolean()) {
222
+ jvmArguments + = [
223
+ " -Dmixin.debug.countInjections=true" ,
224
+ " -Dmixin.debug.verbose=true" ,
225
+ " -Dmixin.debug.export=true"
226
+ ]
227
+ }
215
228
}
216
229
217
230
minecraft {
@@ -303,18 +316,23 @@ def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfig
303
316
def mixinSrg = " ${ tasks.reobf.temporaryDir} " + File . separator + " mixins.srg"
304
317
305
318
task generateAssets {
306
- if (usesMixins. toBoolean()) {
307
- getFile(" /src/main/resources/mixins." + modId + " .json" ). text = """ {
319
+ if (usesMixins. toBoolean()) {
320
+ def mixinConfigFile = getFile(" /src/main/resources/mixins." + modId + " .json" );
321
+ if (! mixinConfigFile. exists()) {
322
+ mixinConfigFile. text = """ {
308
323
"required": true,
309
324
"minVersion": "0.7.11",
310
325
"package": "${ modGroup} .${ mixinsPackage} ",
311
326
"plugin": "${ modGroup} .${ mixinPlugin} ",
312
327
"refmap": "${ mixingConfigRefMap} ",
313
328
"target": "@env(DEFAULT)",
314
- "compatibilityLevel": "JAVA_8"
329
+ "compatibilityLevel": "JAVA_8",
330
+ "mixins": [],
331
+ "client": [],
332
+ "server": []
315
333
}
316
-
317
334
"""
335
+ }
318
336
}
319
337
}
320
338
@@ -453,7 +471,7 @@ def getManifestAttributes() {
453
471
}
454
472
455
473
task sourcesJar (type : Jar ) {
456
- from (sourceSets. main. allJava )
474
+ from (sourceSets. main. allSource )
457
475
from (file(" $projectDir /LICENSE" ))
458
476
getArchiveClassifier(). set(' sources' )
459
477
}
@@ -508,7 +526,7 @@ task devJar(type: Jar) {
508
526
}
509
527
510
528
task apiJar (type : Jar ) {
511
- from (sourceSets. main. allJava ) {
529
+ from (sourceSets. main. allSource ) {
512
530
include modGroup. toString(). replaceAll(" \\ ." , " /" ) + " /" + apiPackage. toString(). replaceAll(" \\ ." , " /" ) + ' /**'
513
531
}
514
532
@@ -550,7 +568,7 @@ publishing {
550
568
artifact source : shadowJar, classifier : " "
551
569
}
552
570
if (! noPublishedSources) {
553
- artifact source : sourcesJar, classifier : " src "
571
+ artifact source : sourcesJar, classifier : " sources "
554
572
}
555
573
artifact source : usesShadowedDependencies. toBoolean() ? shadowDevJar : devJar, classifier: " dev"
556
574
if (apiPackage) {
@@ -560,7 +578,7 @@ publishing {
560
578
groupId = System . getenv(" ARTIFACT_GROUP_ID" ) ?: " com.github.GTNewHorizons"
561
579
artifactId = System . getenv(" ARTIFACT_ID" ) ?: project. name
562
580
// Using the identified version, not project.version as it has the prepended 1.7.10
563
- version = System . getenv(" RELEASE_VERSION" ) ?: versionTag
581
+ version = System . getenv(" RELEASE_VERSION" ) ?: identifiedVersion
564
582
565
583
// remove extra garbage from minecraft and minecraftDeps configuration
566
584
pom. withXml {
@@ -597,10 +615,46 @@ publishing {
597
615
// Updating
598
616
task updateBuildScript {
599
617
doLast {
618
+ if (performBuildScriptUpdate(projectDir. toString())) return
619
+
600
620
print (" Build script already up-to-date!" )
601
621
}
602
622
}
603
623
624
+ if (isNewBuildScriptVersionAvailable(projectDir. toString())) {
625
+ if (autoUpdateBuildScript. toBoolean()) {
626
+ performBuildScriptUpdate(projectDir. toString())
627
+ } else {
628
+ out. style(Style.SuccessHeader ). println (" Build script update available! Run 'gradle updateBuildScript'" )
629
+ }
630
+ }
631
+
632
+ static URL availableBuildScriptUrl () {
633
+ new URL (" https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle" )
634
+ }
635
+
636
+ boolean performBuildScriptUpdate (String projectDir ) {
637
+ if (isNewBuildScriptVersionAvailable(projectDir)) {
638
+ def buildscriptFile = getFile(" build.gradle" )
639
+ availableBuildScriptUrl(). withInputStream { i -> buildscriptFile. withOutputStream { it << i } }
640
+ out. style(Style.Success ). print (" Build script updated. Please REIMPORT the project or RESTART your IDE!" )
641
+ return true
642
+ }
643
+ return false
644
+ }
645
+
646
+ boolean isNewBuildScriptVersionAvailable (String projectDir ) {
647
+ Map parameters = [" connectTimeout" : 2000 , " readTimeout" : 2000 ]
648
+
649
+ String currentBuildScript = getFile(" build.gradle" ). getText()
650
+ String currentBuildScriptHash = getVersionHash(currentBuildScript)
651
+ String availableBuildScript = availableBuildScriptUrl(). newInputStream(parameters). getText()
652
+ String availableBuildScriptHash = getVersionHash(availableBuildScript)
653
+
654
+ boolean isUpToDate = currentBuildScriptHash. empty || availableBuildScriptHash. empty || currentBuildScriptHash == availableBuildScriptHash
655
+ return ! isUpToDate
656
+ }
657
+
604
658
static String getVersionHash (String buildScriptContent ) {
605
659
String versionLine = buildScriptContent. find(" ^//version: [a-z0-9]*" )
606
660
if (versionLine != null ) {
0 commit comments