FWIW here is my first hack of a solution. I plan on rewriting it as a proper
Gradle plugin, but I'm not sure it would be worthy for general consumption.
Should give you some ideas of how to handle it, though. I include it from
build.gradle with "apply from: 'ivy.gradle'"
def IVY_VERSION = "2.2.0"
def IVY_JAR =
"//de2900/build-deps/lib-maven/org.apache.ivy/ivy/${IVY_VERSION}/jars/ivy-${IVY_VERSION}.jar"
File buildDir = new File("build")
File ivyReportDir = new File(buildDir, "ivy-report")
def ivyFile = "ivy.xml"
def ivySettings =
"//de2900/build-deps/lib-jb/jb/jb.itu.ti.build.templates/jb1811/resources/ivy/ivysettings-ng-repo.xml"
def ivyRetrievePattern =
"gen-lib/([class]/)[organization]/[module]/[artifact]-[revision].[ext]"
def localCachedIvyJar = file(IVY_JAR)
task loadIvyTasks {
ant {
property(name: "workspace", value: "d:/udvikler/ws/eclipse")
taskdef(name: "ivyArtifactReport", classname:
"org.apache.ivy.ant.IvyArtifactReport", loaderref: "ivy.taskdefs") {
classpath { fileset(file: localCachedIvyJar) }
}
taskdef(name: "ivyConfigure", classname:
"org.apache.ivy.ant.IvyConfigure", loaderref: "ivy.taskdefs")
taskdef(name: "ivyInfo", classname: "org.apache.ivy.ant.IvyInfo",
loaderref: "ivy.taskdefs")
taskdef(name: "ivyRetrieve", classname:
"org.apache.ivy.ant.IvyRetrieve", loaderref: "ivy.taskdefs")
taskdef(name: "ivyResolve", classname:
"org.apache.ivy.ant.IvyResolve", loaderref: "ivy.taskdefs")
taskdef(name: "ivyReport", classname:
"org.apache.ivy.ant.IvyReport", loaderref: "ivy.taskdefs")
}
}
// This target is invoked from Eclipse (via Ant)
task ivyResolve(depends: loadIvyTasks) << {
ivyReportDir.mkdirs()
ant {
ivyConfigure(file: ivySettings)
ivyInfo(file: ivyFile)
ivyResolve(file: ivyFile, showprogress: true, log: "quiet",
validate: true)
ivyRetrieve(pattern: ivyRetrievePattern, type: "jar,bundle", log:
"quiet")
ivyArtifactReport(tofile: "${buildDir}/ivy-artifact-report.xml")
ivyReport(todir: ivyReportDir)
}
}
On Thu, Feb 3, 2011 at 9:05 AM, Carl Quinn <[email protected]> wrote:
> This approach of parsing the ivy.xml was also mentioned in
> http://jira.codehaus.org/browse/GRADLE-197
>
> Could someone provide a bit of sample code to show how that could be done?
> I am trying to work on a prototype of a Gradle version of our existing build
> framework (Ant+Ivy) in my spare time, but this is a bit of a hurdle for a
> Gradle newbie.
>
>
> On Thu, Dec 30, 2010 at 2:05 PM, Adam Murdoch <[email protected]> wrote:
>
>>
>> On 31/12/2010, at 1:45 AM, Munoz, Pablo [Tech] wrote:
>>
>> When will we get import of ivy.xml and ivysettings.xml?
>>
>>
>> We need to do some reorganising of the dependency DSL before importing
>> ivy.xml files will work well. This reorganisation work is due to happen as
>> part of the first couple of Gradle 1.0 milestone releases. Import of ivy.xml
>> might happen as part of that work, or might happen after that.
>>
>> Importing ivysettings.xml is less likely to happen, as it is a bit too
>> closely tied to the ivy infrastructure, and we want the option to replace
>> some of this infrastructure. However, we might provide some limited form of
>> import. What do you need the ivysettings.xml to support?
>>
>> In the meantime, it is possible to use ivy's API from your build script to
>> parse the various files, and to drive the Gradle dependency DSL
>> programmatically.
>>
>>
>> --
>> Adam Murdoch
>> Gradle Developer
>> http://www.gradle.org
>> CTO, Gradle Inc. - Gradle Training, Support, Consulting
>> http://www.gradle.biz
>>
>>
>