view fix-ivy.groovy @ 87:be111b66cdc6

fix publishlocal task
author smith@nwoca.org
date Tue, 14 Feb 2012 15:52:29 -0500
parents da29f9bde0da
children 9f2ab59a5333
line wrap: on
line source
import groovy.xml.*

def xml = new XmlSlurper()
def ivy = xml.parse( new File('ivy.xml'))

def cfgs =  ivy.configurations

if (cfgs.@defaultconfmapping.size() == 0) {
    println "adding defaultconfmapping"
    cfgs.@defaultconfmapping = '*->default'
}

if (!cfgs.children().find { it.@name == 'default' } ) {
    println "adding default config"
    cfgs.appendNode {
        conf(name:"default")
    }
}

groovy = ivy.dependencies.children().find { it.@org == 'org.codehaus.groovy' && it.@name == 'groovy' }
if (groovy) {
    groovy.@conf = "*->default,optional"
    println "Groovy ${groovy.@rev} conf changed to ${groovy.@conf}"    
}

def sameConfMappings = ivy.dependencies.children().findAll { it.@conf in ['*->@','*->*'] }

println sameConfMappings.each { 
    it.@conf = "default->compile;%->@"
    println "changing conf for ${it.@name} to ${it.@conf}" 
}


def outputBuilder = new StreamingMarkupBuilder()
new File('ivy.xml').write(  XmlUtil.serialize( outputBuilder.bind { mkp.yield ivy }).replaceAll('>','>'))