Using sbt, I'd like to copy some dependency jars to a lib
output folder. If possible, I'd like to use the %provided%
keyword, like I can with sbt-assembly.
So given a build.sbt
somewhat similar to the following, how do create a task that copies the ark-tweet-nlp
but NOt the spark-core
dependencies to target/scala-%ver%/lib
?
retrieveManaged := true
simply copies everything, which is not what I want.
...
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.0.0" % "provided"
libraryDependencies += "edu.cmu.cs" % "ark-tweet-nlp" % "0.3.2"
retrieveManaged := true
...
You could write a task like this.
build.sbt
val retrieveNotProvided = taskKey[Unit]("Copies non provided and non internal dependencies")
def isInternalOrProvided(conf: String) = conf.contains("-internal") || conf == "provided"
retrieveNotProvided := {
val toCopy = new collection.mutable.HashSet[(File, File)]
val pattern = retrievePattern.value
val output = managedDirectory.value
update.value.retrieve { (conf, mid, art, cached) =>
import org.apache.ivy.core.IvyPatternHelper
val fileName = IvyPatternHelper.substitute(
pattern, mid.organization, mid.name, mid.revision, art.name, art.`type`, art.extension, conf
)
if (!isInternalOrProvided(conf)) toCopy += (cached -> output / fileName)
cached
}
IO.copy(toCopy)
}
You'll have to remove retrieveManaged := true
from your build.sbt
, because otherwise sbt will trigger the original retrieve function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.