I'm trying to build an ear using Gradle.
I've my project tree like:
/project | |--> /web-application | | | |--> /src (stuff of web app) | | | |--> build.gradle | |--> build-gradle |--> settings.gradle
I'm trying to generate the ear using the ear plugin, but when I do gradle assemble
I have the war created under the build directory of the web-application, but inside the generated ear I have a jar of the web application. The gradle configuration files are very simple, here they are:
project/build.gradle
apply plugin: 'ear' repositories { mavenCentral() } dependencies { deploy project(':web-application') earlib group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar' }
project/web-application/build.gradle
apply plugin: 'war' repositories { mavenCentral() } dependencies { compile group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar' }
What I did wrong?
I notice that also the bundled samples for the war plugin, have the same problem... Thanks in advance
The Jar is created under the $project/build/libs/ folder.
SOLVED!
It needs to configure the WAR module inside the EAR project as:
dependencies { deploy project(path:':web-application', configuration:'archives') earlib group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar' }
You can avoid specifying a configuration for each deploy dependency using something like this:
allprojects { plugins.withType(WarPlugin) { // Set default configuration as WAR archive if WAR plugin is used configurations { 'default' { extendsFrom = [archives] } } } } ... dependencies { deploy project(':web-application') }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With