diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml new file mode 100644 index 000000000..30b3b4ce4 --- /dev/null +++ b/.github/workflows/gradle-publish.yml @@ -0,0 +1,43 @@ +name: Publish +on: + workflow_dispatch: + push: +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: "Checkout" + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'oracle' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Publish + run: ./gradlew publish + env: + MAVEN_USER: ${{ secrets.MAVEN_USER }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + BUILD_NUMBER: ${{ github.run_number }} + - name: CurseForge Publish + run: ./gradlew curseforge -PcurseApiKey=${CURSE_API_KEY} + env: + CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} + BUILD_NUMBER: ${{ github.run_number }} + continue-on-error: true + - name: Modrinth Publish + run: ./gradlew modrinth -PmodrinthToken=${MODRINTH_TOKEN} + env: + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + BUILD_NUMBER: ${{ github.run_number }} + continue-on-error: true diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 0d926f0ea..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,60 +0,0 @@ -@Library('forge-shared-library')_ - -pipeline { - options { - disableConcurrentBuilds() - } - agent { - docker { - image 'gradle:7-jdk16' - } - } - environment { - GRADLE_ARGS = '-Dorg.gradle.daemon.idletimeout=5000' - } - stages { - stage('fetch') { - steps { - checkout scm - } - } - stage('setup') { - steps { - withGradle { - sh './gradlew ${GRADLE_ARGS} --refresh-dependencies' - } - script { - env.MYVERSION = sh(returnStdout: true, script: './gradlew :properties -q | grep "^version:" | awk \'{print $2}\'').trim() - } - } - } - stage('changelog') { - when { - not { - changeRequest() - } - } - steps { - writeChangelog(currentBuild, "build/BiomesOPlenty-${env.MYVERSION}-changelog.txt") - } - } - stage('publish') { - when { - not { - changeRequest() - } - } - environment { - CURSE_API_KEY = credentials('curse-api-key') - } - steps { - withCredentials([usernamePassword(credentialsId: 'maven-adubbz-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) { - sh './gradlew ${GRADLE_ARGS} publish' - } - withGradle { - sh './gradlew ${GRADLE_ARGS} curseforge -PcurseApiKey=${CURSE_API_KEY}' - } - } - } - } -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6d175b48b..6512d91d3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,38 +1,47 @@ -buildscript { - repositories { - maven { url = 'https://maven.minecraftforge.net/' } - maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.+', changing: true - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' - } - - gradle.projectsEvaluated { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xmaxerrs" << "1000" - } - } -} - plugins { + id "net.minecraftforge.gradle" version "6.0.+" + id "org.spongepowered.mixin" version "0.7-SNAPSHOT" id "com.matthewprenger.cursegradle" version "1.4.0" + id "com.modrinth.minotaur" version "2.+" + id 'net.minecraftforge.gradleutils' version '2.2.0' } -apply plugin: 'maven-publish' -apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'java' apply plugin: 'idea' -apply plugin: 'org.spongepowered.mixin' +apply plugin: 'maven-publish' + +ext { + mod_version = gradleutils.getTagOffsetVersion() + changelog_file = project.file("build/changelog.txt") +} -repositories { mavenLocal() } +changelog { + fromTag '18.2.0' +} + +def trimChangelog(String text) { + def m = text =~ /(?s) - (?:[0-9.]+) (.+?)(?=( - )|$)/ + return '```\n' + m[0][1].replaceAll(/(?m)^ */, '') +} group = "com.github.glitchfiend" -archivesBaseName = "${mod_name}" -version = "${minecraft_version}-${mod_version}.${System.getenv().BUILD_NUMBER}" -def mod_build_version = "${mod_version}.${System.getenv().BUILD_NUMBER}" +base.archivesName = mod_name +version = "${minecraft_version}-${mod_version}" java.toolchain.languageVersion = JavaLanguageVersion.of(17) +java.withSourcesJar() + +tasks.withType(JavaCompile).configureEach { + it.options.encoding = 'UTF-8' + it.options.release.set(17) +} + +// Disables Gradle's custom module metadata from being published to maven. The +// metadata includes mapped dependencies which are not reasonably consumable by +// other mod developers. +tasks.withType(GenerateModuleMetadata) { + enabled = false +} minecraft { mappings channel: 'official', version: minecraft_version @@ -41,37 +50,53 @@ minecraft { runs { client = { workingDirectory = project.file("run") - source sourceSets.main + ideaModule "${project.name}.main" + taskName 'Client' + mods { + modClientRun { + source sourceSets.main + } + } } - server = { - workingDirectory = project.file("run") - source sourceSets.main + server { + workingDirectory project.file('run') + ideaModule "${project.name}.main" + taskName 'Server' + mods { + modServerRun { + source sourceSets.main + } + } } data { - workingDirectory = project.file("run") - source sourceSets.main - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/'), '--existing', file('src/generated/resources/') + workingDirectory project.file('run') + ideaModule "${project.name}.main" + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + taskName 'Data' + mods { + modDataRun { + source sourceSets.main + } + } } } } -// Configure the source folders sourceSets { - main { + api { java { - srcDir "src/main/java" + compileClasspath += main.compileClasspath + srcDirs main.java.srcDirs + include "${mod_id}/api/**" } + } + main { resources { - srcDir "src/main/resources" srcDir 'src/generated/resources' } } } -processResources { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - dependencies { minecraft 'net.minecraftforge:forge:' + minecraft_version + '-' + forge_version implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:${terrablender_version}") @@ -82,43 +107,33 @@ jar { attributes([ 'Specification-Title' : mod_name, 'Specification-Vendor' : mod_author, - 'Specification-Version' : mod_build_version, + 'Specification-Version' : mod_version, 'Implementation-Title' : project.name, - 'Implementation-Version' : mod_build_version, + 'Implementation-Version' : mod_version, 'Implementation-Vendor' : mod_author, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - 'Timestampe' : System.currentTimeMillis(), + 'Timestamp' : System.currentTimeMillis(), 'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", 'Build-On-Minecraft' : minecraft_version ]) } } -task deobfJar(type: Jar) { - from sourceSets.main.output - classifier = 'deobf' -} - task apiJar(type: Jar) { - from(sourceSets.main.allJava) { - include "${mod_id}/api/**" - } - from (sourceSets.main.output) { - include 'LICENSE.txt' - include "${mod_id}/api/**" - } + from sourceSets.api.allJava, sourceSets.api.output + archiveClassifier = 'api' +} - // TODO: Investigate why there are duplicates produced in the first place - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - classifier = 'api' +task deobfJar(type: Jar) { + from sourceSets.main.output + archiveClassifier = 'deobf' } -def changelog_file = rootProject.file("build/${mod_name}-${version}-changelog.txt") +build.dependsOn apiJar +build.dependsOn deobfJar curseforge { - if (project.hasProperty('curseApiKey')) { - apiKey = project.getProperty('curseApiKey') - } + apiKey = project.findProperty('curseApiKey') ?: 'unset' project { id = mod_curseforge_id @@ -135,20 +150,26 @@ curseforge { addArtifact deobfJar addArtifact apiJar - + relations { requiredDependency 'terrablender' } } } -artifacts { +modrinth { + token = project.findProperty('modrinthToken') + projectId = mod_modrinth_id + versionNumber = mod_version + versionName = version + " for Forge " + minecraft_version + versionType = 'beta' // can be release, beta, or alpha + uploadFile = jar + gameVersions = [minecraft_version] + loaders = ['forge'] + if (changelog_file.exists()) { - archives changelog_file + changelog = trimChangelog(changelog_file.text) } - archives jar - archives deobfJar - archives apiJar } publishing { @@ -156,8 +177,8 @@ publishing { mavenJava(MavenPublication) { // We must use artifact jar to ensure the Forge dependency is excluded from the pom, breaking fg.deobf() artifact jar - artifact deobfJar artifact apiJar + artifact deobfJar groupId project.group artifactId project.archivesBaseName version project.version @@ -195,13 +216,10 @@ publishing { } repositories { maven { - url "https://maven.minecraftforge.net/releases/" - authentication { - basic(BasicAuthentication) - } + url = "https://maven.minecraftforge.net/releases/" credentials { - username = System.env.MAVEN_USER ?:'fake' - password = System.env.MAVEN_PASSWORD ?:'news' + username = System.getenv("MAVEN_USER") + password = System.getenv("MAVEN_PASSWORD") } } } diff --git a/gradle.properties b/gradle.properties index 6029612e9..f4d707c13 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,6 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # Project -mod_version=18.1.0 mod_id=biomesoplenty mod_name=BiomesOPlenty mod_display_name=Biomes O' Plenty @@ -14,6 +13,7 @@ mod_issues_url=https://github.com/Glitchfiend/BiomesOPlenty/issues mod_git_url=https://github.com/Glitchfiend/BiomesOPlenty mod_scm_url=scm:git:git@github.com:Glitchfiend/BiomesOPlenty.git mod_curseforge_id=220318 +mod_modrinth_id=biomes-o-plenty # Dependencies minecraft_version=1.20.2 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2..c1962a79e 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661ee..744c64d12 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c78733..aeb74cbb4 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${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"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -143,12 +140,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# 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"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +210,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32c..93e3f59f1 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 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 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..80c183a29 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,19 @@ +pluginManagement.repositories { + gradlePluginPortal() + maven { + name = "Fabric" + url = "https://maven.fabricmc.net/" + } + maven { + name = "NeoForge" + url = "https://maven.neoforged.net/releases" + } + maven { + name = "Forge" + url = "https://maven.minecraftforge.net" + } + maven { + name = "Sponge Snapshots" + url = "https://repo.spongepowered.org/repository/maven-public/" + } +}