Multiproject builds, but NO subprojects (ie. nested projects)

(jhm) #1

Every tutorial that I’ve seen on multi-project builds assumes a hierarchical code base structure:
|- /subProjLib
|- /subProjClient1
|- /subProjClient2

I cannot rejigger the source repo to match this. I have 2 top-level projects with lots of code copy/pasted between them that I desperately want to factor out into a new library project that both projects can reference.

But I cannot figure out how to do this short of stuffing the 2 existing projects into the library project, which is just a deal breaker for me.

Is there way to reference another project that lives at the same level as current one?

Here’s my workspace:
/myLib (the new one I want to create)

I’ve tried this in myClient1:
dependencies {
compile project(’:myLib’)

But it fails to find “myLib” in the same directory, which makes sense so far, but:
compile project(’:…/myLib’)

I was hoping it just walk up (…/) from the currect directory and find myLib project, but it failed.

At the end of the day, I need myLib.jar visible to myClient1 and myClient2 during compilation and also materialized in those projects buildspace (to be RPM’d).

Can anyone please help me with this?

(Dimitar Dimitrov) #2

Search for “flat project layout” and “composite builds”. Here is something to get you started:

Also a quick search found: