How to retrieve extra properties from ivy file?

Hi, All,

In our organization, we have extra properties in ivy file, which will be read and applied during dependency resolution, use the ivy FileSystemResolver:

<ivy-module version="2.0" xmlns:extra="">
   <info organisation="myorg" module="mymodule" revision="1.0"
        extra:jniPath="//filesystem/mylibs" />

But hence FileSystemResolver will be removed since gradle 2.0, what would be the alternative to achieve this: read the extra properties and apply it during dependency resolution.

Thanks very much!

How do you use the extra attribute value in Gradle?

How is it ‘read and applied during dependency resolution’?

I’m not familiar with how this would work.

We override a function from FileSystemResolver:

public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)

Which provide us with the information to access extra properties, there are actually a jira issue opened here:

OK but does your build file have access to the extra property values? The Gradle API doesn’t give you access to this information in your build, so I’m wondering how you use it.

Can you be a bit more specific about your actual use case for extra attributes?

We cuold access the extra property values. By overriding getDependency, we could get DependencyDescriptor, from which would could get DefaultModuleDescriptor, which has an method: getExtraAttribute(

We get this extra jniPath value to populate java.library.path so our test cases and programs could run properly to loading this jni libraries.

Hi, Deboer - do you need more information? we currently does using FileSystemResolver to get the extra information and do something with it.

Nope, I think I understand how you’re currently using Ivy extra attributes. They aren’t being used in dependency resolution, but recorded by the FileResolver and used elsewhere.

There’s a (not particularly nice) solution that doesn’t use require the use of (deprecated) FileResolver: download the ivy.xml file from the repository and parse it to extract the extra attribute data you require. You can download the ivy.xml file for a module with:

configurations {

ivyModules } dependencies {

ivyModules(‘org.gradle.sample:quickstart:1.0’) {

artifact {

name = “ivy”

extension = “xml”

type = “xml”


} }

While it’s unlikely that Ivy extra attributes will be supported directly in the Gradle model, it’s possible that a new hook will be added that will allow you to access the raw metadata file during resolution. I can imagine this being useful for extracting custom information from pom files, ivy files and whatever new metadata formats we support.