When specifying Gradle project dependencies, can I avoid using a full absolute project name and use a relative one instead? (i.e. in my example I don’t want to explicitly specify :app-a when referencing :domain-a)
//Directory structure
app-a/
domain-a/
build.gradle
webapp-a/
build.gradle
WebApp-A build.gradle:
apply plugin: 'java'
//Build.gradle for webapp-a
dependencies {
// Works
compile project(':app-a:domain-a')
//Doesn't work
compile project(projectDir.path + '/../domain-a/')
//Doesn't work
compile findProject('../domain-a')
//Doesn't work
compile project(':domain-a')
}
Relative names are a bad idea since they make your project depend on the wider project it is located in. That should not be the case. I suggest to avoid using the relative name.
In terms of retrieving the parent project as a dependency this would be done via the default being the parent directory or that failing it would use the usual dependency resolution mechanism, which uses the coordinates (groupId, artifactId and version) and looks the artifact up in the local repository..