From 4e95bc8ad7640ad881c222b95fec55cf03a0dfbc Mon Sep 17 00:00:00 2001 From: makamys Date: Sat, 24 Dec 2022 18:41:56 +0100 Subject: Update BS --- .github/workflows/gradle.yml | 14 ++++++++----- .gitignore | 1 - build.gradle | 40 +++++++++++++------------------------- buildscript/forge-1.7-mixin.gradle | 18 ++++++++++++++--- buildscript/forge-1.7.gradle | 27 +++++++++---------------- publish/README.txt | 7 ++++++- publish/build.gradle | 22 ++++++++++++++------- publish/build_and_release.sh | 5 +++-- publish/curseforge_all.sh | 2 +- publish/gradlew | 0 publish/modrinth_all.sh | 2 +- publish/prepare_publish.py | 2 +- publish/update_updatejson.py | 2 +- 13 files changed, 75 insertions(+), 67 deletions(-) mode change 100644 => 100755 publish/gradlew diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 21ef39e..dd37cb2 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -11,18 +11,22 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: - java-version: 1.8 + distribution: 'temurin' + java-version: 8 - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle + - name: Set up Gradle build run: ./gradlew SetupCIWorkspace build - - uses: actions/upload-artifact@v2 + - name: Build with Gradle + run: ./gradlew cleanBuildAll + working-directory: publish + - uses: actions/upload-artifact@v3 with: name: Package path: build/libs diff --git a/.gitignore b/.gitignore index bdf4293..c3a2ca8 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,3 @@ bin/ bin/ jars/ /.nb-gradle/ -libs/ diff --git a/build.gradle b/build.gradle index 1b9e638..731479f 100644 --- a/build.gradle +++ b/build.gradle @@ -2,31 +2,19 @@ unless you have to. Edit project.gradle instead. */ buildscript { - repositories { - mavenCentral() - maven { - name = "forge" - url = "https://maven.minecraftforge.net/" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } - } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - } + repositories { + mavenCentral() + maven { + name = "forge" + url = "https://maven.minecraftforge.net/" + } + maven { + url = "https://jitpack.io" + } + } + dependencies { + classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.11' + } } -plugins { - id 'java-library' - id 'maven-publish' -} - -dependencies { - compile "codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev" - compile "codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev" -} - - -apply from: "buildscript/forge-1.7.gradle" \ No newline at end of file +apply from: "buildscript/forge-1.7.gradle" diff --git a/buildscript/forge-1.7-mixin.gradle b/buildscript/forge-1.7-mixin.gradle index fddc15b..9612084 100644 --- a/buildscript/forge-1.7-mixin.gradle +++ b/buildscript/forge-1.7-mixin.gradle @@ -7,9 +7,21 @@ repositories { } } +def embedMixin = !project.hasProperty("nomixin"); + +if(!embedMixin){ + project.version += "+nomixin" +} + dependencies { - embed('org.spongepowered:mixin:0.7.11-SNAPSHOT'){ - setTransitive false + if(embedMixin){ + embed('org.spongepowered:mixin:0.7.11-SNAPSHOT'){ + setTransitive false + } + } else { + compile('org.spongepowered:mixin:0.7.11-SNAPSHOT'){ + setTransitive false + } } } @@ -39,4 +51,4 @@ afterEvaluate { reobf { addExtraSrgFile outSrgFile -} \ No newline at end of file +} diff --git a/buildscript/forge-1.7.gradle b/buildscript/forge-1.7.gradle index f094cbb..cd74fd8 100644 --- a/buildscript/forge-1.7.gradle +++ b/buildscript/forge-1.7.gradle @@ -55,8 +55,17 @@ if(project.enable_mixin.toBoolean()) { apply from: "buildscript/forge-1.7-mixin.gradle" } +project.ext.override_dependencies = false + apply from: "project.gradle" +if(!project.ext.override_dependencies) { + dependencies { + runtimeOnly "codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev" + runtimeOnly "codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev" + } +} + jar { from(sourceSets.main.output); @@ -90,24 +99,6 @@ tasks.withType(JavaCompile) { options.encoding = "UTF-8" } -// This task creates a .jar file containing the source code of this mod. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource -} - -// This task creates a .jar file containing a deobfuscated version of this mod, for other developers to use in a development environment. -task devJar(type: Jar) { - classifier = "dev" - from sourceSets.main.output -} - -// Creates the listed artifacts on building the mod. -artifacts { - archives sourcesJar - archives devJar -} - // Add git commit hash to MANIFEST.MF def getCommitHash(){ diff --git a/publish/README.txt b/publish/README.txt index b429284..1b777f6 100644 --- a/publish/README.txt +++ b/publish/README.txt @@ -1,2 +1,7 @@ # How to publish -sh ./build_and_release.sh $GITHUB_TOKEN [$CURSEFORGE_TOKEN] [$MODRINTH_TOKEN] \ No newline at end of file + +Push the release's tag before running this. + +``` +sh ./build_and_release.sh $GITHUB_TOKEN [$CURSEFORGE_TOKEN] [$MODRINTH_TOKEN] +``` diff --git a/publish/build.gradle b/publish/build.gradle index 9cf7c6e..1a05d54 100644 --- a/publish/build.gradle +++ b/publish/build.gradle @@ -28,8 +28,9 @@ def getCommitVersion(){ } def buildVersion = getCommitVersion() -def changeLog = new File("${projectDir}/changelog.md").getText('UTF-8') -def gameVersionsMap = new JsonSlurper().parseText(file("gameVersions.json").getText('UTF-8')) +def changeLogFile = new File("${projectDir}/changelog.md") +def changeLog = changeLogFile.exists() ? changeLogFile.getText('UTF-8') : "" +ext.gameVersionsMap = new JsonSlurper().parseText(file("gameVersions.json").getText('UTF-8')) ext.gameVersions = gameVersionsMap.keySet() def githubOK = project.hasProperty("githubToken") @@ -165,14 +166,21 @@ task listFiles { } } -project.gameVersions.collect({toBaseVersion(it)}).each { ver -> - def dir = getVersionProjectPath(ver) - task ("cleanBuild-$ver", type: Exec) { +def getBuildArgumentSets(ver) { + def projectConfig = new Properties() + projectConfig.load(file("../gradle.properties").newReader()) + return projectConfig.enable_mixin ? ["", "-Pnomixin"] : [""] +} + +project.gameVersions.each { ver -> + def baseVer = toBaseVersion(ver) + def dir = getVersionProjectPath(baseVer) + task ("cleanBuild-$baseVer", type: Exec) { workingDir dir - commandLine 'sh', '-c', "rm -f build/libs/* && ./gradlew build" + commandLine 'sh', '-c', "rm -f build/libs/* && " + String.join(" && ", getBuildArgumentSets(ver).collect({"./gradlew build ${it}"})) } } task cleanBuildAll(dependsOn: project.gameVersions.collect({"cleanBuild-${toBaseVersion(it)}"})) { -} \ No newline at end of file +} diff --git a/publish/build_and_release.sh b/publish/build_and_release.sh index 5ab7fe0..7766411 100644 --- a/publish/build_and_release.sh +++ b/publish/build_and_release.sh @@ -28,7 +28,6 @@ MODRINTH_TOKEN=$3 # release py prepare_publish.py ./gradlew githubRelease -PgithubToken=$GITHUB_TOKEN -py update_updatejson.py if [ -n "$CURSEFORGE_TOKEN" ] then @@ -40,4 +39,6 @@ fi if [ -n "$MODRINTH_TOKEN" ] then ./modrinth_all.sh -PmodrinthToken=$MODRINTH_TOKEN -fi \ No newline at end of file +fi + +py update_updatejson.py diff --git a/publish/curseforge_all.sh b/publish/curseforge_all.sh index 280911d..3d10aa7 100644 --- a/publish/curseforge_all.sh +++ b/publish/curseforge_all.sh @@ -1,3 +1,3 @@ for proj in `cat gameVersions.txt`; do ./gradlew curseforge -PgameVersion=$proj $* -done \ No newline at end of file +done diff --git a/publish/gradlew b/publish/gradlew old mode 100644 new mode 100755 diff --git a/publish/modrinth_all.sh b/publish/modrinth_all.sh index 80d68db..e3a6538 100644 --- a/publish/modrinth_all.sh +++ b/publish/modrinth_all.sh @@ -1,3 +1,3 @@ for proj in `cat gameVersions.txt`; do ./gradlew publishModrinth -PgameVersion=$proj $* -done \ No newline at end of file +done diff --git a/publish/prepare_publish.py b/publish/prepare_publish.py index 50e799c..731ec41 100644 --- a/publish/prepare_publish.py +++ b/publish/prepare_publish.py @@ -1,3 +1,3 @@ import json -open("gameVersions.txt", "w").write(" ".join(json.load(open("gameVersions.json", "r")).keys())) \ No newline at end of file +open("gameVersions.txt", "w").write(" ".join(json.load(open("gameVersions.json", "r")).keys())) diff --git a/publish/update_updatejson.py b/publish/update_updatejson.py index d9af683..02a1fe7 100644 --- a/publish/update_updatejson.py +++ b/publish/update_updatejson.py @@ -22,4 +22,4 @@ json.dump(data, open(jsonPath, "w", encoding="utf8"), indent=2) subprocess.run(["git", "add", jsonPath]) subprocess.run(["git", "commit", "-m", "[skip ci] Update update json"]) -subprocess.run(["git", "push"]) \ No newline at end of file +subprocess.run(["git", "push"]) -- cgit