I’m having some difficulty retrieving artifacts which use custom dependency scopes in our external POM files.
I understand Gradle uses maven libraries as a means to fetch external maven dependencies.
I also understand that from Maven’s perspective, Maven POM files can only use a specific set of dependency ‘scopes’
– compile, runtime, etc.
Like several other posters, we have a need to define and use some custom dependency scope in our maven POM files. For example, ‘manifest’ scope and ‘release’ scope.
I am able to use Gradle to publish these dependencies with custom POMs using these scopes.
However, I am having difficulty getting Gradle to download dependencies with a specified scope.
So far in my experimentation, Gradle downloads the specified ‘compile’ config dependency and any other dependencies listed in its POM file, even when their scopes do not match the gradle configuration (‘compile’).
I would like to be able to align the gradle configuration with the maven pom scopes evaluated during dependency resolution.
So for example, if I am using the compile configuration in Gradle, only ‘compile’ scope artifacts would be retrieved.
However, what I am seeing happen is that although my Gradle dependency uses compile config, the artifacts downloaded (transitively) have all sorts of different scopes in the maven poms.
Is there a way to restrict which artifacts are downloaded, say by applying scope filters somehow to the set of artifacts to download?
An example might be helpful.
Say I have an external maven artifact com.foo:bar:1.0.168 which has a pom like this
...
<groupId>com.foo</groupId>
<artifactId>bar</artifactId>
<version>1.0.168</version>
<dependencies>
<dependency>
<groupId>com.foo</groupId>
<artifactId>bar-manifest</artifactId>
<version>1.0.30</version>
<scope>manifest</scope>
</dependency>
</dependencies>
...
In my build.gradle, I have this block:
dependencies {
compile 'com.foo:bar:1.0.168'
}
task fetchArtifacts << {
copy {
from configurations.compile
into "lib"
}
}
When I run ‘gradle fetchArtifacts’ it downloads not just com.foo.bar:1.0.168 but also all dependencies listed in com.foo.bar-manifest:1.0.30, with various maven pom dependency scopes such as ‘release’, ‘compile’, and ‘manifest’.
I would like to retrieve only the compile dependencies – com.foo.bar:1.0.168 and any other compile dependencies listed in com.foo.bar-manifest:1.0.30.
Any thoughts?
Thanks! -Steve