Dependencies from build project to code


(Dan Gravell) #1

I’m probably going about this in the wrong way, so do educate me…

I have the following projects in a flat multi project build:

master  (root project)
build (is a distribution project)
code  (Java project)

The build project is where all the distribution stuff occurs - OS X app built, Launch4j EXE built and signed, RPMs built, etc etc.

How do I configure build such that a change to code will mean it is rebuilt when I run installDist in build?

At the moment, I have to explicitly build the code project first, then call installDist.

The reason this happens is that the libs etc are brought in using the project API and grabbing the runtime configuration for code. It’s important that build does not have a compile dependency on code because to do so screws up the operation of the various distribution tasks.

For example, in build’s build.gradle:

configurations {
    code
}

dependencies {
    code project(":code")
}

distributions {
    main {
        contents {
            from(configurations.code.files) {
            	into "lib"
            }
    }
}

(Stefan Oehme) #2

configurations.code.files resolves at configuration time, which is causing your trouble. Just do configurations.code instead.


(Dan Gravell) #3

Easy as that - thanks!