I have a multiple project build with flat paths, e.g.:
settings.gradle:
includeFlat 'projA','projB','projC'
There are about 20 different sub-projects with all sorts of different interdependencies. I'd like gradle to handle the dependencies but I don't want to tie the entire project together as a monolith, I want to keep these as individual uploads which go into our artifact repository (Nexus) with their individual sub-project versioning. Each sub-project has its group specified in the gradle.properties
file.
The problem is, if I call out the dependencies via the compile dependency, i.e.:
projA-build.gradle:
compile project(":projB")
Then everything compiles and the artifacts are uploaded just fine but at runtime I get an error such as:
Could not resolve all dependencies for configuration ':runtime'.
Could not find master:restclient:4.0-SNAPSHOT.
The upload is in the master
build.gradle
file. The relevant portion of the build script:
subprojects {
afterEvaluate { Project proj ->
def is_snap = false
def reltype = "releases"
def artifact_name = sprintf("%s-%s.jar"
,project['name']
,project['version'])
def nexus_release_path = sprintf("%s/nexus/content/repositories/releases/%s/%s/%s/%s"
,project['nexus_url']
,project['groupId'].replaceAll("\\.","/")
,project['name']
,project['version']
,artifact_name
)
if(project.version.contains("SNAPSHOT")){
reltype = "snapshots"
is_snap = true
}
uploadArchives {
// only try the upload if it's not already there
onlyIf {
try {
def artifact_exists = new URL(nexus_release_path).bytes
// if we get here then the artifact existed and we only want to
// build if this is a snapshot version
is_snap || false
} catch (FileNotFoundException e) {
// this means we couldn't find the artifact in nexus
if(!is_snap){
println "NOTE ==> Don't forget to create new git tag for $artifact_name!"
}
true
}
}
repositories {
mavenDeployer {
repository(url: "${project.nexus_url}/nexus/content/repositories/$reltype") {
authentication(userName: project.nexus_user, password: project.nexus_password)
}
pom.version = "${project['version']}"
pom.artifactId = "${project.name}"
pom.groupId = "${groupId}"
}
}
}
...
}
Though it's uploaded to Nexus correctly somehow the dependency is built in with that "master" in the artifact coordinates.
Am I going about this the wrong way or have the wrong expectations?