Custom Configuration wont resolve artifact only dependency

The documentation describes the artifact only notation @zip (50.4.1.2). This works fine when I use the testRuntime configuration created by the Java plugin, but when I create a custom configuration, the artifact is not resolved

configurations {
    dotnet
}
  dependencies {
    dotnet 'group:dotnet-api:' + DotNetAPIVersion + ':@zip'
}

If I try to loop through the configuration, gradle claims it resolve the dependency, like it is simply ignoring the @zip. What do I need to do to get my configuration to resolve an artifact only dependency?

Where do you use this configuration? Configurations in gradle are lazy. this means that they are just resolved when you use them. In your snippet above you just declared that configuration, but don’t use it.

to test the resolution is correct, you can add a simple task:

task testResolve << {configurations.dotnet.files.each {println it.absolutePath}

When running the testResolve task, the configuration should be resolved.

cheers, rené

I did, and it prints:

Tasks to be executed: [task ‘:testResolve’] :testResolve (Thread[Daemon Thread 6,5,main]) started. :testResolve Executing task ‘:testResolve’ (up-to-date check took 0.0 secs) due to:

Task has not declared any outputs. :testResolve FAILED :testResolve (Thread[Daemon Thread 6,5,main]) completed. Took 0.002 secs.

FAILURE: Build failed with an exception.

  • Where: Script ‘/home/kg/work/master/dist.gradle’ line: 126

  • What went wrong: Execution failed for task ‘:testResolve’. > Could not resolve all dependencies for configuration ‘:dotnet’.

Could not find robosuite-api:robosuite-dotnet-api:1.23.0.0.

Required by:

:master:unspecified

Here is a cooked down example

configurations {
    foo
}
  dependencies {
    foo 'junit:junit:4.11:@jar'
}
  task useFoo() << {
    configurations.foo.each {
        println it
    }
}

This will not work on its own, but if you add the Java plugin it works, any idea why ?