How to get the path of a JAR based on a Dependency object?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the path of a JAR based on a Dependency object?

gradlefan
Hey,

I'm trying to write a plugin for my own purposes. For this to work I need get the actual file system path of JAR files represented by a Dependency object.

I can't find any obvious method in the JavaDoc.

Please advise.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: How to get the path of a JAR based on a Dependency object?

hans_d
Administrator

On May 12, 2008, at 3:15 PM, gradlefan wrote:

Hey,

I'm trying to write a plugin for my own purposes. For this to work I need
get the actual file system path of JAR files represented by a Dependency
object.

I can't find any obvious method in the JavaDoc.


There is no obvious method right now. We want to make the resolve API richer in our future releases.

If you don't mind getting into the guts of our dependency handling you could do the following:

import org.gradle.api.tasks.util.FileSetimport org.apache.ivy.core.resolve.ResolveOptions

... some declarations

init.doLast() {   dependencies.dependencies.each {       def resolveOptions = new ResolveOptions()       def resolveReport = dependencies.ivy.resolve(it.createDepencencyDescriptor().dependencyRevisionId,           resolveOptions, false)       println resolveReport.dependencies   }}

As part of the init task we resolve every single dependency and print out all of its dependencies. ResolveOptions and ResolveReport are Ivy classes. You might look in the Ivy JavaDoc or Ivy code for further details.

Such things should become more convenient in the future. 

- Hans 

Please advise.

Thanks
-- 
Sent from the gradle-user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:




--
Hans Dockter
Gradle Project lead




Reply | Threaded
Open this post in threaded view
|

Re: How to get the path of a JAR based on a Dependency object?

hans_d
Administrator

On May 13, 2008, at 10:34 AM, Hans Dockter wrote:

On May 12, 2008, at 3:15 PM, gradlefan wrote:

Hey,

I'm trying to write a plugin for my own purposes. For this to work I need
get the actual file system path of JAR files represented by a Dependency
object.

I can't find any obvious method in the JavaDoc.


There is no obvious method right now. We want to make the resolve API richer in our future releases.

If you don't mind getting into the guts of our dependency handling you could do the following:

import org.gradle.api.tasks.util.FileSetimport org.apache.ivy.core.resolve.ResolveOptions

... some declarations

init.doLast() {   dependencies.dependencies.each {       def resolveOptions = new ResolveOptions()       def resolveReport = dependencies.ivy.resolve(it.createDepencencyDescriptor().dependencyRevisionId,           resolveOptions, false)       println resolveReport.dependencies   }}

The same again with new lines:

import org.gradle.api.tasks.util.FileSet
import org.apache.ivy.core.resolve.ResolveOptions

init.doLast() {
   dependencies.dependencies.each {
       def resolveOptions = new ResolveOptions()
       def resolveReport = dependencies.ivy.resolve(it.createDepencencyDescriptor().dependencyRevisionId,
           resolveOptions, false)
       println resolveReport.dependencies
   }
}


As part of the init task we resolve every single dependency and print out all of its dependencies. ResolveOptions and ResolveReport are Ivy classes. You might look in the Ivy JavaDoc or Ivy code for further details.

Such things should become more convenient in the future. 

- Hans 

Please advise.

Thanks
-- 
Sent from the gradle-user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:




--
Hans Dockter
Gradle Project lead





--
Hans Dockter
Gradle Project lead