Skip to content

Instantly share code, notes, and snippets.

@Xalcon
Last active June 23, 2017 14:54
Show Gist options
  • Save Xalcon/62e610f7f913d918f89132caa8fac62a to your computer and use it in GitHub Desktop.
Save Xalcon/62e610f7f913d918f89132caa8fac62a to your computer and use it in GitHub Desktop.
experimental code that moves the "api" subpackage into its own jar which then gets re-packaged with a jar that doesnt have said sub-package. Output is a jar with the qualifier "universal". This concept can be adapted to pacakage a Coremod-only jar into the mainmod.jar to comply to the new forge coremod policy.
// at the end of your build.gradle
// Create API library zip
// Warning: This jar will be reobfuscated! Its only used to package it with the universal jar
task apiJar(type: Jar) {
from(sourceSets.main.output) {
include "**/api/**"
}
classifier = 'obf-api'
includeEmptyDirs = false
}
// task to create a jar containing all classes from the main sourceSet output and the api.jar
// also sets up the manifest attribute 'ContainedDeps' which fml uses to extract the api jar at runtime
task packedJar(type: Jar, dependsOn: 'reobfApiJar') {
manifest {
attributes 'FMLAT': "${modid}_at.cfg"
attributes 'ContainedDeps': "${archivesBaseName}-${version}-api.jar"
}
from(sourceSets.main.output) {
exclude('**/api/**')
}
from("${buildDir}/libs") {
include("*-${version}-api.jar")
}
classifier = 'universal'
}
// tell gradle to reobfuscate our jars
reobf {
// jar is done by default
// jar { }
apiJar { }
packedJar { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment