diff --git a/README.MD b/README.MD index 8d47b50..9f17a97 100644 --- a/README.MD +++ b/README.MD @@ -52,7 +52,7 @@ class ExampleMod implements BaseGMod { ``` ## Groovy Version -The Groovy version provided by the latest version of GML is currently: **4.0.12**. +The Groovy version provided by the latest version of GML is currently: **4.0.13**. To find out what Groovy version a built GML jar provides, you can read the `BundledGroovyVersion` property in the `META-INF/MANIFEST.MF`. Only releases will be supported by GML, not release candidates. @@ -69,9 +69,28 @@ The major GML version is bumped every MC version. Below you can find a list of M - `1.19.3` -> `2.x.x` - `1.19.4` -> `3.x.x` - `1.20.0` -> `4.x.x` + **NOTE**: 1.19.2 - 1.19.4 versions use the `com.matyrobbrt.gml` artifact group. ## Shading GML While we would appreciate if you instead had a dependency on GML on [CurseForge](https://www.curseforge.com/minecraft/mc-mods/gml) in order provide us revenue, we understand that in some cases, you may not want to depend on another mod. Fortunately, we _are_ JiJ-able. If you want to JiJ GML, just follow the guide [here](https://forge.gemwire.uk/wiki/Jar-in-Jar) but replace GSON with the `all` version of GML (the `runtimeOnly` one). + +## Contributing +We welcome contributions to GML. If you want to contribute, please open a PR with your changes. + +### Troubleshooting + +#### Unable to build +Make sure to include the Git tags when forking, as they are used to determine the version of GML and the build will fail if they are not present: +```shell +git fetch --tags upstream +git push --tags +``` + +#### GML not showing up in-game when running in IDE +Developing GML requires you to use the Gradle run tasks to test your changes rather than the IDE run configurations, for example, use `./gradlew runClient` instead of the IntelliJ `runClient` run configuration. + +#### Updating the README +Remember to run the `makeReadme` task when updating the README template or Groovy version, otherwise the README will be outdated. diff --git a/build.gradle b/build.gradle index 14ea333..23ae962 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,8 @@ import com.matyrobbrt.gradle.jarinjar.task.* import com.matyrobbrt.gradle.jarinjar.transform.ForgeManifestFixerTransformer +import com.modrinth.minotaur.TaskModrinthUpload +import groovy.transform.CompileStatic +import io.github.groovymc.modsdotgroovy.ConvertToTomlTask import net.darkhax.curseforgegradle.TaskPublishCurseForge import org.eclipse.jgit.api.Git @@ -8,29 +11,55 @@ plugins { id 'maven-publish' id 'org.cadixdev.licenser' version '0.6.1' id 'com.matyrobbrt.jarinjar' version '1.2.+' - id 'net.minecraftforge.gradle' version '5.1.+' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'org.groovymc.simpleci' version '0.2.+' + id 'org.groovymc.modsdotgroovy' version "${mdg_plugin_version}" id 'org.parchmentmc.librarian.forgegradle' version '1.+' id 'com.modrinth.minotaur' version "${minotaur_version}" - id 'com.github.johnrengelman.shadow' version '7.1.2' apply false + id 'com.github.johnrengelman.shadow' version '8.1.1' apply false id 'net.darkhax.curseforgegradle' version "${cursegradle_version}" } +// Project setup +// ------------- archivesBaseName = 'gml' group = 'org.groovymc.gml' +java.toolchain.languageVersion = JavaLanguageVersion.of(17) // 1.18+ uses Java 17 + +println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" + +apply from: 'gradle/projectSetup.gradle' + +// SimpleCI +// -------- versioning { fromTag.set('4.0') } final calculatedVersion = Git.open(rootProject.projectDir).withCloseable { versioning.calculateVersion(it) { cm, info -> } } -project.ext.versionBasedReleaseType = calculatedVersion.alphaBeta.betaNumber != -1 ? 'beta' : (calculatedVersion.alphaBeta.alphaNumber != -1 ? 'alpha' : 'release') +final String versionBasedReleaseType = calculatedVersion.alphaBeta.betaNumber !== -1 ? 'beta' : (calculatedVersion.alphaBeta.alphaNumber !== -1 ? 'alpha' : 'release') allprojects { Project proj -> println("${proj.name} version: ${proj.version = calculatedVersion.toString()}") } -project.ext.groovyLibs = [ +// mods.groovy +// ----------- +modsDotGroovy { + dslVersion = '1.5.1' + automaticConfiguration = false +} +tasks.create('testModsDotGroovyToToml', ConvertToTomlTask) { + configureForSourceSet(sourceSets.test) +} +tasks.create('modModsDotGroovyToToml', ConvertToTomlTask) { + configureForSourceSet(sourceSets.mod) +} + +// Dependencies +// ------------ +final String[] groovyLibs = [ 'stdlib', 'contracts', 'datetime', 'nio', 'macro', 'macro-library', 'templates', 'typecheckers', @@ -39,43 +68,6 @@ project.ext.groovyLibs = [ 'toml', 'json' ] -project.ext.manifestAttr = [ - 'Specification-Title' : 'GroovyModLoader', - 'Specification-Vendor' : 'GroovyMC', - 'Specification-Version' : 1, - 'Implementation-Title' : project.name, - 'Implementation-Version': project.version, - 'Implementation-Vendor' : 'GroovyMC', - 'BundledGroovyVersion' : project.groovy_version, - 'GitCommit' : getGitCommit(), - 'FMLModType' : 'LANGPROVIDER', - 'Built-on-Minecraft' : project.mc_version -] - -apply from: 'gradle/projectSetup.gradle' -apply from: 'gradle/mdg.gradle' -apply from: 'gradle/jars.gradle' -apply from: 'gradle/compiler.gradle' - -tasks.register('publishCurseForge', TaskPublishCurseForge) -tasks.register('fullJar', ForgeJarInJarTask) -tasks.register('jijtestJar', ForgeJarInJarTask) -apply from: 'gradle/minecraft.gradle' -apply from: 'gradle/publishing.gradle' - -// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" - -allprojects { - afterEvaluate { - license { - header = rootProject.file('license-header.txt') - exclude('**/mods.groovy') - } - } -} repositories { maven { @@ -88,29 +80,15 @@ repositories { } } -jij.onConfiguration('groovy') { - final manifestFix = new ForgeManifestFixerTransformer(modType: 'LIBRARY', modulePrefix: 'org.groovymc.gml.groovyjij') - eachMatching('.+') { - versionRange nextMajor - transform manifestFix - } -} - -jij.onConfiguration('modsDotGroovy') { - eachMatching('.+') { - path = 'mdg-dsl.jar' - includeMetadata = false - } -} - dependencies { minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" - project.ext.groovyLibs.each { - groovy groovyDep(it as String) + groovyLibs.each { + groovy groovyDep(it) } compileOnly sourceSets.extension.output + compileOnly 'com.matyrobbrt.enhancedgroovy:dsl:0.2.0' transformCompileOnly sourceSets.main.output @@ -119,7 +97,6 @@ dependencies { modCompileOnly sourceSets.main.output - compileOnly 'com.matyrobbrt.enhancedgroovy:dsl:0.2.0' include("org.groovymc.cgl:cgl-${cgl_mc_version}-forge:${cgl_version}") { jij.onDependency(it as Dependency) { versionRange nextMajor @@ -127,30 +104,30 @@ dependencies { } } -String groovyDep(final String name) { - return "${groovyId(name)}:${project.groovy_version}" -} - -static String groovyId(final String name) { - return "org.apache.groovy:groovy${name == 'stdlib' ? '' : '-' + name}" +private Map groovyDep(final String name) { + return [ + group: 'org.apache.groovy', + name: name == 'stdlib' ? 'groovy' : "groovy-$name", + version: project.groovy_version + ] } -tasks.register('makeReadme', Copy) { - final groovyLibsAsString = project.ext.groovyLibs.join(', ') - final expands = [ - 'groovyVersion': project.groovy_version, - 'groovyLibs' : groovyLibsAsString, - - 'gmlVersion' : '${gmlVersion}', // Thanks Gradle... - 'header' : '' - ] - it.inputs.properties expands +// Jars +// ---- +project.ext.manifestAttr = [ + 'Specification-Title' : 'GroovyModLoader', + 'Specification-Vendor' : 'GroovyMC', + 'Specification-Version' : 1, + 'Implementation-Title' : project.name, + 'Implementation-Version': project.version, + 'Implementation-Vendor' : 'GroovyMC', + 'BundledGroovyVersion' : project.groovy_version, + 'GitCommit' : getGitCommit(), + 'FMLModType' : 'LANGPROVIDER', + 'Built-on-Minecraft' : project.mc_version +] - it.from('templates/README.MD') { - expand expands - } - it.destinationDir(project.rootDir) -} +apply from: 'gradle/jars.gradle' tasks.register('groovyJar', ForgeJarInJarTask) { group('build') @@ -162,12 +139,13 @@ tasks.register('groovyJar', ForgeJarInJarTask) { ]) } -tasks.named('fullJar', ForgeJarInJarTask).configure { +tasks.register('fullJar', ForgeJarInJarTask) { from(sourceSets.main.output) from(sourceSets.transform.output) from(sourceSets.extension.output) manifest.attributes(manifestAttr + [ - 'Automatic-Module-Name': 'org.groovymc.gml', 'FMLModType': 'LANGPROVIDER' + 'Automatic-Module-Name': 'org.groovymc.gml', + 'FMLModType': 'LANGPROVIDER' ]) archiveClassifier.set('all') group('build') @@ -179,13 +157,14 @@ tasks.named('fullJar', ForgeJarInJarTask).configure { tasks.build.dependsOn(it) } + project(':script-mods').afterEvaluate { - rootProject.tasks.named('fullJar', ForgeJarInJarTask) { - fromJar(project(':script-mods').tasks.shadowJar as org.gradle.jvm.tasks.Jar) { versionRange nextMajor } + rootProject.tasks.named('fullJar', ForgeJarInJarTask).configure { + fromJar(project(':script-mods').tasks.shadowJar as Jar) { versionRange nextMajor } } } -tasks.named('jijtestJar', ForgeJarInJarTask).configure { +tasks.register('jijtestJar', ForgeJarInJarTask) { archiveBaseName.set('jijtest') fromJar(tasks.named('fullJar')) manifest.attributes([ @@ -195,8 +174,103 @@ tasks.named('jijtestJar', ForgeJarInJarTask).configure { ]) } -static String getGitCommit() { +jij.onConfiguration('groovy') { + final manifestFix = new ForgeManifestFixerTransformer(modType: 'LIBRARY', modulePrefix: 'org.groovymc.gml.groovyjij') + eachMatching('.+') { + versionRange nextMajor + transform manifestFix + } +} + +jij.onConfiguration('modsDotGroovy') { + eachMatching('.+') { + path = 'mdg-dsl.jar' + includeMetadata = false + } +} + +@CompileStatic +private static String getGitCommit() { final proc = 'git rev-parse --short HEAD'.execute() proc.waitFor() return proc.exitValue() ? "ERROR(${proc.exitValue()})" : proc.text.trim() } + +// Minecraft +// --------- +// Run configurations, mappings... +apply from: 'gradle/minecraft.gradle' + +// Misc +// ---- +tasks.withType(GroovyCompile).configureEach { + groovyOptions.encoding = 'UTF-8' + groovyOptions.optimizationOptions.indy = true + options.incremental = true +} + +tasks.register('makeReadme', Copy) { + final groovyLibsAsString = groovyLibs.join(', ') + final expands = [ + 'groovyVersion': project.groovy_version, + 'groovyLibs' : groovyLibsAsString, + + 'gmlVersion' : '${gmlVersion}', // Thanks Gradle... + 'header' : '' + ] + inputs.properties expands + + from('templates/README.MD') { + expand expands + } + destinationDir(project.rootDir) +} + +allprojects { + afterEvaluate { + license { + header = rootProject.file('license-header.txt') + exclude('**/mods.groovy') + } + } +} + +// Publishing +// ---------- +modrinth { + token = findProperty('modrinthToken') ?: System.getenv('MODRINTH_TOKEN') + projectId = project.modrinth_project + versionNumber = project.version + versionType = versionBasedReleaseType + uploadFile = tasks.fullJar + gameVersions = [mc_version] + loaders = ['forge'] + changelog.set(tasks.changelog.output.map { + it.asFile.text + }) +} +tasks.named('modrinth', TaskModrinthUpload).configure { + dependsOn(tasks.fullJar, tasks.changelog) +} + +tasks.register('publishCurseForge', TaskPublishCurseForge) { + apiToken = findProperty('curseforgeKey') ?: System.getenv('CURSEFORGE_TOKEN') + group = 'publishing' + disableVersionDetection() + + final projectId = findProperty('curseforge_project') + final modFile = upload(projectId, tasks.fullJar) + modFile.changelog = tasks.changelog.output.asFile.get() + modFile.releaseType = versionBasedReleaseType + modFile.displayName = "$archivesBaseName-$version" as String + modFile.addJavaVersion 'Java 17' + modFile.addModLoader 'Forge' + modFile.addGameVersion "$mc_version" + if (mc_version == '1.20') + modFile.addGameVersion '1.20.1' + + dependsOn(tasks.fullJar) + finalizedBy(':makeReadme') +} + +apply from: 'gradle/publishing.gradle' diff --git a/gradle.properties b/gradle.properties index 37b8d01..c5799ab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,7 @@ org.gradle.jvmargs=-Xmx2G -XX:+ParallelRefProcEnabled org.gradle.parallel=true org.gradle.daemon=false +org.gradle.caching=true org.gradle.console=verbose # Dependencies @@ -18,6 +19,6 @@ curseforge_project=661517 modrinth_project=zg2tT2Vu # Plugins -mdg_plugin_version=1.4.1 -cursegradle_version=1.0.11 -minotaur_version=2.7.5 +mdg_plugin_version=1.4.+ +cursegradle_version=1.1.15 +minotaur_version=2.8.1 diff --git a/gradle/compiler.gradle b/gradle/compiler.gradle deleted file mode 100644 index 4842048..0000000 --- a/gradle/compiler.gradle +++ /dev/null @@ -1,5 +0,0 @@ -tasks.withType(GroovyCompile).configureEach { GroovyCompile task -> - task.groovyOptions.fork = true - task.groovyOptions.encoding = 'UTF-8' - task.groovyOptions.optimizationOptions.indy = true -} \ No newline at end of file diff --git a/gradle/jars.gradle b/gradle/jars.gradle index b007898..b8ffb06 100644 --- a/gradle/jars.gradle +++ b/gradle/jars.gradle @@ -1,3 +1,7 @@ +/* + * Note: The JiJ-related jar tasks (such as groovyJar and fullJar) are in the main build.gradle file + */ + tasks.register('modJar', Jar) { from sourceSets.mod.output manifest.attributes(manifestAttr - ['FMLModType': 'LANGPROVIDER']) @@ -7,19 +11,19 @@ tasks.register('modJar', Jar) { tasks.named('jar', Jar).configure { from sourceSets.extension.output manifest.attributes(manifestAttr + [ - 'Automatic-Module-Name': 'org.groovymc.gml', 'FMLModType': 'LANGPROVIDER' + 'Automatic-Module-Name': 'org.groovymc.gml', + 'FMLModType': 'LANGPROVIDER' ]) } java.withSourcesJar() -groovydoc { +tasks.named('groovydoc', Groovydoc).configure { use = true source(sourceSets.transform.allSource) source(sourceSets.extension.allSource) } - tasks.register('groovydocJar', Jar) { - classifier 'javadoc' + archiveClassifier = 'javadoc' from groovydoc.destinationDir dependsOn(groovydoc) } @@ -34,7 +38,6 @@ tasks.register('transformJar', Jar) { archiveBaseName.set('transform') destinationDirectory.set(transformDest) } - tasks.register('transformSources', Jar) { from sourceSets.transform.allSource manifest.attributes(transformAttr) @@ -46,13 +49,13 @@ tasks.register('transformSources', Jar) { tasks.register('testJar', Jar) { group 'build' from sourceSets.test.output - classifier 'test' + archiveClassifier = 'test' manifest.attributes([ 'Specification-Title': 'GMLTestMod', 'Specification-Vendor': 'Matyrobbrt', 'Specification-Version': '1', 'Implementation-Title': 'GMLTestMod', - 'Implementation-Version': '1.0', - 'Implementation-Vendor': 'Matyrobbrt' + 'Implementation-Vendor': 'Matyrobbrt', + 'Implementation-Version': '1.0' ]) -} \ No newline at end of file +} diff --git a/gradle/mdg.gradle b/gradle/mdg.gradle deleted file mode 100644 index 0d3385a..0000000 --- a/gradle/mdg.gradle +++ /dev/null @@ -1,25 +0,0 @@ -import io.github.groovymc.modsdotgroovy.ConvertToTomlTask -import io.github.groovymc.modsdotgroovy.ModsDotGroovy - -buildscript { - repositories { - mavenCentral() - gradlePluginPortal() - } - dependencies { - classpath 'org.groovymc.modsdotgroovy:ModsDotGroovy:1.4.+' - } -} - -apply plugin: ModsDotGroovy - -modsDotGroovy { - dslVersion = '1.5.0' - automaticConfiguration = false -} -tasks.create('testModsDotGroovyToToml', ConvertToTomlTask) { - it.configureForSourceSet(sourceSets.test) -} -tasks.create('modModsDotGroovyToToml', ConvertToTomlTask) { - it.configureForSourceSet(sourceSets.mod) -} diff --git a/gradle/minecraft.gradle b/gradle/minecraft.gradle index 12a5b29..5d2af09 100644 --- a/gradle/minecraft.gradle +++ b/gradle/minecraft.gradle @@ -17,19 +17,19 @@ minecraft { dependencies { if ('runJijtest' in gradle.startParameter.taskNames) { runtimeOnly files( - tasks.named('jijtestJar').map { it.archiveFile.get().asFile } + tasks.named('jijtestJar', Jar).map { it.archiveFile.get().asFile } ) } else { runtimeOnly files( - tasks.named('fullJar').map { it.archiveFile.get().asFile } + tasks.named('fullJar', Jar).map { it.archiveFile.get().asFile } ) } } -tasks.whenTaskAdded { - if (it.name == 'runClient' || it.name == 'runServer') { - it.dependsOn(':fullJar') - } else if (it.name == 'runJijtest') { - it.dependsOn(':jijtestJar') +tasks.configureEach { + if (name == 'runClient' || name == 'runServer') { + dependsOn(':fullJar') + } else if (name == 'runJijtest') { + dependsOn(':jijtestJar') } -} \ No newline at end of file +} diff --git a/gradle/projectSetup.gradle b/gradle/projectSetup.gradle index 6483def..a9c24b2 100644 --- a/gradle/projectSetup.gradle +++ b/gradle/projectSetup.gradle @@ -44,4 +44,4 @@ sourceSets { sourceSets.each { sourceSet -> final javaDir = file("src/${sourceSet.name}/java/") javaDir.deleteDir() -} \ No newline at end of file +} diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 5f1ae49..4b428bc 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -2,59 +2,28 @@ import groovy.transform.CompileStatic import org.w3c.dom.Document import org.w3c.dom.Element -modrinth { - token = findProperty('modrinthToken') ?: System.getenv('MODRINTH_TOKEN') - projectId = project.modrinth_project - versionNumber = project.version - versionType = project.ext.versionBasedReleaseType - uploadFile = tasks.fullJar - gameVersions = [mc_version] - loaders = ['forge'] - changelog.set(tasks.changelog.output.map { - it.asFile.text - }) -} -tasks.named('modrinth') { - dependsOn(tasks.fullJar, tasks.changelog) -} - -publishCurseForge { - apiToken = findProperty('curseforgeKey') ?: System.getenv('CURSEFORGE_TOKEN') - group = 'publishing' - disableVersionDetection() - - final projectId = findProperty('curseforge_project') - final modFile = upload(projectId, tasks.fullJar) - modFile.changelog = tasks.changelog.output.asFile.get() - modFile.releaseType = project.ext.versionBasedReleaseType - modFile.displayName = "$archivesBaseName-$version" as String - modFile.addJavaVersion 'Java 17' - modFile.addModLoader 'Forge' - modFile.addGameVersion "$mc_version" - - dependsOn(tasks.fullJar) - finalizedBy(':makeReadme') -} +/* + * Note: The Modrinth and CurseForge publishing tasks have been moved + * to the main build.gradle file to allow for lazy configuration + */ publishing { publications { register('mavenJava', MavenPublication) { - it.artifacts = [ - jar, sourcesJar, fullJar, groovydocJar - ] it.artifactId = 'gml' - changelog.addArtifact(it) + it.artifacts = [jar, sourcesJar, fullJar, groovydocJar] + changelog.addArtifact(it) // add this MavenPublication containing the artifacts to SimpleCI's ChangelogTask pom { withXml { XmlProvider xml -> final element = xml.asElement() - var depsElem = element.getOwnerDocument().createElement('dependencies') - var owner = element.getOwnerDocument() + var depsElem = element.ownerDocument.createElement('dependencies') + var owner = element.ownerDocument var deps = (DependencySet) project.configurations.groovy.getDependencies() deps.each { depsElem.appendChild createDependency(owner, it.group, it.name, it.version, 'compile') } - depsElem.appendChild createDependency(owner, project.group, 'transform', project.version, 'compile') + depsElem.appendChild createDependency(owner, project.group as String, 'transform', (String) project.version as String, 'compile') element.appendChild(depsElem) } } @@ -62,11 +31,12 @@ publishing { register('transform', MavenPublication) { it.artifactId = 'transform' it.artifacts = [transformJar, transformSources] + pom { withXml { XmlProvider xml -> final element = xml.asElement() - var depsElem = element.getOwnerDocument().createElement('dependencies') - var owner = element.getOwnerDocument() + var depsElem = element.ownerDocument.createElement('dependencies') + var owner = element.ownerDocument var deps = (DependencySet) project.configurations.groovy.getDependencies() deps.each { depsElem.appendChild createDependency(owner, it.group, it.name, it.version, 'compile') @@ -89,7 +59,7 @@ publishing { } @CompileStatic -static Element createDependency(Document owner, String group, String name, String version, String scope) { +private static Element createDependency(Document owner, String group, String name, String version, String scope) { var sub = owner.createElement('dependency') var groupEl = owner.createElement('groupId') @@ -109,4 +79,4 @@ static Element createDependency(Document owner, String group, String name, Strin sub.appendChild scopeEl return sub -} \ No newline at end of file +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..c1962a7 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 8049c68..37aef8d 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-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..aeb74cb 100644 --- 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 diff --git a/gradlew.bat b/gradlew.bat index f127cfd..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/script-mods/build.gradle b/script-mods/build.gradle index c3cf59d..ce17160 100644 --- a/script-mods/build.gradle +++ b/script-mods/build.gradle @@ -1,8 +1,8 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { id 'java' - id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'com.github.johnrengelman.shadow' version '8.1.1' id 'org.cadixdev.licenser' version '0.6.1' } @@ -12,6 +12,7 @@ archivesBaseName = 'script-mods' repositories { mavenCentral() maven { + name = 'MinecraftForge' url = 'https://maven.minecraftforge.net' } maven { @@ -37,7 +38,7 @@ dependencies { exclude module: 'checker-compat-qual' exclude module: 'auto-service-annotation' } - implementation'com.google.jimfs:jimfs:1.2' + implementation 'com.google.jimfs:jimfs:1.2' } shadowJar { @@ -52,18 +53,16 @@ shadowJar { // } } -tasks.register('relocateShadowJar', ConfigureShadowRelocation) { - target = tasks.shadowJar - prefix = 'org.groovymc.gml.scriptmods.shadow' +tasks.named('shadowJar', ShadowJar) { + enableRelocation true + relocationPrefix 'org.groovymc.gml.scriptmods.shadow' } -tasks.shadowJar.dependsOn tasks.relocateShadowJar - -jar { +tasks.named('jar', Jar) { manifest.attributes([ 'Automatic-Module-Name': 'org.groovymc.gml.scriptmods', 'FMLModType': 'LIBRARY', 'Implementation-Name': 'GScriptMods', 'Implementation-Version': project.version ]) -} \ No newline at end of file +} diff --git a/settings.gradle b/settings.gradle index 4383f74..7b83d0a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,27 +1,28 @@ pluginManagement { repositories { + gradlePluginPortal() + mavenCentral() maven { name 'SpongePowered' url 'https://repo.spongepowered.org/repository/maven-public/' } maven { name 'MinecraftForge' - url 'https://maven.minecraftforge.net/' + url 'https://maven.minecraftforge.net' } maven { name 'ParchmentMC' url 'https://maven.parchmentmc.org' } - mavenCentral() - gradlePluginPortal() - } - resolutionStrategy { - eachPlugin { - if (requested.id.id == 'org.spongepowered.mixin') - useModule("org.spongepowered:mixingradle:${requested.version}") - } } } rootProject.name = 'GML' -include('script-mods') \ No newline at end of file + +buildCache { + remote(HttpBuildCache) { + url = 'https://gradlecache.groovymc.org/cache/' + } +} + +include('script-mods') diff --git a/templates/README.MD b/templates/README.MD index ff47cad..79d2c91 100644 --- a/templates/README.MD +++ b/templates/README.MD @@ -69,9 +69,28 @@ The major GML version is bumped every MC version. Below you can find a list of M - `1.19.3` -> `2.x.x` - `1.19.4` -> `3.x.x` - `1.20.0` -> `4.x.x` + **NOTE**: 1.19.2 - 1.19.4 versions use the `com.matyrobbrt.gml` artifact group. ## Shading GML While we would appreciate if you instead had a dependency on GML on [CurseForge](https://www.curseforge.com/minecraft/mc-mods/gml) in order provide us revenue, we understand that in some cases, you may not want to depend on another mod. Fortunately, we _are_ JiJ-able. If you want to JiJ GML, just follow the guide [here](https://forge.gemwire.uk/wiki/Jar-in-Jar) but replace GSON with the `all` version of GML (the `runtimeOnly` one). + +## Contributing +We welcome contributions to GML. If you want to contribute, please open a PR with your changes. + +### Troubleshooting + +#### Unable to build +Make sure to include the Git tags when forking, as they are used to determine the version of GML and the build will fail if they are not present: +```shell +git fetch --tags upstream +git push --tags +``` + +#### GML not showing up in-game when running in IDE +Developing GML requires you to use the Gradle run tasks to test your changes rather than the IDE run configurations, for example, use `./gradlew runClient` instead of the IntelliJ `runClient` run configuration. + +#### Updating the README +Remember to run the `makeReadme` task when updating the README template or Groovy version, otherwise the README will be outdated.