I am using the Universal plugin of the sbt-native-packager to create a zip package. I am using the below setting for creating a default structure:
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.4")
enablePlugins(JavaAppPackaging)
Currently all my project dependencies in the zip fall under the lib folder e.g.
lib/
ch.qos.logback.logback-classic-1.1.3.jar
dom4j.dom4j-1.6.1.jar
How do I change the name of all the libraries to contain only the artifactId and version of the jar and not the complete name. For example, for the above, I want something like this:
lib/
logback-classic-1.1.3.jar
dom4j-1.6.1.jar
The logic for this is hard coded in the JavaAppPackaging archetype. However you can remap your library dependencies.
mappings in Universal := (mappings in Universal).value.map {
case (file, dest) if dest.startsWith("lib/") =>
file -> changeDestination(dest)
case mapping => mapping
}
def changeDestination(dest: String): String = ???
Next you need to change the scriptClasspathOrdering which is responsible for the app_classpath defined in the BashStartScriptPlugin.
scriptClasspathOrdering := scriptClasspathOrdering.value.map {
case (file, dest) if dest.startsWith("lib/") =>
file -> changeDestination(dest)
case mapping => mapping
}
The destination folder should be lib/ as the bash script assumes this.
Note that I have not tested this as this is a very uncommon use case. However the main idea should be clear :)
cheers, Muki
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With