compile separate combined API jar

This commit is contained in:
James Seibel
2026-04-18 15:47:23 -05:00
parent 0ef11caaf2
commit 95c4459d8a
+21 -8
View File
@@ -27,12 +27,13 @@ java {
withSourcesJar() withSourcesJar()
} }
task addSourcesToCompiledJar(type: ShadowJar) { task createReleaseApiJar(type: ShadowJar) {
mustRunAfter sourcesJar mustRunAfter sourcesJar
dependsOn shadowJar
// the compiled "-all" jar is used since it's available at the time this task is run // the compiled "-all" jar is used since it's available at the time this task is run
def compiledJarPath = "build/libs/api-api-${rootProject.versionStr}-all.jar" def compiledJarPath = "build/libs/DistantHorizonsApi-${rootProject.api_version}-all.jar"
def compiledJarFile = file(compiledJarPath) def compiledJarFile = file(compiledJarPath)
// doFirst is so these only run when the task is actually executed // doFirst is so these only run when the task is actually executed
@@ -47,11 +48,8 @@ task addSourcesToCompiledJar(type: ShadowJar) {
} }
} }
// Set the name of the combined JAR file archiveFileName.set("DistantHorizonsApi-${rootProject.api_version}-combined.jar") // jar name
archiveFileName.set("DistantHorizonsApi-${rootProject.api_version}.jar") destinationDirectory = file('build/libs/') // jar location
// Set the destination directory for the combined JAR file
destinationDirectory = file('build/libs/')
// Set the input JAR files to be combined // Set the input JAR files to be combined
from sourceSets.main.allJava from sourceSets.main.allJava
@@ -94,11 +92,12 @@ task addSourcesToCompiledJar(type: ShadowJar) {
} }
} }
// always create a combined jar for easy deployment
assemble.dependsOn(createReleaseApiJar)
shadowJar { shadowJar {
// required for basic shadowJar setup // required for basic shadowJar setup
configurations = [project.configurations.shadow] configurations = [project.configurations.shadow]
finalizedBy(addSourcesToCompiledJar)
} }
javadoc { javadoc {
@@ -110,3 +109,17 @@ javadoc {
addStringOption('Xdoclint:all,-missing', '-quiet') addStringOption('Xdoclint:all,-missing', '-quiet')
} }
} }
// set the jar name
def configureJar = { task ->
// outputs in the format:
// "DistantHorizonsApi-6.0.0.jar"
// "DistantHorizonsApi-6.0.0-sources.jar"
task.archiveBaseName = rootProject.api_name
task.archiveVersion = rootProject.api_version
}
configureJar(tasks.named("jar").get())
configureJar(tasks.named("sourcesJar").get())
configureJar(tasks.named("shadowJar").get())