I have a multi-project Gradle build structure, where child project depends on a JAR, which I don't want to be in WAR file. I tried "exclude" but it does not work.
The main project script:
apply plugin: 'war'
war {
dependencies {
runtime (project(':childProject')) {
exclude group: 'javax.servlet.jsp', module: 'jsp-api'
}
}
}
The childProject script:
apply plugin: 'java'
dependencies {
compile 'javax.servlet.jsp:jsp-api'
}
From the Gradle documentation
The War plugin adds two dependency configurations: providedCompile and providedRuntime. Those configurations have the same scope as the respective compile and runtime configurations, except that they are not added to the WAR archive.
So, in other words, adding an entry to providedCompile
or providedRuntime
will cause that dependency to be excluded from the war file.
providedCompile
if you have source that relies on some classes for compilingprovidedRuntime
if you use it for testing and not compiling.http://www.gradle.org/docs/current/userguide/war_plugin.html
Example
providedCompile "javax.servlet:servlet-api:2.5"