0

When at the sbt CLI I can just type package and everything works fine - two jar files are produced. But I want to make package a dependency of a new task I am creating, so I want to make packaging happen as part of the build script. This is what I have:

lazy val deployTask = TaskKey[Unit]("deploy")
deployTask := { println("deploy happening now!") }

deployTask := {
    (deployTask.in(file("."))).value
    (Keys.`package` in Compile).value
}

My reading of the documentation tells me that Compile really means file("src/main/scala"), which is not what I want. It seems that I have to put in <Something>. What do I need to put in instead of <Something> to get package to mean what it means when I type it at the CLI?

At the CLI I should be able to:

clean
show deploy

, but unfortunately it does not do the packaging I expect.

These are the projects:

projects
[info] In file:/C:/dev/v2/atmosphere/
[info] atmosphereJS
[info] atmosphereJVM
[info] * root

So it makes sense that when I run package from the CLI the root project is used. So another way of asking this question might be: "How do I make package work for root from the deploy task I am creating?"

Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
  • I sequenced the package task after the deploy task just for this example because I want deploy to be returning something that can be shown. In reality I want to make deploy copy the packaged jar files, so I will be switching the order once this issue has been resolved. – Chris Murphy Jun 27 '15 at 05:53
  • Also by way of context to my saying 'I don't want src/main/scala'. Instead I want js/src/main/scala and jvm/src/main/scala. This is a Scala.js setup. – Chris Murphy Jun 27 '15 at 06:36
  • I do not fully understand what you are trying to do. But in general, you would want to package JS and JVM compiled Scala code separately. You can reference the individual package tasks like this: `package in atmosphereJS in Compile`. – gzm0 Jul 11 '15 at 00:46
  • I just want to type `package` and for 'something extra' to happen. Alternatively type `deploy` and for `package` and 'something extra' to happen. I want to copy the produced jar file to another place - that's the 'something extra'. – Chris Murphy Jul 11 '15 at 07:02
  • 1
    If you need the package to be put elsewhere, you can just set `artifactPath in packageBin in atmosphereJS in Compile := file("foo/bar.jar")`. – gzm0 Jul 13 '15 at 20:48
  • Thanks @gzm0. I don't need to do this anymore as deployment (copying jar files) can easily be done from a shell script that is called as part of launching the application. The problem with my initial approach was that I was copying the jar files into a potentially running web server. Better to pull the jar files into their correct places at launch time rather than push them out at package time. – Chris Murphy Jul 14 '15 at 03:14

0 Answers0