Hi,
I’m using gradle 1.4, under debian linux environment.
I have a multiproject build, that includes many wars. I need to build more than one ear, according to customers needs. Here is a simplified example, to focus the problem: For an ear-project I need to build two ears: the first ear (let’s say ear1) must include a ejb module and a war (let’s say war1), and the second (say ear2) is the same of the first, but also need a war2. The two ears have different dependencies and, since I’m deploying to jboss appserver, I have to build a list of shared jars that I will put in the appserver lib dir, avoiding to place them in the ear.
So the situation is:
ear1
-jar
-war1
ear2
-jar
-war1
-war2
and I have also two zip including the dependencies for the 2 ear’s: shared_libs1.zip shared_libs2.zip
The dependencies/ ear tasks are something like this:
dependencies {
deploy project(':jar')
deploy project(path: ':war1', configuration: 'archives')
...omissis..
ear {
deploymentDescriptor {
displayName = project.name
version = 5
webModule("war1-${project.version}.war",'/war1')
}
}
dependencies {
deploy project(':jar')
deploy project(path: ':war1', configuration: 'archives')
deploy project(path: ':war2', configuration: 'archives')
...omissis..
ear2 {
deploymentDescriptor {
displayName = project.name
version = 5
webModule("war1-${project.version}.war",'/war1')
webModule("war2-${project.version}.war",'/war2')
}
}
The logic to extract the shared libs is a little bit complex, and also I need to place a deployment description in the two ear’s.
In my undestanding, I cannot place two ear definition in the same build.gradle; I can create a task ear2(type: ear) but then I cannot use the deploymentDescriptor.
I could solve this issue by creating 2 project, one for ear1 and the other for ear2, but this will cause a multiplication of the folders and I don’t like it.
I thought that I could solve this creating a copy of the build.gradle (say build2.gradle), but, while the build using build.gradle works fine, using build2.gradle I receive some errors:
gradle -b build2.gradle ear
* What went wrong:
A problem occurred evaluating root project 'xxx-ear'.
> Project with path ':jar' could not be found in root project 'xxx-ear'.
I thought that the problem is the settings.gradle, but I have another error:
gradle -c ../settings.gradle -b build2.gradle ear
* What went wrong:
Could not select the default project for this build. No projects in this build have build file 'build2.gradle'.
So, question are: 1) what is the proper solution to a “double ear” need? 2) if the “double build.gradle” approach is the best (or better than nothing ), how can I solve the errors that I’m facing?
Thanks,
Luca