I should have been a bit more specific. You need both
groovy localGroovy()
providedRuntime localGroovy()
Which does the job of both making Groovy available for your tests, as well
as removing it from the WAR. The down-side is that it "allows" Groovy code
to also creep into your "main" classes, which you won't notice until you try
to run the war.
A better way is a combination of what you started with, with what I did:
dependencies {
groovy localGroovy()
testCompile localGroovy()
}
configurations.runtime.exclude group:'org.codehaus.groovy'
That has the virtue of being explicit that Groovy is being used for
specifically testing, and that it should not be part of the main runtime
configuration.
The issue of attaching the configuration/plugin a particular sourceset that
GRADLE-1124 talks about is still there, since tasks like "compileGroovy"
don't make sense in this context. But that brings with it a whole new set
of nuances.
On Thu, Aug 19, 2010 at 4:24 PM, Steve Appling <[email protected]>wrote:
> Thanks for all the suggestions. I thought I would update the list with
> what I found out.
> Jason Porter wrote:
> > Exclude it for runtime?
>
> I had tried
> configurations {
> runtime.exclude group:'org.codehaus.groovy'
> }
>
> but this ends up excluding it from testRuntime as well since testRuntime
> extends runtime. If I do this, then my I can't use it for testing. There
> might be some other trick here that I didn't find, but I didn't figure out a
> solution this way.
>
> Jim Moore wrote:
> > Another hack is to do
> >
> > providedRuntime localGroovy()
>
> This doesn't work because gradle enforces having a groovy configuration to
> run groovy. You will get the error:
> Execution failed for task ':compileTestGroovy'.
> Cause: You must assign a Groovy library to the groovy configuration!
>
> Luke Taylor wrote:
> > Check out this issue too:
> >
> > http://jira.codehaus.org/browse/GRADLE-1124
> >
> > On 19/08/2010 12:52, Steve Appling wrote:
> >> How can I use groovy only for testing? If I declare a groovy
> configuration under dependencies (which I have to do to use groovy at all),
> then I get the groovy-all jar in my WEB-INF/lib of my war. I want to use
> groovy (and spock) for testing, but not ship it.
>
>
> This issue is exactly what I am running into, thanks for pointing it out.
> The workaround that Adam suggested there doesn't seem to work exactly, but
> something close does. I'll update that Jira with my change. I ended up
> using :
> configurations {
> compile.extendsFrom = [providedCompile]
> testCompile.extendsFrom groovy
> }
>
> Thanks for all the ideas. It's great to have a responsive community when
> your brain isn't working well.
>
> --
> Steve Appling
> Automated Logic Research Team
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
-Jim Moore