Running Wget in scala build.sbt -


i have requirement need download bunch of jars url , place them inside lib directory , add them unmanaged dependancy.

i kind of stuck on how in build.sbt. went on sbt documentation , found processbuilder. in mind, came below code.

for(i <- jarurls) {   val wget = s"wget -p $libdir $anonuser@$hgrooturl/$i"   wget ! } 

this runs wget on bunch of jars , places file in mentioned folder. pretty simple code, unable run this. error "expression of type unit must confirm dslentry in sbt file".

how accomplish this?

build.sbt isn't scala file, sbt special preprocessing on (that's why don't have def project = etc).

your problem happens because every line of code (except imports , definitions) in build.sbt must return expression of type dslentry sbt sees every line of code setting. when want wget executed? usual way define task:

lazy val wget = taskkey[unit]("wget")  wget := {   for(i <- list(1,2,3)) {     val wget = s"wget -p $libdir $anonuser@$hgrooturl/$i"     wget !   }   () } 

and run sbt wget.

you can make wget task dependent on other task (or can think of them events) in sbt.

see http://www.scala-sbt.org/0.13/docs/tasks.html

of course, there tricky unsafe ways, like:

val init: unit = {    //any code want here } 

but wouldn't recommend since want files during let's compile stage or something:

wget := {   code here } dependson compile 

you can use regular scala build instead of build.sbt: http://www.scala-sbt.org/0.13/docs/full-def.html


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -