Sibling project setup

I have spent hours of searching and trying, and reading oh-so-many docs, so please bear with me:

I want to have some base/utility projects on which other projects rely, as siblings in my environment, without a parent project, nor a master sibling with a settings file in it.

eclipseWorkspace

  • clientApiProject
  • clientImplementationProject (depends on clientApiProject)
  • servicesProject (depends on clientApiProject and clientImplementationProject)

I want all three projects to be checked into git, and don’t want some enclosing project, because then I can’t check them all into git separately (since the three projects listed here would be subfolders of the big parent project).

I want to be able to trigger the build of the services project, and have my ide detect and build whatever is necessary from the other projects in this project’s bin dir so I can just run it.

I don’t want a sibling project (like master) with a settings file in it, because it means that I have to manually build from a different project than the one in which I’m editing files.

I just want to save my file in the services project, have it detect any changes in the other two, and build everything into my bin dir so I can run it.

How do I do this?

Sounds like you want to use Composite Builds

See this SO answer for a trick to avoid nested composite builds

Thanks for the pointer. I’ve taken a look at the documentation at: Composing builds, and setup a couple of test projects, but I’m unable to get this to work.

(I tried a bunch of screenshots, but apparently new users only get one image.)

testlib`

  • ``build.gradle
    plugins {
    id ‘java’
    }
  • testLib.Target.java
    package testLib;

public class Target {

public void doSomething() {
	System.out.println("helloworld");
}

}

testConsumer (project)

  • settings.gradle
    pluginManagement {
    includeBuild ‘…/testLib’
    }
    includeBuild ‘…/testLib’
  • build.gradle
    plugins {
    id ‘java’
    }
  • Main.java
    package testConsumer;

import testLib.Target;

public class Main {

public static final void main(String[] args) {
	new Target().doSomething();
}

}

testConsumer.Main fails at line 3, on the import.

A little more help?

In your build.gradle you’ll need to add a dependency to the testlib module from the included build. Something like:

plugins {
   id 'java' 
} 
dependencies {
   implementation 'com.mygroup:test-lib:1.0' 
} 

Thanks for the follow-up, Lance.

I’ve found something which works with includeFlat and dependencies { implementation project(":otherProject") }.

I’d like to get your solution working, but need some time to play with it. I’ll report back when I do :slight_smile:

Thanks again.