Get reference to jar assembly path in sbt -
i'm using sbt-izpack build installer. looks there's bug variable package file name isn't being referenced properly. i'm looking pass in variable main jar packaged so:
variables in izpack += ("artifactname", artifactfilename.value )
the thing can't figure out how path string of main artifact. docs can map on package , (artifact, file)
pair so:
val artifactfilename = settingkey[string]("my task.") artifactfilename := { val (art, file) = packagedartifact.in(compile, packagebin).value println("artifact definition: " + art) println("packaged file: " + file.getabsolutepath) file.getabsolutepath }
but sbt complains a setting cannot depend on task
.
is there way can somehow path of main assembly without needing generate first (in task) can pass in via setting?
alternatively, there someway update setting supplied izpack in task?
it looks answer in documentation, it's not obvious because it's in section modifying artifacts, not reading properties.
from: http://www.scala-sbt.org/0.12.2/docs/detailed-topics/artifacts.html#modifying-default-artifacts:
each built-in artifact has several configurable settings in addition publish-artifact. basic ones
artifact
(of typesettingkey[artifact]
),mappings
(of typetaskkey[(file,string)]
), ,artifactpath
(of typesettingkey[file]
). scoped (<config>
,<task>
) indicated in previous section.
so can string value of artifactpath, setting , thereby usable in izpack setting, following:
lazy val artifactpathext = settingkey[string]("get main artifact path") artifactpathext := (artifactpath in (compile, packagebin)).value.getpath
while forget how happened across this, here's how 1 might discover information (discoverability in sbt being of problem):
one knows package
task builds main output, can type:
inspect tree package
at sbt prompt, displays following tree:
> inspect tree package [info] compile:package = task[java.io.file] [info] +-compile:packagebin = task[java.io.file] [info] +-compile:packagebin::packageconfiguration = task[sbt.package$conf.. [info] | +-compile:packagebin::artifactpath = target\scala-2.11\scaladaem.. [info] | | +-*:scalabinaryversion = 2.11 [info] | | +-*:scalaversion = 2.11.5
here can see package
task requires compile:packagebin::packageconfiguration
. can inspect value of setting @ sbt prompt.
to grab hold of value in build, you'd have know how reference thing. you'd have figure out keys, tasks , scopes. you'd have know "in" syntax of getting keys out of configs , tasks. finally, you'd have know how declare , use custom tasks , how settings , tasks referenced , declared @ runtime. finally, you'd have know how use setting set setting.
whew.
Comments
Post a Comment