I have a build including about 10 projects. Finally everything is packed into one war-File. My current setup described below works but I think there must be a better solution.
What I would like is to define the plugin war on the “web”-project which is one of the given 10 projects. As the other projects define dependencies which shall not be included in the final war I use the providedCompile feature. However in order to be able to use providedCompile the project needs to have the war plugin defined. So I ended up to define the war-plugin on all 10 projects. Building the projects creates war-file in all of the 10 projects which doesn’t make sense…
Is there a better solution?
One solution is to define regular ‘compile’ dependencies for the other projects and additionally list those dependencies that should not make it into the War under ‘providedCompile’ in the web project. Another solution is implement your own ‘provided’ configuration. For the latter, see previous questions here or on Stack Overflow.
Thanks for your answer.
Did you mean the following question in Stack Overflow http://stackoverflow.com/questions/13925724/providedcompile-without-war-plugin
I didn’t mean any question in particular, but this appears to be one of them.
I created a provided configuration as follows:
configurations {
provided
compile.extendsFrom(provided)
runtime.minus(provided) }
Unfortunately the libraries marked with provided are finally in the war-file as well?!?
Subtracting a configuration returns a new file collection, rather than modifying the original configuration. Why don’t you follow one of the solutions given in the forum or Stack Overflow posts on the topic.
Okay. Thanks for this hint.
I have taken the solution from the follwowing post: http://stackoverflow.com/questions/13925724/providedcompile-without-war-plugin
I haven’t found any other useable posts on stack overflow.
Could you point me to the appropriate stack overflow post? or give me a better solution?
I don’t see your solution mentioned in that post.
Googling “gradle provided” returns several forum and stack overflow posts on the first result page.
Well I did that long before having posted the given question in this forum. Obviously I coulnd’t find a solution. Googling “gradle provided” brings up only the following post which doesn’t solve my problem:
http://stackoverflow.com/questions/12301513/gradle-provided-dependency-for-java-plugin
Why can’t you just give me the link to the Stack Overflow post which discuesses my problem. Or even better if you know how to do it right. Why don’t you just give me a concrete solution?
Thanks for your help.
Thanks for the given links. I read the same links before having posted this question and none of these worked out.
I think the problem lies in the fact that I have a multi-project build. When I try the following proposal (as mentioned in the first link you have given):
configurations {
provided } sourceSets {
main { compileClasspath += configurations.provided } }
I encounter the problem that a library XY which is marked as provided in project A is not on the classpath of a depending project B (meaning Project B has a dependency on project A). Using providedCompile of the WAR-Plugin libraries markes as providedCompile in a project are availabe in depending projects.
When I use the following approach:
configurations {
provided
compile.extendsFrom(provided) }
The libraries marked as provided are know available in depending projects. BUT the provided libraries are unfortunately part of the war-File.
Any hints are still welcome
I encounter the problem that a library XY which is marked as provided in project A is not on the classpath of a depending project B
But that’s the whole point of ‘provided’.
I don’t think so. The point of providedCompile or provided (which is a custom providedCompile) is to have all available for compilation but finally not in the war-file which is built.
As mentioned using providedCompile libraries marked with providedCompile are available in depending projects.
I’m talking about Maven’s ‘provided’ scope here (and Gradle’s equivalent thereof). ‘providedCompile’ only exists in Gradle war projects, which aren’t really meant to be depended-upon.
I’m afraid I don’t understand your problem well enough to help any further. Maybe someone else can chime in.