1- // version: 1642464427
1+ // version: 1643020202
22/*
33DO NOT CHANGE THIS FILE!
44
@@ -32,16 +32,18 @@ buildscript {
3232 }
3333 }
3434 dependencies {
35- classpath ' com.github.GTNewHorizons:ForgeGradle:1.2.5 '
35+ classpath ' com.github.GTNewHorizons:ForgeGradle:1.2.7 '
3636 }
3737}
3838
3939plugins {
4040 id ' idea'
41+ id ' eclipse'
4142 id ' scala'
4243 id(" org.ajoberstar.grgit" ) version(" 3.1.1" )
4344 id(" com.github.johnrengelman.shadow" ) version(" 4.0.4" )
4445 id(" com.palantir.git-version" ) version(" 0.12.3" )
46+ id(' de.undercouch.download' ) version(' 4.1.2' )
4547 id(" maven-publish" )
4648}
4749
@@ -88,6 +90,7 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly")
8890checkPropertyExists(" usesShadowedDependencies" )
8991checkPropertyExists(" developmentEnvironmentUserName" )
9092
93+ boolean noPublishedSources = project. findProperty(" noPublishedSources" ) ? project. noPublishedSources. toBoolean() : false
9194
9295String javaSourceDir = " src/main/java/"
9396String scalaSourceDir = " src/main/scala/"
@@ -171,6 +174,19 @@ else {
171174 archivesBaseName = modId
172175}
173176
177+
178+ def arguments = []
179+ def jvmArguments = []
180+
181+ if (usesMixins. toBoolean()) {
182+ arguments + = [
183+ " --tweakClass org.spongepowered.asm.launch.MixinTweaker"
184+ ]
185+ jvmArguments + = [
186+ " -Dmixin.debug.countInjections=true" , " -Dmixin.debug.verbose=true" , " -Dmixin.debug.export=true"
187+ ]
188+ }
189+
174190minecraft {
175191 version = minecraftVersion + " -" + forgeVersion + " -" + minecraftVersion
176192 runDir = " run"
@@ -190,6 +206,20 @@ minecraft {
190206 replace gradleTokenGroupName, modGroup
191207 }
192208 }
209+
210+ clientIntellijRun {
211+ args(arguments)
212+ jvmArgs(jvmArguments)
213+
214+ if (developmentEnvironmentUserName) {
215+ args(" --username" , developmentEnvironmentUserName)
216+ }
217+ }
218+
219+ serverIntellijRun {
220+ args(arguments)
221+ jvmArgs(jvmArguments)
222+ }
193223}
194224
195225if (file(" addon.gradle" ). exists()) {
@@ -321,15 +351,6 @@ afterEvaluate {
321351}
322352
323353runClient {
324- def arguments = []
325-
326- if (usesMixins. toBoolean()) {
327- arguments + = [
328- " --mods=../build/libs/$modId -${ version} .jar" ,
329- " --tweakClass org.spongepowered.asm.launch.MixinTweaker"
330- ]
331- }
332-
333354 if (developmentEnvironmentUserName) {
334355 arguments + = [
335356 " --username" ,
@@ -338,19 +359,12 @@ runClient {
338359 }
339360
340361 args(arguments)
362+ jvmArgs(jvmArguments)
341363}
342364
343365runServer {
344- def arguments = []
345-
346- if (usesMixins. toBoolean()) {
347- arguments + = [
348- " --mods=../build/libs/$modId -${ version} .jar" ,
349- " --tweakClass org.spongepowered.asm.launch.MixinTweaker"
350- ]
351- }
352-
353366 args(arguments)
367+ jvmArgs(jvmArguments)
354368}
355369
356370tasks. withType(JavaExec ). configureEach {
@@ -484,20 +498,34 @@ task apiJar(type: Jar) {
484498}
485499
486500artifacts {
487- archives sourcesJar
501+ if (! noPublishedSources) {
502+ archives sourcesJar
503+ }
488504 archives devJar
489505 if (apiPackage) {
490506 archives apiJar
491507 }
492508}
493509
510+ // The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
511+ // and isn't strictly needed with the POM so just disable it.
512+ tasks. withType(GenerateModuleMetadata ) {
513+ enabled = false
514+ }
515+
516+
494517// publishing
495518publishing {
496519 publications {
497520 maven(MavenPublication ) {
498- artifact source : jar
499- artifact source : sourcesJar, classifier : " src"
500- artifact source : devJar, classifier : " dev"
521+ from components. java
522+ if (usesShadowedDependencies. toBoolean()) {
523+ artifact source : shadowJar, classifier : " "
524+ }
525+ if (! noPublishedSources) {
526+ artifact source : sourcesJar, classifier : " src"
527+ }
528+ artifact source : usesShadowedDependencies. toBoolean() ? shadowDevJar : devJar, classifier: " dev"
501529 if (apiPackage) {
502530 artifact source : apiJar, classifier : " api"
503531 }
@@ -506,6 +534,18 @@ publishing {
506534 artifactId = System . getenv(" ARTIFACT_ID" ) ?: project. name
507535 // Using the identified version, not project.version as it has the prepended 1.7.10
508536 version = System . getenv(" RELEASE_VERSION" ) ?: identifiedVersion
537+
538+ // Remove all non GTNH deps here.
539+ // Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but
540+ // it also removes all of the MC deps
541+ pom. withXml {
542+ Node pomNode = asNode()
543+ pomNode. dependencies. ' *' . findAll() {
544+ it. groupId. text() != ' com.github.GTNewHorizons'
545+ }. each() {
546+ it. parent(). remove(it)
547+ }
548+ }
509549 }
510550 }
511551
@@ -576,6 +616,72 @@ configure(updateBuildScript) {
576616 description = ' Updates the build script to the latest version'
577617}
578618
619+ // Deobfuscation
620+
621+ def deobf (String sourceURL ) {
622+ try {
623+ URL url = new URL (sourceURL)
624+ String fileName = url. getFile()
625+
626+ // get rid of directories:
627+ int lastSlash = fileName. lastIndexOf(" /" )
628+ if (lastSlash > 0 ) {
629+ fileName = fileName. substring(lastSlash + 1 )
630+ }
631+ // get rid of extension:
632+ if (fileName. endsWith(" .jar" )) {
633+ fileName = fileName. substring(0 , fileName. lastIndexOf(" ." ))
634+ }
635+
636+ String hostName = url. getHost()
637+ if (hostName. startsWith(" www." )) {
638+ hostName = hostName. substring(4 )
639+ }
640+ List parts = Arrays . asList(hostName. split(" \\ ." ))
641+ Collections . reverse(parts)
642+ hostName = String . join(" ." , parts)
643+
644+ return deobf(sourceURL, hostName + " /" + fileName)
645+ } catch (Exception e) {
646+ return deobf(sourceURL, " deobf/" + String . valueOf(sourceURL. hashCode()))
647+ }
648+ }
649+
650+ // The method above is to be prefered. Use this method if the filename is not at the end of the URL.
651+ def deobf (String sourceURL , String fileName ) {
652+ String cacheDir = System . getProperty(" user.home" ) + " /.gradle/caches/"
653+ String bon2Dir = cacheDir + " forge_gradle/deobf"
654+ String bon2File = bon2Dir + " /BON2-2.5.0.jar"
655+ String obfFile = cacheDir + " modules-2/files-2.1/" + fileName + " .jar"
656+ String deobfFile = cacheDir + " modules-2/files-2.1/" + fileName + " -deobf.jar"
657+
658+ if (file(deobfFile). exists()) {
659+ return files(deobfFile)
660+ }
661+
662+ download {
663+ src ' https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar'
664+ dest bon2File
665+ quiet true
666+ overwrite false
667+ }
668+
669+ download {
670+ src sourceURL
671+ dest obfFile
672+ quiet true
673+ overwrite false
674+ }
675+
676+ exec {
677+ commandLine ' java' , ' -jar' , bon2File, ' --inputJar' , obfFile, ' --outputJar' , deobfFile, ' --mcVer' , ' 1.7.10' , ' --mappingsVer' , ' stable_12' , ' --notch'
678+ workingDir bon2Dir
679+ standardOutput = new ByteArrayOutputStream ()
680+ }
681+
682+ return files(deobfFile)
683+ }
684+
579685// Helper methods
580686
581687def checkPropertyExists (String propertyName ) {
0 commit comments