JarJar Artifact Jar

- Use JarJar
  - Include Flywheel automatically
  - Include Registrate instead of shading it
- Refactor Maven coordinate scheme
  - Artifact ID: "Create" -> "create-{minecraft_version}"
  - Artifact Version: "{mod_version}.{patch}-{build_number}"
- Exclude datagen cache from built jars
- Include LICENSE file in build jars
- Sync mods.toml version with gradle.properties version
- Use more modern publication code
- Update Gradle: 7.4.1 -> 7.4.2
This commit is contained in:
PepperCode1 2022-07-14 15:02:24 -07:00
parent 0161b876fa
commit 4c45333687
4 changed files with 59 additions and 53 deletions

View file

@ -12,8 +12,8 @@ buildscript {
classpath "org.parchmentmc:librarian:${librarian_version}"
}
}
plugins {
id 'com.github.johnrengelman.shadow' version "${shadow_version}"
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
}
apply plugin: 'net.minecraftforge.gradle'
@ -22,17 +22,18 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
jarJar.enable()
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false');
// jozu: I use a gradle workspace with both projects.
// The project is named Flywheel-Forge, but sub-projects are named by folder.
boolean inWorkspace = findProject(':Flywheel') != null
ext.buildNumber = System.getenv('BUILD_NUMBER')
if (buildNumber == null) buildNumber = 'custom'
version = "mc${minecraft_version}_v${mod_version}" + (dev && !buildNumber.equals('custom') ? "+${buildNumber}" : '')
group = 'com.simibubi.create'
archivesBaseName = 'create'
archivesBaseName = "create-${artifact_minecraft_version}"
version = mod_version + (dev && buildNumber != null ? "-${buildNumber}" : '')
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
@ -92,18 +93,6 @@ minecraft {
}
}
compileJava {
options.compilerArgs = ['-Xdiags:verbose']
}
sourceSets.main.resources {
srcDir 'src/generated/resources'
}
mixin {
add sourceSets.main, 'create.refmap.json'
}
repositories {
maven {
// Location of the maven that hosts JEI files (and TiC)
@ -141,16 +130,17 @@ repositories {
}
}
configurations {
shade
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
def registrate = "com.tterrag.registrate:Registrate:${registrate_version}"
implementation fg.deobf(registrate)
shade registrate
jarJar(group: 'com.tterrag.registrate', name: 'Registrate', version: '[MC1.18.2-1.1.3]') {
jarJar.pin(it, project.registrate_version)
}
jarJar(group: 'com.jozufozu.flywheel', name: 'Flywheel-Forge', version: '[1.18-0.6.4,1.18-0.6.5)') {
jarJar.pin(it, project.flywheel_version)
}
implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}")
if (inWorkspace) {
implementation project(':Flywheel')
@ -179,6 +169,31 @@ dependencies {
}
}
processResources {
inputs.property 'version', mod_version
filesMatching('META-INF/mods.toml') {
expand 'version': mod_version
}
}
sourceSets.main.resources {
srcDir 'src/generated/resources'
exclude '.cache/'
}
mixin {
add sourceSets.main, 'create.refmap.json'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
compileJava {
options.compilerArgs = ['-Xdiags:verbose']
}
jar {
classifier = 'slim'
manifest {
@ -187,7 +202,7 @@ jar {
'Specification-Vendor': 'simibubi',
'Specification-Version': '1',
'Implementation-Title': project.name,
'Implementation-Version': "${version}",
'Implementation-Version': project.jar.archiveVersion,
'Implementation-Vendor': 'simibubi',
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'MixinConfigs': 'create.mixins.json'
@ -195,40 +210,30 @@ jar {
}
}
shadowJar {
classifier = ''
configurations = [project.configurations.shade]
relocate 'com.tterrag.registrate', 'com.simibubi.create.repack.registrate'
java {
withSourcesJar()
withJavadocJar()
}
reobf {
shadowJar {}
void addLicense(jarTask) {
jarTask.from('LICENSE') {
rename { "${it}_${project.archivesBaseName}" }
}
}
jar.finalizedBy('reobfJar')
tasks.jarJar.finalizedBy('reobfJarJar')
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveBaseName.set(project.archivesBaseName)
archiveVersion.set("${project.version}")
archiveClassifier.set('sources')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
archiveClassifier.set('javadoc')
}
artifacts {
archives jar, shadowJar, sourcesJar, javadocJar
}
addLicense(jar)
addLicense(tasks.jarJar)
publishing {
tasks.publish.dependsOn 'build'
publications {
mavenJava(MavenPublication) {
artifact shadowJar
artifact sourcesJar
artifact javadocJar
artifactId = archivesBaseName
from components.java
jarJar.component(it)
}
}

View file

@ -4,7 +4,9 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
# mod version info
mod_version = 0.5.0c
mod_version = 0.5.0.c
artifact_minecraft_version = 1.18.2
minecraft_version = 1.18.2
forge_version = 40.1.60
@ -13,7 +15,6 @@ forgegradle_version = 5.1.+
mixingradle_version = 0.7-SNAPSHOT
mixin_version = 0.8.5
librarian_version = 1.+
shadow_version = 7.1.0
cursegradle_version = 1.4.0
parchment_version = 2022.07.10

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -5,7 +5,7 @@ license="MIT"
[[mods]]
modId="create"
version="0.5.0c"
version="${version}"
displayName="Create"
#updateJSONURL=""
displayURL="https://www.curseforge.com/minecraft/mc-mods/create"