I am trying to pass command line arguments to my JAR created with sbt-assembly
. Neither of these -Dconfig.file=application.conf
nor -Dconfig.trace=loads
My exact command is
java -jar googleScraper-assembly-0.0.1.jar -Dconfig.trace=loads -Dconfig.resource=application.conf
This is my build.sbt
lazy val googleScraper = project.in(file("google-data-scraper"))
.settings(commonSettings:_*)
.settings(
version := "0.0.1",
assemblyMergeStrategy in assembly := {
case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
case "log4j.properties" => MergeStrategy.discard
case m if m.toLowerCase.startsWith("meta-inf/services/") => MergeStrategy.filterDistinctLines
case "reference.conf" => MergeStrategy.concat
case "application.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
},
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.3.0",
"com.typesafe.play" % "play_2.11" % "2.3.9",
"com.typesafe.play" % "play-ws_2.11" % "2.3.9",
"com.ning" % "async-http-client" % "1.8.15"
),
fork in run := true
)
.dependsOn("util")
.dependsOn("core")
Edit
So turns out that putting the argument before the -jar makes a different. This now works:
java -Dconfig.trace=loads -Dconfig.resource=blah.conf -jar googleScraper-assembly-0.0.1.jar
but it now the loading indicates that the app is trying to load the new config from within the JAR. How can I make it load it completely externally (absolute path didn't work)?
The sbt-assembly plugin is an SBT plugin for building a single independent fat JAR file with all dependencies included. This is inspired by the popular Maven assembly plugin, which is used to build fat JARs in Maven.
(extracting answer from the comments)
JVM options such as -D must come before -jar
config.file is an external file and config.resource is a resource on the classpath.
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