I've recently started using Gradle and replacing my existing Maven-based projects. I have had many issues in the past with handling multi-module builds with Maven. Gradle has been a breath of fresh air when handling multi-module buils, but it's not perfect yet.
I have the following folder layout for my projects:
-- Projects
---- EnterpriseApp1
------ EarProject
-------- build.gradle
------ EjbProject
-------- build.gradle
------ WarProject
-------- build.gradle
------ properties.gradle
------ build.gradle
---- CommonLib
------ build.gradle
---- ClientApplication
------ build.gradle
The problem I am having is that the "EnterpriseApp1" and "ClientApplication" both depend on the CommonLib project. I don't know how to configure my "EnterpriseApp1" build file to use the CommonLib project as dependency for the "EjbProject". I have come very close to getting this to work, but not quite working yet. I have had success by copying the CommonLib folder inside "EnterpriseApp1", but that's not a long term solution.
Here's my current properties.gradle file in "EnterpriseApp1":
include "EarProject", "EjbProject", "WarProject"
includeFlat "CommonLib"
According to the Gradle documentation the "includeFlat" command in the "settings.gradle" file will include projects on the same level as the folder where the "settings.gradle" file resides (desired behavior).
EnterpriseApp1/build.gradle file:
subprojects {
apply plugin: 'java'
sourceCompatibility = 1.6
group = 'org.example'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
...
}
dependencies {
}
}
EnterpriseApp1/EjbProject/build.gradle:
apply plugin: 'java'
sourceCompatibility = 1.6
repositories {
mavenCentral()
...
}
dependencies {
compile project(':CommonLib')
compile group: 'org.restlet.jee', name: 'org.restlet', version: '2.0.11'
compile group: 'ma.glasnost.orika', name: 'orika-core', version: '1.0'
...
compile group: 'javax.jmdns', name: 'jmdns', version: '3.4.1'
}
When I execute "gradle clean build" from the EnterpriseApp1 folder all the dependencies are downloaded as expected and the projects begin to compile (including the CommonLib project), but the EjbProject project fails during the build due to the fact it's missing the CommonLib jar reference. Gradle is not smart enough (or I'm completely clueless ;)) to configure my EjbProject to use the Jar generated from the CommonLib project build stage.
I apologize for the long and complicated setup. I have been working on trying to figure this out for some time now, but have nearly ran out of ideas. I would really appreciate any help for the community.
Thanks!
See Question&Answers more detail:
os