Hi everyone,
I’m looking at converting an existing Ant + Ivy build over to Gradle. We have several java sub-projects that are used within a J2EE container as well as standalone. These projects may depend on resources provided by the container, so we have different configurations in Ivy that indicate the dependencies for each use case.
Ivy Configurations
- compile: all compile time dependencies, including container dependencies
- container: all runtime dependencies required when used in a container. This module doesn’t include dependencies provided by the J2EE container
- standalone: all runtime dependencies, including those which would have normally been provided from a container.
There is no extension between our current Ivy configurations, but logically standalone includes everything in container. Occasionally there is something included in compile that is not in the others (e.g. findbugs annotations).
I’ve tried to reproduce this functionally in gradle. Here is my intended configuration in gradle.
I use one of these configurations when declaring dependencies
- container: dependencies provided by the J2EE container
- runtimeContainer: runtime dependencies that are needed while running in the container
- provided: dependencies used at compile time but not at runtime
- testCompile: dependencies used for the test source
I then mark these as extending some combination of the configurations above:
- runtime - extends runtimecontainer and container; all runtime dependencies for running standalone
- compile - extends runtime and provided
When I do all of this, gradle task gives me a StackOverflowError. The following build.gradle demonstrates the setup and error, if you run gradle dependencies:
apply plugin: "java"
configurations {
container
provided
runtimeContainer
runtime.extendsFrom = [container, runtimeContainer]
compile.extendsFrom = [provided, runtime]
testRuntime.extendsFrom = [runtime]
testCompile.extendsFrom = [testRuntime]
}
How can I setup my dependency configurations to enable me to handle my projects being used with and without a J2EE container?