Issue
I have three eclipse projects (Project A, Project B, and Project C) in my workspace. Project B and C depend on Project A.
In my build.gradle file, I've set up the dependencies in B and C to refer to A:
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile('com.example:projectA:1.0')
}
However, when I right click and select Gradle->Refresh Gradle Project on Project B or C, it states that it is unable to resolve the projectA dependency.
I'm using Mars 4.5.2 and Buildship version 1.0.20. I understand that Buildship 2.0 once released will provide support such that it can refer to other eclipse projects as dependencies. In the interim though, how do I install project A into the repo and refer to it in project B and C? I do not see an install option for project A in the Buildship Gradle Tasks.
Solution
You've added a dependency using a GAV (group-artifact-version): com.example:projectA:1.0
.
When you declare a dependency in gradle using a GAV, gradle assumes that it should go look for that dependency in all the available Maven or Ivy repositories that it knows about. I presume that the reason it can't resolve the GAV, is that you never published project A to any repository where your build is searching.
You have two ways out:
Publish project A's output (jar files) to a Maven repo. You would need to apply the Maven publishing plugin. For example, you could publish to your local repo using "gradle publishToMavenLocal".
Declare the dependency as a Project dependency, and keep your projects as sub-project of the same parent project. You'd declare the dependency as
compile project(':projectA')
The latter is probably a lot easier to work with.
BTW, Buildship itself probably has little to do with this issue, rather it's a general problem of using dependency tracking build systems like Gradle or Maven. I remember seeing some reference to how Gradle would solve this problem better in 3.0 and up, but I can't seem to find the link at the moment.
Answered By - Jolta
Answer Checked By - Candace Johnson (JavaFixing Volunteer)