I have a project performing integration tests for a bunch of projects which are all bundled in the same multi-project build with it. The integration tests run through a regular main (object Runner extends App
).
I wish being able to run it from the root project of the multi-project build through a task or command named integrationTest
, so I try:
val integrationTest = taskKey[Unit]("Executes integration tests.")
lazy val root = (project in file(".")).aggregate(projIntegrationTest, projA, projB, ...).settings(
integrationTest := (run in Compile in projIntegrationTest).value
)
Which does nothing when I issue integrationTest
on the prompt, only emitting:
[success] Total time: 0 s, completed Oct 23, 2015 12:31:21 AM
How may I approach finding out why does it not get run when my custom task integrationTest
runs?
Oddly, replacing run
with compile
or publishlocal
in integrationTest := (run in Compile in projIntegrationTest).value
above, my custom task line acts as expected and takes care of compiling or publishing when the custom task is executed.
When I add a subproject to a master project, it always becomes a part of the project just above it. It is indented one more level. Must I only create subprojects on the top row of the project?
Use Subprojects ( index ), where index is the subproject index or project summary task name, to return a single Subproject object. The following example prevents changes made to the specified subproject in a master project from being automatically made to the source project. Use the Subprojects property to return a Subprojects collection.
You can try this by making a copy of one of the subprojects in your project, placing it into another folder, and then adding it to your project again. Subprojects will not report the new project, or provide information about any subprojects that are added to that project afterwards.
In the master project, subprojects appear as summary tasks that you can easily arrange in an outline. Click the plus sign next to a subproject to expand that subproject's tasks for viewing. Each subproject represents a different phase or other functional group in the main project.
It doesn't work because run
is an InputTask
, not a regular Task
.
You need to do:
integrationTest :=
(run in Compile in projIntegrationTest)
.toTask("").value
this is covered in the "Get a Task from an InputTask" section of http://www.scala-sbt.org/0.13/docs/Input-Tasks.html.
As of sbt 0.13.13 your code gives:
warning: `value` is deprecated for an input task. Use `evaluated` or `inputTaskValue`.
This is a nice improvement; earlier versions of sbt let this pass, making it hard to troubleshoot. (But note that the deprecation message suggests a different solution than I've used here; I haven't investigated that discrepancy. Can someone shed some light on that?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With