Adding project dependencies in a multi project Buildship workspace

677 views Asked by At

I have two projects, client and shared. Both are Buildship projects and have external dependencies defined and working. Here's my multi project setup:

workspace/
    shared/
        build.gradle
    client/
        build.gradle
    settings.gradle

workspace/settings.gradle:

rootProject.name = 'workspace'

include 'client'
include 'shared'

Now I want to sort inter-project dependencies. client depends on compiled artifacts from shared. So according to 25.4.3. Project dependencies I think I add the following to clients build.gradle:

compile project(':shared')

However I can't compile in Eclipse. If I refresh the client project I get:

A problem occurred evaluating root project 'client'. Project with path ':shared' could not be found in root project 'client'.

It's like it doesn't recognise it as a multi project build...

I realised that gradle init had generated a settings.gradle file inside the two child projects. So I removed those files, but then I get a different error when refreshing either child project (and the project becomes entirely unusable):

Provided eclipse project is not the root project

How to get the two projects to work together, and hopefully just define this once?

1

There are 1 answers

3
Dan Gravell On

Thanks to help here the following should fix it:

  1. Delete the client and shared projects from Eclipse, leave the files intact on the file system
  2. Move the root folder with client and shared inside to a different folder, so the root folder is not also the Eclipse workspace root
  3. Perform a Gradle import inside Eclipse for the root folder

That fixed it for me - inter project dependencies were then resolved.