ProvidedCompile for groovy?

Hi is there a providedCompile for groovy? I have a project where I’m building a war file and have integration tests running with groovy. But when I create the war file the groovy libraries and dependencies are inside WEB-INF/lib. How can I exclude them from being copied into the WEB-INF/lib folder?


Hello guy, I assume, that you applied the groovy plugin and the war plugin. to solve this issue, have a look at the solution provided by luke in this thread:

regards, René

Hi Rene

thanks for the quick reply. It worked with Luke’s solution. I just found an old issue which isn’t implemented anymore in milestone 8. Are there any plans to re-add this functionality?



Hi guy, honestly I am not aware of any plans to do this.

regards, René

That is a petty. For the same reason there is a providedCompile for the Java plugin, there should also be a providedCompile for the Groovy plugin - unless providing deep support for projects written in Groovy is not on your list. Or am I overlooking some alternative here?

The providedCompile configuration is added by the War plugin to represent compile time dependencies that are later provided by the container and its available for groovy and java only projects, but it’s not part of the JavaPlugin. We’re aware of the fact, that using groovy for tests only is a common usecase and we should support this pattern in a better way.

regards, René

The use case is important to us, but we don’t want to solve it using a providedCompile configuration.

Instead, we will get rid of the special groovy configuration, and you will declare groovy as a regular dependency. The groovy plugin will find it in the appropriate compile or testCompile configuration, and do the right thing based on where it finds it.

For example, if I declare:

dependencies {
    compile 'org.codehaus:groovy:1.8.5'

then the groovy plugin will use ‘org.codehaus:groovy:1.8.5’ as the implementation to use for ‘compileGroovy’, ‘compileTestGroovy’, ‘groovyDoc’, ‘test’ and so on. It will also end up in the generated ivy.xml or pom.xml, in the IDE class path, and so on.

If I have a project that uses groovy only for testing, then I would do this, instead:

dependencies {
    testCompile 'org.codehaus:groovy:1.8.5'

then, the groovy plugin will use groovy as a dependency only for test compilation and execution. Groovy would not end up in the generated ivy.xml or pom.xml, or the IDE compile class path.

Very nice! Thanks for the detailed explanation.