We have a multiple modules in our Java project and each module publishes SNAPSHOT jar files to Nexus repository. All the sub-modules are directly dependent on the SNAPSHOT jar files.
During development, we want to depend on the Eclipse project rather than SNAPSHOT jars. So we introduced a flag which switches between the dependencies as shown below.
I’m wondering how do you guarantee that every time the project is built, all modules depend on the just built artifacts instead of the SNAPSHOT ones available on your Nexus repository?
I am not sure whether I understood your question correctly.
Gradle build running on our CI server (Jenkins) will depend only on the SNAPSHOT builds for the dependent projects as we don’t use any flags while building the projects.
We are using the “-DsetupProject=true” flag ONLY for the “gradle eclipse” task. This helps developers not to worry about snapshots.
I assume you are talking about a multiproject build, so ‘:Module1’ and ‘:Module2’ are subprojects. My question was - if let’s say Module1 depends on Module2 using an external module dependency rather than a project dependency:
Then isn’t it possible that if you build all modules (from the root project) using ‘gradle clean build’ - ‘:Module1’ could be built against the latest available ‘com.test:module2:0.1-SNAPSHOT’ on your Nexus repository (which could be some outdated version uploaded yesterday), rather than the ‘:Module2’ being built by this same build?