In build.gradle I am building WAR for tomcat and wildfly by single script. Wildfly has provided dependency to "javax.mail:mail:1.4.7'. But tomcat is missing this jar. So I have always added this jar to ${CATALINA_HOME}/lib/ . Currently I am trying to migrate from both of them to Amazon AWS Elastic Beanstalk and I don't want to mess with ${CATALINA_HOME}/lib/. How to write universal gradle script for wildfly with:
dependencies {
....
providedCompile group: 'javax.mail', name: 'mail', version: '1.4.7'
providedCompile group: 'javax.activation', name: 'activation', version: '1.1.1'
...
}
and for tomcat with:
dependencies {
...
compile group: 'javax.mail', name: 'mail', version: '1.4.7'
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
...
}
I am not an expert with gradle.
@RaGe solved my problem. Code below is an ultimate solution as "42" number.
configurations {
tomcatLibs
}
dependencies {
...
providedCompile group: 'javax.mail', name: 'mail', version: '1.4.7' //provided for wildfly
providedCompile group: 'javax.activation', name: 'activation', version: '1.1.1' //provided for wildfly
tomcatLibs group: 'javax.mail', name: 'mail', version: '1.4.7' //only for tomcat
tomcatLibs group: 'javax.activation', name: 'activation', version: '1.1.1' //only for tomcat
providedCompile group: 'javax.mail', name: 'javax.mail-api', version: '1.5.0'
....
}
//default war for wildfly
war {
....
}
task createTomcatWar(type: War, dependsOn: classes) {
archiveName = 'app-tomcat.war';
classpath configurations.tomcatLibs // adds a configuration to the WEB-INF/lib dir
}
....