Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle ear is putting JAR instead of WAR

Tags:

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

like image 534
rascio Avatar asked Mar 12 '13 12:03

rascio


People also ask

Where does Gradle build Put the jar?

The Jar is created under the $project/build/libs/ folder.


2 Answers

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' } 
like image 91
rascio Avatar answered Sep 19 '22 12:09

rascio


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') } 
like image 23
Vyacheslav Shvets Avatar answered Sep 20 '22 12:09

Vyacheslav Shvets