2
votes

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.

1
Does the above config build successfully if you use the gradle command line? ./gradlew projectB:build - Jolta
No. It states Could not find com.example:projectA:1.0. Searched in the following locations: The locations include the local repo. When I navigate the local repo file system, I also cannot find the path to projectA, so my issue appears to be the inability to install project A in the local repo. But I'm not sure how to install project A using Buildship. - James
I think your problem is not related to Buildship... I'll post an answer. - Jolta
What gradle version are you using? - Jolta
Thanks. I'm using version 2.11 - James

1 Answers

1
votes

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:

  1. 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".

  2. 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.