Skip to content

Commit d919914

Browse files
authored
Merge branch 'master' into bugfix
2 parents e8825d7 + 0937feb commit d919914

23 files changed

+551
-267
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
name: Build and test
3+
4+
on:
5+
pull_request:
6+
branches: [ master, main ]
7+
push:
8+
branches: [ master, main ]
9+
10+
jobs:
11+
build-and-test:
12+
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
13+
secrets: inherit

.github/workflows/release-tags.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
name: Release tagged build
3+
4+
on:
5+
push:
6+
tags: [ '*' ]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release-tags:
13+
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
14+
secrets: inherit

build.gradle

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
//version: 1644894948
1+
//version: 1650343995
22
/*
33
DO NOT CHANGE THIS FILE!
44
55
Also, you may replace this file at any time if there is an update available.
66
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
77
*/
88

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
129

1310
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
1411
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
1514

1615
import java.util.concurrent.TimeUnit
1716

@@ -104,6 +103,7 @@ checkPropertyExists("usesShadowedDependencies")
104103
checkPropertyExists("developmentEnvironmentUserName")
105104

106105
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
106+
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
107107

108108
String javaSourceDir = "src/main/java/"
109109
String scalaSourceDir = "src/main/scala/"
@@ -180,18 +180,27 @@ catch (Exception ignored) {
180180
}
181181

182182
// 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+
}
183188
catch (Exception ignored) {
184189
out.style(Style.Failure).text(
185190
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
186191
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
187192
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
188193
)
189194
versionOverride = 'NO-GIT-TAG-SET'
195+
identifiedVersion = versionOverride
190196
}
191-
String versionTag = gitVersion().split("-")[gitVersion().split("-").length - 1]
192-
version = minecraftVersion + '-' + versionTag
197+
version = minecraftVersion + '-' + identifiedVersion
193198
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')
195204
}
196205

197206
group = modGroup
@@ -205,13 +214,17 @@ else {
205214
def arguments = []
206215
def jvmArguments = []
207216

208-
if(usesMixins.toBoolean()) {
217+
if (usesMixins.toBoolean()) {
209218
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"
214220
]
221+
if (usesMixinDebug.toBoolean()) {
222+
jvmArguments += [
223+
"-Dmixin.debug.countInjections=true",
224+
"-Dmixin.debug.verbose=true",
225+
"-Dmixin.debug.export=true"
226+
]
227+
}
215228
}
216229

217230
minecraft {
@@ -303,18 +316,23 @@ def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfig
303316
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
304317

305318
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 = """{
308323
"required": true,
309324
"minVersion": "0.7.11",
310325
"package": "${modGroup}.${mixinsPackage}",
311326
"plugin": "${modGroup}.${mixinPlugin}",
312327
"refmap": "${mixingConfigRefMap}",
313328
"target": "@env(DEFAULT)",
314-
"compatibilityLevel": "JAVA_8"
329+
"compatibilityLevel": "JAVA_8",
330+
"mixins": [],
331+
"client": [],
332+
"server": []
315333
}
316-
317334
"""
335+
}
318336
}
319337
}
320338

@@ -453,7 +471,7 @@ def getManifestAttributes() {
453471
}
454472

455473
task sourcesJar(type: Jar) {
456-
from (sourceSets.main.allJava)
474+
from (sourceSets.main.allSource)
457475
from (file("$projectDir/LICENSE"))
458476
getArchiveClassifier().set('sources')
459477
}
@@ -508,7 +526,7 @@ task devJar(type: Jar) {
508526
}
509527

510528
task apiJar(type: Jar) {
511-
from (sourceSets.main.allJava) {
529+
from (sourceSets.main.allSource) {
512530
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
513531
}
514532

@@ -550,7 +568,7 @@ publishing {
550568
artifact source: shadowJar, classifier: ""
551569
}
552570
if(!noPublishedSources) {
553-
artifact source: sourcesJar, classifier: "src"
571+
artifact source: sourcesJar, classifier: "sources"
554572
}
555573
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
556574
if (apiPackage) {
@@ -560,7 +578,7 @@ publishing {
560578
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
561579
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
562580
// 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
564582

565583
// remove extra garbage from minecraft and minecraftDeps configuration
566584
pom.withXml {
@@ -597,10 +615,46 @@ publishing {
597615
// Updating
598616
task updateBuildScript {
599617
doLast {
618+
if (performBuildScriptUpdate(projectDir.toString())) return
619+
600620
print("Build script already up-to-date!")
601621
}
602622
}
603623

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+
604658
static String getVersionHash(String buildScriptContent) {
605659
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
606660
if(versionLine != null) {

dependencies.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Add your dependencies here
22

33
dependencies {
4-
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev')
5-
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:dev')
4+
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev')
5+
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-87-GTNH:dev')
66
compile('curse.maven:cofh-core-69162:2388751')
77
compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false}
88
compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.8.5:dev")
99

10-
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
10+
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.7:dev")
1111
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
1212
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
1313
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
@@ -20,6 +20,7 @@ dependencies {
2020
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
2121
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') {transitive = false}
2222
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.29:dev") {transitive = false}
23+
compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false}
2324

2425
runtime("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
2526
}

0 commit comments

Comments
 (0)