Skip to content

Instantly share code, notes, and snippets.

@vlsi
Last active October 7, 2020 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlsi/f676b5ea830b82a64c8eaf3ea6c92a3b to your computer and use it in GitHub Desktop.
Save vlsi/f676b5ea830b82a64c8eaf3ea6c92a3b to your computer and use it in GitHub Desktop.
Add Class-Path attribute to a jar manifest in Gradle
// Add Class-Path to the existing "jar" task
tasks.jar {
val classpath = configurations.runtimeClasspath
// Input declaration is needed for the proper up-to-date checks
inputs.files(classpath).withNormalizer(ClasspathNormalizer::class.java)
manifest {
attributes(
"Class-Path" to classpath.map { cp -> cp.joinToString(" ") { it.absolutePath } }
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment