Question

In my SBT build, I'm fetching a zip dependency (previously built with the sbt-native-packager plugin), published in my local Ivy repo with a bundle classifier.

But I need the dependency path in the Ivy repo, in order to unzip it (with IO.unzip), put some files in it and repackage it with sbt-native-packager.

I'm using the artifacts(...) method to find the artifact and add it as a dependency :

"foo" % "bar" % "1.0-SNAPSHOT" artifacts(Artifact("bar-bundle", "zip", "zip", "bundle"))

But after that, I'm a bit lost...

I tried to filter out the dependencyClasspath to find it :

val bundleFile = taskKey[File]("bundle's path")

val settings = Seq(bundleFile <<= dependencyClasspath map { _ filter (_.endsWith(".zip"))})

Trouble is : I can't find the zip dependency in any classpath... What I'm doing wrong ?

I'm using sbt 0.13.

Was it helpful?

Solution

Zip files aren't on the classpath by default. The types of artifacts that are included are configured by classpathTypes. You can add "zip" to it with:

classpathTypes += "zip"

It will then appear on dependencyClasspath.

However, if it isn't really supposed to go on the classpath, you might pull it out of the update report directly.

bundleFile := {
   val report: UpdateReport = update.value
   val filter = artifactFilter(name = "bar-bundle", extension = "zip")
   val all: Seq[File] = report.matching(filter)
   all.headOption getOrElse error("Could not find bar-bundle")
}

See the documentation on UpdateReport for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top