Skip to content

Commit

Permalink
Merge branch 'master' into bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
GlodBlock authored Aug 1, 2022
2 parents e8825d7 + 0937feb commit d919914
Show file tree
Hide file tree
Showing 23 changed files with 551 additions and 267 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

name: Build and test

on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]

jobs:
build-and-test:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

name: Release tagged build

on:
push:
tags: [ '*' ]

permissions:
contents: write

jobs:
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
94 changes: 74 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
//version: 1644894948
//version: 1650343995
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/

import org.gradle.internal.logging.text.StyledTextOutput
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.logging.text.StyledTextOutput.Style

import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory

import java.util.concurrent.TimeUnit

Expand Down Expand Up @@ -104,6 +103,7 @@ checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")

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

String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
Expand Down Expand Up @@ -180,18 +180,27 @@ catch (Exception ignored) {
}

// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception ignored) {
out.style(Style.Failure).text(
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
)
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
String versionTag = gitVersion().split("-")[gitVersion().split("-").length - 1]
version = minecraftVersion + '-' + versionTag
version = minecraftVersion + '-' + identifiedVersion
ext {
modVersion = versionTag
modVersion = identifiedVersion
}

if(identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}

group = modGroup
Expand All @@ -205,13 +214,17 @@ else {
def arguments = []
def jvmArguments = []

if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
jvmArguments += [
"-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true"
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
if (usesMixinDebug.toBoolean()) {
jvmArguments += [
"-Dmixin.debug.countInjections=true",
"-Dmixin.debug.verbose=true",
"-Dmixin.debug.export=true"
]
}
}

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

task generateAssets {
if(usesMixins.toBoolean()) {
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
if (usesMixins.toBoolean()) {
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
if (!mixinConfigFile.exists()) {
mixinConfigFile.text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [],
"server": []
}
"""
}
}
}

Expand Down Expand Up @@ -453,7 +471,7 @@ def getManifestAttributes() {
}

task sourcesJar(type: Jar) {
from (sourceSets.main.allJava)
from (sourceSets.main.allSource)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
Expand Down Expand Up @@ -508,7 +526,7 @@ task devJar(type: Jar) {
}

task apiJar(type: Jar) {
from (sourceSets.main.allJava) {
from (sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}

Expand Down Expand Up @@ -550,7 +568,7 @@ publishing {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
artifact source: sourcesJar, classifier: "src"
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
Expand All @@ -560,7 +578,7 @@ publishing {
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: versionTag
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion

// remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
Expand Down Expand Up @@ -597,10 +615,46 @@ publishing {
// Updating
task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return

print("Build script already up-to-date!")
}
}

if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
}
}

static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
}

boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}

boolean isNewBuildScriptVersionAvailable(String projectDir) {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]

String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)

boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}

static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
Expand Down
7 changes: 4 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Add your dependencies here

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

compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.7:dev")
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
Expand All @@ -20,6 +20,7 @@ dependencies {
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.29:dev") {transitive = false}
compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false}

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

0 comments on commit d919914

Please sign in to comment.