Quick Question: Are there such things as Project Assembly Dependencies in Gradle?


Are there such things as Project Assembly Dependencies in Gradle?

PS: I already know that there are Project Library Dependencies: https://docs.gradle.org/current/userguide/multi_project_builds.html

I’m not certain what you mean here by “project assembly dependency”. Do you mean a dependency to something other than the project’s JAR?

Hi Mark

Today is a new day. I think that I am probably asking the wrong question.

Execute gradle assemble and then Gradle does not run the unit tests or tests in a module.
Execute gradle build and then Gradle does execute assemble and also run tests in a module.
In Maven, the final artifact, be it JAR, WAR or EAR is only build after running the tests. This is not the case for Gradle, the artifacts are built first and then tests are ran.

So I wonder if there was such thing as the following:

subprojects {
    apply plugin: 'java'
    group = 'org.gradle.sample'
    version = '1.0'
    repositories {
    dependencies {
        testCompile "junit:junit:4.12"

project(':api') {
    dependencies {
        **build** project(':shared')

project(':services:personService') {
    dependencies {
        **build** project(':shared'), project(':api')

The personService' is only build, if the dependent JARs ofsharedandapi` are built and the their tests, if any, have run to completion.

Maybe the proper question should have been: is it possible to execute the tests before the JAR, WAR and EAR are built in a Gradle project?

You can run gradle :services:personService:buildNeeded which will do exactly that. It will “build” the projects it depends on, which includes running tests.