How to specify artifact type mappings for Ivy repositories

Somewhat related to:

We are consuming dependencies from an Ivy repository and it has peculiar conventions which don’t map to Gradle’s expectations. In paticular, sources are published with type ‘src’, javadocs with type ‘doc’ and binaries with type ‘bin’. The extensions are correspondingly zip, zip and jar. Classifiers are not being used.

Currently we get the default Gradle behavior when the ivy mappings don’t match the standards - it loads all configs in the classpath and when generating projects they come without sources attached.

Is there a way to describe to Gradle the particular mappings for this repository, or if necessary - per artifact?

Alternatively, is there a recommended way to get rid of the garbage artifacts that get added to the classpath?

In fact it seems that none of the Gradle dependency notation provides any way of expressing the “type” of an ivy dependency artifact I want to use.

Am I missing something?

Why would you want/need to specify an artifact type when selecting an Ivy module?

I need to specify the type as a last resort to prevent consuming poisonous dependencies. The repo in question is structured so that sources, docs, poms and binaries are published without classifier, but with different types.

The way gradle interprets this is to include them all in the classpath. This causes some test classes to interfere with some classpath scanning.

I tried to use the shorthand notation as ‘group:artifact::type:version@jar’, hoping that if Gradle sees 5 parts it would interpret the last as type, but it did not work. I tried the map notation to specify ‘type’ in the same way as one may specify classifier. I finally tried to use nested ‘artifact {}’ config, but that just added the artifact and then Gradle went on to read the full descriptor.

1 Like