I’m a new user but not really a new user. I lost the old password and email and had to create a new account.
Anyway, given I’ve the following projects:
parent
--- common
--- child1 (depends on common)
unrelated (depends on common)
When both parent and unrelated are Maven projects and opened in the same IDE workspace (I verified in IDEA but I’m told that Eclipse behavior is the same), I can navigate from unrelated to common without having to link sources. Refactoring anything in common correctly finds references of it in unrelated. Since Maven doesn’t differentiate between submodule and lib dependencies, both dependencies shown above are declared in the same manner.
With Gradle, unrelated doesn’t seem to know that common exists in the same workspace. Refactoring anything in common breaks unrelated. The source code is only linked within submodules, as in between child1 and common.
I’m looking at Gradle docs 23.8.3.3. Conditionally substituting a dependency,
configurations.all {
resolutionStrategy.dependencySubstitution.all { DependencySubstitution dependency ->
if (dependency.requested instanceof ModuleComponentSelector && dependency.requested.group == "org.example") {
def targetProject = findProject(":${dependency.requested.module}")
if (targetProject != null) {
dependency.useTarget targetProject
}
}
}
}
However this only seems to work if the requested module is a subproject, which seems pointless, because if it were a subproject, we’d use a project dependency anyway, not a lib dependency.
Any idea how can I get the Maven like behavior in Gradle? Someone asked this in the IDEA forum where he was told to create his own custom plugin. IDEA claimed that this feature is coming in 2016.3 version but they lied. https://youtrack.jetbrains.com/issue/IDEA-114469
Using Gradle 3.0, the latest. For full disclosure, I’ve also posted this question on StackOverflow.