diff options
27 files changed, 828 insertions, 182 deletions
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..2858775 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,26 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew SetupCIWorkspace build + - uses: actions/upload-artifact@v2 + with: + name: Package + path: build/libs @@ -1,17 +1,36 @@ -.classpath -.metadata +# mac os +.DS_Store + +# forge / gradle .gradle -.project -.settings -bin/ build/ -jars/ +out/ +classes/ run/ -*.iml + +# eclipse *.launch +.settings +.classpath +.project +.metadata +eclipse +*.launch + +# idea +.idea/ +*.iml +*.ipr +*.iws + +# vscode +.settings/ +.vscode/ +bin/ +.classpath + +# other +bin/ +jars/ /.nb-gradle/ libs/ - -/*Audio files*/ -*.ogg -*.WAV diff --git a/build.gradle b/build.gradle index 5a3a3bf..1b9e638 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,12 @@ +/** The root of the build. Exposed for flexibility, but you shouldn't edit it + unless you have to. Edit project.gradle instead. */ + buildscript { repositories { mavenCentral() - jcenter() maven { name = "forge" - url = "http://files.minecraftforge.net/maven" + url = "https://maven.minecraftforge.net/" } maven { name = "sonatype" @@ -13,102 +15,18 @@ buildscript { } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - // MixinGradle only works with ForgeGradle 2+, so we need to implement it ourselves. - // (Comments mark the lines where this is done.) - //classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' - } -} - -repositories { - maven { // this has to be here and not in buildscript.repositories, otherwise Gradle won't find mixin <0.8 for some reason - name = 'sponge' - url = 'https://repo.spongepowered.org/maven/' } } -configurations { - embed - compile.extendsFrom(embed) -} - -apply plugin: 'forge' - -version = "0.0" -group= "makamys.lodmod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "lodmod" - -minecraft { - version = "1.7.10-10.13.4.1614-1.7.10" - runDir = "run" +plugins { + id 'java-library' + id 'maven-publish' } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - dependencies { - embed 'org.spongepowered:mixin:0.7+' - - /* Mixin 0.8 breaks with 1.7.10, but can be made to work by embedding these. However, - doing so overrides the libraries provided by Forge, which will likely result in other mods breaking. */ - //embed 'org.ow2.asm:asm-all:5.2' - //embed 'com.google.guava:guava:21.0' -} - -def outRefMapFile = tasks.compileJava.temporaryDir.toString() + "/lodmod.mixin.refmap.json" // 1.7.10 mixin compatibility - -jar { - manifest { - attributes ( - 'MixinConfigs': 'lodmod.mixin.json', - 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', - 'TweakOrder': 0, - - // If these two are not set, Forge will not detect the mod, it will only run the mixins - 'FMLCorePluginContainsFMLMod': 'true', - 'ForceLoadAsMod': 'true', - 'FMLAT': "LODMod_at.cfg" - ) - } - - from(sourceSets.main.output); - - from outRefMapFile; // 1.7.10 mixin compatibility - - // embed libraries in jar - from configurations.embed.collect { - exclude '**/LICENSE.txt' - it.isDirectory() ? it : zipTree(it) - } -} - -// 1.7.10 mixin compatibility -def outSrgFile = tasks.compileJava.temporaryDir.toString() + "/outSrg.srg" - -afterEvaluate { - tasks.compileJava.options.compilerArgs += ["-AreobfSrgFile=${tasks.reobf.srg}", "-AoutSrgFile=${outSrgFile}", "-AoutRefMapFile=${outRefMapFile}"]; -} - -reobf { - addExtraSrgFile outSrgFile + compile "codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev" + compile "codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev" } -// end of mixin stuff -processResources -{ - // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } -} +apply from: "buildscript/forge-1.7.gradle"
\ No newline at end of file diff --git a/buildscript/forge-1.7-mixin.gradle b/buildscript/forge-1.7-mixin.gradle new file mode 100644 index 0000000..fddc15b --- /dev/null +++ b/buildscript/forge-1.7-mixin.gradle @@ -0,0 +1,42 @@ +/** Applying this file in a Forge build will imbue it with the powers of Mixin. */ + +repositories { + maven { + name = 'sponge' + url = 'https://repo.spongepowered.org/maven/' + } +} + +dependencies { + embed('org.spongepowered:mixin:0.7.11-SNAPSHOT'){ + setTransitive false + } +} + +ext.outRefMapFile = "${tasks.compileJava.temporaryDir}/${project.modid}.mixin.refmap.json" + +jar { + manifest { + attributes ( + 'MixinConfigs': "${project.modid}.mixin.json", + 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', + 'TweakOrder': 0, + + // If these two are not set, Forge will not detect the mod, it will only run the mixins + 'FMLCorePluginContainsFMLMod': 'true', + 'ForceLoadAsMod': 'true', + ) + } + + from outRefMapFile; +} + +def outSrgFile = "${tasks.compileJava.temporaryDir}/outSrg.srg" + +afterEvaluate { + tasks.compileJava.options.compilerArgs += ["-AreobfSrgFile=${tasks.reobf.srg}", "-AoutSrgFile=${outSrgFile}", "-AoutRefMapFile=${outRefMapFile}"]; +} + +reobf { + addExtraSrgFile outSrgFile +}
\ No newline at end of file diff --git a/buildscript/forge-1.7.gradle b/buildscript/forge-1.7.gradle new file mode 100644 index 0000000..ca2f66b --- /dev/null +++ b/buildscript/forge-1.7.gradle @@ -0,0 +1,90 @@ +/** Common code for Forge 1.7.10 builds */ + +apply plugin: 'forge' + + +project.version = new File(project.multiproject_structure.toBoolean() ? "${projectDir}/../version.txt" : "${projectDir}/publish/version.txt").getText('UTF-8').trim() + +group = project.group +archivesBaseName = "${project.archives_base}-${project.minecraft_version}" + +minecraft { + version = "${project.minecraft_version}-${project.forge_version}" + runDir = "run" + replace '@VERSION@', project.version +} + +// These settings allow you to choose what version of Java you want to be compatible with. Forge 1.7.10 runs on Java 6 to 8. +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + maven { + name = "chickenbones" + url = "http://chickenbones.net/maven/" + } +} + +configurations { + embed + compile.extendsFrom(embed) + shade + compile.extendsFrom(shade) +} + +if(project.enable_mixin.toBoolean()) { + apply from: "buildscript/forge-1.7-mixin.gradle" +} + +apply from: "project.gradle" + +jar { + from(sourceSets.main.output); + + // embed libraries in jar + from configurations.embed.collect { + exclude '**/LICENSE', '**/LICENSE.txt' + it.isDirectory() ? it : zipTree(it) + } + + configurations.shade.each { dep -> + from(project.zipTree(dep)){ + exclude '**/LICENSE', '**/LICENSE.txt', 'META-INF', 'META-INF/**' + } + } +} + +processResources { + // This will ensure that this task is redone when the versions or any + // user-defined properties change. + inputs.property "version", version + inputs.property "mcversion", project.minecraft.version + inputs.properties project.ext.getProperties() + + filesMatching('*.info') { + expand project.properties + } +} + +// Ensures that the encoding of source files is set to UTF-8, see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +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 +}
\ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..fa12114 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,12 @@ +# Mod properties +modid=lodmod +archives_base=lodmod +# http://maven.apache.org/guides/mini/guide-naming-conventions.html +group=makamys.lodmod + +# Forge properties +minecraft_version=1.7.10 +forge_version=10.13.4.1614-1.7.10 + +enable_mixin=true +multiproject_structure=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differindex 30d399d..e708b1c 100644 --- a/gradle/wrapper/gradle-wrapper.jar +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2f7d10e..752f5af 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Sep 14 12:28:28 PDT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip @@ -1,4 +1,20 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## ## @@ -6,20 +22,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +64,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,33 +75,14 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -90,7 +106,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -110,11 +126,13 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" @@ -138,27 +156,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -8,20 +24,23 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,34 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/project.gradle b/project.gradle new file mode 100644 index 0000000..c25475a --- /dev/null +++ b/project.gradle @@ -0,0 +1,7 @@ +jar { + manifest { + attributes ( + 'FMLAT': "LODMod_at.cfg" + ) + } +} diff --git a/publish/.gitignore b/publish/.gitignore new file mode 100644 index 0000000..cfeecb5 --- /dev/null +++ b/publish/.gitignore @@ -0,0 +1,2 @@ +changelog.md +gameVersions.txt
\ No newline at end of file diff --git a/publish/README.txt b/publish/README.txt new file mode 100644 index 0000000..b429284 --- /dev/null +++ b/publish/README.txt @@ -0,0 +1,2 @@ +# How to publish +sh ./build_and_release.sh $GITHUB_TOKEN [$CURSEFORGE_TOKEN] [$MODRINTH_TOKEN]
\ No newline at end of file diff --git a/publish/build.gradle b/publish/build.gradle new file mode 100644 index 0000000..85425aa --- /dev/null +++ b/publish/build.gradle @@ -0,0 +1,158 @@ +plugins { + id "com.github.breadmoirai.github-release" version "2.2.12" + id "com.matthewprenger.cursegradle" version "1.4.0" + id "com.modrinth.minotaur" version "1.2.1" +} + +import com.modrinth.minotaur.TaskModrinthUpload +import groovy.json.JsonSlurper +import okhttp3.OkHttpClient +import java.util.concurrent.TimeUnit + +def buildVersion = new File("${projectDir}/version.txt").getText('UTF-8').trim() +def changeLog = new File("${projectDir}/changelog.md").getText('UTF-8') +def gameVersionsMap = new JsonSlurper().parseText(file("gameVersions.json").getText('UTF-8')) +ext.gameVersions = gameVersionsMap.keySet() + +def githubOK = project.hasProperty("githubToken") +def curseOK = project.hasProperty("curseToken") && project.hasProperty("gameVersion") +def modrinthOK = project.hasProperty("modrinthToken") && project.hasProperty("gameVersion") + +def debugPublish = project.hasProperty("debugPublish") && project.debugPublish.toBoolean() + +task build {} +task assemble {} + +if(githubOK){ + githubRelease { + token project.githubToken // This is your personal access token with Repo permissions + // You get this from your user settings > developer settings > Personal Access Tokens + owner project.githubOwner // default is the last part of your group. Eg group: "com.github.breadmoirai" => owner: "breadmoirai" + repo project.githubRepo // by default this is set to your project name + tagName "v${buildVersion}" // by default this is set to "v${project.version}" + targetCommitish "master" // by default this is set to "master" + releaseName "${project.releaseName} ${buildVersion}" + body changeLog // by default this is empty + draft false // by default this is false + prerelease false // by default this is false + releaseAssets getFiles() // this points to which files you want to upload as assets with your release + + overwrite false // by default false; if set to true, will delete an existing release with the same tag and name + dryRun debugPublish // by default false; you can use this to see what actions would be taken without making a release + apiEndpoint "https://api.github.com" // should only change for github enterprise users + client new OkHttpClient.Builder() + .writeTimeout(5, TimeUnit.MINUTES) + .readTimeout(5, TimeUnit.MINUTES) + .build() // Added because I kept getting SocketTimeoutExceptions + } +} else { + println("Not configuring GitHub publish because project arguments are missing.") +} + +if(project.hasProperty("gameVersion")){ + def gameVersion = project.gameVersion + def baseVersion = toBaseVersion(gameVersion) + def files = getFiles(baseVersion) + def shortest = null + files.each { + if(shortest == null || it.name.length() < shortest.name.length()){ + shortest = it + } + } + def additionalFiles = files - shortest + + if(curseOK) { + curseforge { + apiKey = project.curseToken + project { + id = project.curseID + changelogType = 'markdown' + changelog = changeLog + releaseType = 'release' + addGameVersion gameVersion + addGameVersion "Forge" + + mainArtifact(file(shortest)) { + displayName = "${releaseName} ${buildVersion} for Minecraft ${gameVersion}" + } + additionalFiles.each { addArtifact(it) } + } + options { + debug = debugPublish + javaIntegration = false + forgeGradleIntegration = false + javaVersionAutoDetect = false + } + } + } else { + println("Not configuring CurseForge publish because project arguments are missing.") + } + + if(modrinthOK) { + task publishModrinth (type: TaskModrinthUpload) { + token = project.modrinthToken + projectId = project.modrinthID + versionNumber = "$gameVersion-$buildVersion" + versionName = "$gameVersion-$buildVersion" // the doc says this defaults to the versionNumber, but it defaulted to the string "undefined" for me so i'm setting it + uploadFile = shortest + addGameVersion(gameVersion) + additionalFiles.each { addFile(it) } + addLoader('forge') + changelog = changeLog + detectLoaders = false + } + } else { + println("Not configuring Modrinth publish because project arguments are missing.") + } +} + +def toBaseVersion(ver){ + return String.join(".", ver.tokenize(".").subList(0, 2)) +} + +def getVersionProjectPath(ver){ + if(project.versionedProjectDirectories.toBoolean()){ + return "${projectDir}/../${ver}" + } else { + return "${projectDir}/.." + } +} + +def getFiles(ver) { + def files = [] + new File("${getVersionProjectPath(ver)}/build/libs").eachFile(groovy.io.FileType.FILES, { + if(!(it.name.endsWith("-sources.jar") || it.name.endsWith("-dev.jar"))){ + files << it + } + }) + return files +} + +def getFiles() { + def files = [] + project.gameVersions.collect({toBaseVersion(it)}).each { + files += getFiles(it) + } + return files +} + +// for debug +task listFiles { + doLast { + project.gameVersions.collect({toBaseVersion(it)}).each { + println("$it: ${getFiles(it)}") + } + } +} + +project.gameVersions.collect({toBaseVersion(it)}).each { ver -> + def dir = getVersionProjectPath(ver) + task ("cleanBuild-$ver", type: Exec) { + workingDir dir + commandLine 'sh', '-c', "rm -f build/libs/* && ./gradlew build" + } +} + +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 new file mode 100644 index 0000000..5ab7fe0 --- /dev/null +++ b/publish/build_and_release.sh @@ -0,0 +1,43 @@ +if [ ! -s changelog.md ]; then + echo "Changelog is empty, refusing to publish." + exit 3 +fi + +if [[ $(git diff --cached --stat) != '' ]] +then + echo "There are staged uncommitted changes, refusing to publish." + exit 2 +fi + +if [ "$#" -lt 1 ] || [ "$#" -gt 3 ] +then + echo "Usage: $0 GITHUB_TOKEN CURSEFORGE_TOKEN [MODRINTH_TOKEN]" + exit 1 +fi + +# exit when any command fails +set -e + +GITHUB_TOKEN=$1 +CURSEFORGE_TOKEN=$2 +MODRINTH_TOKEN=$3 + +# build the release +./gradlew cleanBuildAll + +# release +py prepare_publish.py +./gradlew githubRelease -PgithubToken=$GITHUB_TOKEN +py update_updatejson.py + +if [ -n "$CURSEFORGE_TOKEN" ] +then + ./curseforge_all.sh -PcurseToken=$CURSEFORGE_TOKEN +fi + +/dev/null > changelog.md + +if [ -n "$MODRINTH_TOKEN" ] +then + ./modrinth_all.sh -PmodrinthToken=$MODRINTH_TOKEN +fi
\ No newline at end of file diff --git a/publish/curseforge_all.sh b/publish/curseforge_all.sh new file mode 100644 index 0000000..280911d --- /dev/null +++ b/publish/curseforge_all.sh @@ -0,0 +1,3 @@ +for proj in `cat gameVersions.txt`; do + ./gradlew curseforge -PgameVersion=$proj $* +done
\ No newline at end of file diff --git a/publish/gameVersions.json b/publish/gameVersions.json new file mode 100644 index 0000000..39f71f6 --- /dev/null +++ b/publish/gameVersions.json @@ -0,0 +1,3 @@ +{ + "1.7.10": {} +}
\ No newline at end of file diff --git a/publish/gradle.properties b/publish/gradle.properties new file mode 100644 index 0000000..2f104f6 --- /dev/null +++ b/publish/gradle.properties @@ -0,0 +1,10 @@ +githubOwner= +githubRepo= + +curseID= +modrinthID= + +releaseName= + +versionedProjectDirectories=false +updateJsonFullVersionFormat=false
\ No newline at end of file diff --git a/publish/gradle/wrapper/gradle-wrapper.jar b/publish/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 0000000..30d399d --- /dev/null +++ b/publish/gradle/wrapper/gradle-wrapper.jar diff --git a/publish/gradle/wrapper/gradle-wrapper.properties b/publish/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..22ad9ab --- /dev/null +++ b/publish/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Sep 14 12:28:28 PDT 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip diff --git a/publish/gradlew b/publish/gradlew new file mode 100644 index 0000000..91a7e26 --- /dev/null +++ b/publish/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/publish/gradlew.bat b/publish/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/publish/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/publish/modrinth_all.sh b/publish/modrinth_all.sh new file mode 100644 index 0000000..80d68db --- /dev/null +++ b/publish/modrinth_all.sh @@ -0,0 +1,3 @@ +for proj in `cat gameVersions.txt`; do + ./gradlew publishModrinth -PgameVersion=$proj $* +done
\ No newline at end of file diff --git a/publish/prepare_publish.py b/publish/prepare_publish.py new file mode 100644 index 0000000..50e799c --- /dev/null +++ b/publish/prepare_publish.py @@ -0,0 +1,3 @@ +import json + +open("gameVersions.txt", "w").write(" ".join(json.load(open("gameVersions.json", "r")).keys()))
\ No newline at end of file diff --git a/publish/update_updatejson.py b/publish/update_updatejson.py new file mode 100644 index 0000000..8d751e5 --- /dev/null +++ b/publish/update_updatejson.py @@ -0,0 +1,25 @@ +import json +import subprocess + +jsonPath = "../updatejson/update.json" + +# lol +fullFormat = "updateJsonFullVersionFormat=true" in open("gradle.properties", "r", encoding="utf8").read() + +data = json.load(open(jsonPath, "r", encoding="utf8")) +ver = open("version.txt", "r").read().strip() + +for gameVer in json.load(open("gameVersions.json", "r")).keys(): + modVer = "{}".format(ver) if not fullFormat else "{}-{}".format(gameVer, ver) + + if gameVer not in data: + data[gameVer] = {} + + data[gameVer][modVer] = "" + data["promos"]["{}-latest".format(gameVer)] = modVer + +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 diff --git a/publish/version.txt b/publish/version.txt new file mode 100644 index 0000000..171538e --- /dev/null +++ b/publish/version.txt @@ -0,0 +1 @@ +0.0
\ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 7d06cb6..2a52d7c 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,10 +1,10 @@ [ { - "modid": "lodmod", + "modid": "${modid}", "name": "LOD mod", "description": "Increases render distance by rendering distant chunks with a low level of detail", "version": "${version}", - "mcversion": "${mcversion}", + "mcversion": "${minecraft_version}", "url": "", "updateUrl": "", "authorList": ["makamys"], |