Tuesday 14 June 2016

Update Ivy xml generated in Ivy publication in Gradle




How to update Version in Ivy xml generated in Gradle ?


Solution:

In Gradle it uses  groovy scripting API.
So think like groovy guy .
To update this Ivy XML::
  1. Go to  Interface IvyPublication
  2. Go to Method > IvyPublication>descriptor
  3. Where descriptor takes IvyModuleDescriptorSpec
  4. Go to above interface, u will find wihXML which returns XMLProvider
  5. XMLProvider has asNode() method which returns Root node.

Usage :
publishing {
publications {
       
Ivy(IvyPublication) {
organisation "$project.group"
                                module "$project.name"
                                revision "$project.version"
from components.java
descriptor.withXml {
asNode().info[0].appendNode("description", project.name)
asNode().dependencies.dependency.findAll{ it.@org.startsWith("com.group")}.each{ it.@rev = "$project.version" }
               }
             }
    }
    repositories {
       mavenLocal()

    }
}

No comments:

Post a Comment

Please comment here