Why aren't the classifier and extension included in the ExternalModuleDependency class?


(Andreas Schopper) #1

Hi,

I’d like to generate a xml-File with alle informations about the dependencies, but I don’t know how to get the classifier and the extension form the dependencies.

Regards


(Andreas Schopper) #2

Hi,

where can I get the classifier and the extension of a dependency?

Any hint would be appreciated.

Regards


#3

The ‘classifier’ and ‘extension’ attributes are used to work out which ‘artifacts’ to attach to a dependency; they are not part of the dependency definition per se. You can get these values by looking at the contents of ‘ModuleDependency.getArtifacts()’.

If you’re interested in exactly how the ‘classifier’ and ‘extension’ attributes are processed, take a look at ‘org.gradle.api.internal.artifacts.dsl.dependencies.ModuleFactoryHelper’.


(Andreas Schopper) #4

Hi Daz,

thanks for the reponse. I don’t understand why a dependency can have more then one artifact. Has this to do with the transitive dependencies?

Regards


#5

The Maven POM is a very simple metadata format, that does not explicitly define artifacts. So when using a Maven repository you’ll get 1 artifact per dependency. However, the Ivy xml metadata format is much richer, and permits multiple artifacts to be defined for a single dependency module.


(Andreas Schopper) #6

I know, I have to use differnt classifier for uploading more then one artifact. But this isn’t my problem. When I define a dependency like

dependencies {

compile(group: ‘com.oracle’, name: ‘ojdbc6’, version: ‘11.2.0.3.0’, classifier:‘sources, ext:‘zip’’) }

how can I access the classifier and extension of the ojdbc6 dependency in the code?

The ExternalModuleDependency class dosen’t provide this information.


(Peter Niederwieser) #7

The ‘classifier’ and ‘extension’ information is stored on the artifact level. See ‘ModuleDependency.getArtifacts()’.


(Andreas Schopper) #8

ModuleDependency.getArtifacts() returns a set of DependencyArtifact but this class has no version included and it doesn’t contain the resolved depencencies.

For example: If I define a dependency like

compile(group: ‘jfree’, name: ‘jfreechart’, version: '1.0.+)

How can I get the resolved version of this dependency within a task?


(Peter Niederwieser) #9

You can use the ‘configuration.incoming’ API.


(Andreas Schopper) #10

Hi Peter,

thanks, this works.

Regards Schoppi