How can I retrieve dependencies in pom test scope transitively?

(gretar arnason) #1

Let’s say I have dependency with a pom file in a repository like:

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

What I’m looking for is to somehow create a new configuration and add the ‘mygroup:myartifact:1.0.0’ to the group in such a way that it will resolve the junit jar. Example build.gradle:

repositories {
  configurations {
  dependencies {
    test 'mygroup:myartifact:1.0.0'
  task dump << {
    configurations.test.files.collect{}.sort().each { println it }

Is there a way to config this in such a way that ‘gradle dump’ will give me result: junit-4.8.2.jar myartifact-1.0.0.jar

Footnote: I’m using the name test for configuration for brevity, I expect it will clash with test task when applying java plugin.

(René Groeschke) #2

Hello gretar, you have to set the “configuration” you want to resolve when looking for a specific scope. for this you have to use the map syntax for delcaring your dependencies:

test group:'mygroup', name:'myartifact', version:'1.1.0', configuration:'test'

unfortunately this does not include myartifact itself so you still need “test ‘mygroup:myartifact:1.1.0’” in your dependency block.

best regards, René

(gretar arnason) #3

Yes! I knew this had to be simple :). Now working like a charm. Thank you so much. Saved my weekend.

best regards gretar