Reputation: 373
I'm using gradle V4.10.2
and eclipse
for building WAR
files. I have some common JAR
files for all the wars. I need them to use only during compile time and need to exclude them while building into WAR
file. Also I don't want to exclude all the JAR
s file.
I've put all the JARs in libs
folder. In build.gradle
, I have specified only the JARs to be included. Since the exclude list is bigger then include list of JARs I'm not using exclude
war {
rootSpec.include("**/test.jar")
}
The above results the WAR
file without META-INF
folder. Hence, webapp is not started. I have tried adding the libs as reference lib
in eclipse
but that results in compilation error.
Execution failed for task ':compileJava'.
Compilation failed; see the compiler error output for details
So I have to include all the JARs in libs folder and then need to use only required JARs in the WAR built. How to include only specific JARs into build?
Upvotes: 0
Views: 2088
Reputation: 14500
I strongly recommend reading about building Java projects with Gradle and in particular the part about web applications
In short you should add the JARs needed for compilation only to the compileOnly
configuration and the JARs needed for compilation and at runtime in the implementation
configuration.
Gradle will then use all of them for compilation and only include the ones in implementation
when packaging the WAR.
While you can do that by selecting them from your libs
folder, I strongly recommend moving to libraries and its metadata sourced from a repository, private or public, so that the dependency management is done for you.
Upvotes: 2