Creating a dependency on a system test module


(Steven Blundy) #1

I’ve got a multi-module project that produces two WARs and I’d like to have an integration/system test module that makes sure they play well together. The test module wouldn’t actual produce an artifact, but I would like my assembly module to be dependent upon its successful execution.

My project looks something like this:

  • Parent

  • War One

  • War Two

  • Integration Test

  • Assembly

How do I make a module dependent upon another module when the dependency doesn’t produce an artifact?

I’ve attempted the following in ‘:assembly’

configurations {
    assembly
}
  dependencies {
    assembly module(':test')
}
  task build(dependsOn: configurations.assembly) << {
    println("in assembly:build")
}

But the :assembly:build is being executed before :test.


(Peter Niederwieser) #2

In Gradle this is called a multi-project build, and hence it’s also ‘project(":test")’. Also, artifact dependencies (as specified in the ‘dependencies’ block) and execution dependencies are two different things, and execution dependencies are always between tasks, not between projects. Long story short, you probably want a task dependency from the assemble task to the test task (which resides in another project). Something like ‘assemble.dependsOn(":test:test")’. Another option is to omit this task dependency and just run ‘gradle test assemble’ (in that order).


(Steven Blundy) #3

Works. Thanks!