Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
246 changes: 160 additions & 86 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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',
Expand All @@ -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 {
Expand All @@ -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

Expand All @@ -119,38 +97,37 @@ 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
}
}
}

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<String, String> 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' : '<!-- This file is automatically generated, make any modifications to it in the `templates/README.MD` file, and then run the `makeReadme` Gradle task -->'
]
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')
Expand All @@ -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')
Expand All @@ -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([
Expand All @@ -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' : '<!-- This file is automatically generated, make any modifications to it in the `templates/README.MD` file, and then run the `makeReadme` Gradle task -->'
]
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'
Loading