On 6/3/11 6:38 PM, Peter Niederwieser wrote:
David Gileadi wrote:
So my question is, does anyone have a suggestion on how to gain this
effect in Gradle?
It's fairly easy to simulate Maven's 'provided' scope in Gradle:
configurations {
provided
}
dependencies {
provided "some:dep:1.0"
}
sourceSets {
main {
compileClasspath += configurations.provided
}
test {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
}
idea {
module {
scopes.PROVIDED.plus += configurations.provided
}
}
Depending on your exact needs, you could omit configuring the test class
paths and/or IDEA class path.
Thanks for the suggestion. I've tried doing this within the m2metadata
plugin's apply method via the following code:
configuration =
project.getConfigurations().add(PROVIDED_COMPILE_CONFIGURATION)
.setVisible(false);
JavaPluginConvention convention = (JavaPluginConvention)
project.getConvention().getPlugins().get(JAVA_PLUGIN_CONVENTION_NAME);
convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getCompileClasspath().add(configuration);
SourceSet testSourceSet = convention.getSourceSets().getByName("test");
testSourceSet.getCompileClasspath().add(configuration);
testSourceSet.getRuntimeClasspath().add(configuration);
However, I always get an "UnsupportedOperationException: Configuration
':myproject:compile' does not allow modification." I take this to mean
that by the time the apply method is called it's too late to modify the
sourceSets.
I'd really prefer that the m2metadata plugin be able to simulate the
"provided" scope rather than requiring projects to define it themselves.
Can you think of a way? If not, I suppose the plugin could support
that configuration if it exists, and use the default configuration
instead...
Thanks again for your help!
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email