Gradle ear is putting JAR instead of WAR
10,184
Solution 1
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'
}
Solution 2
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')
}
Related videos on Youtube
Comments
-
rascio about 2 years
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
-
angelcervera over 9 yearsAre there Any reference in the documentation?
-
rascio over 9 yearsI don't remember where I take that solution, and the documentation is a bit confusing about it...
-
angelcervera over 9 yearsConfiguration doc: gradle.org/docs/current/dsl/…