comparison fix-ivy.groovy @ 86:da29f9bde0da

groovy script to 'fix' ivy scripts to use standard conventions for configurations
author smith@nwoca.org
date Tue, 14 Feb 2012 15:41:45 -0500
parents
children 9f2ab59a5333
comparison
equal deleted inserted replaced
85:f36eeb411845 86:da29f9bde0da
1 import groovy.xml.*
2
3 def xml = new XmlSlurper()
4 def ivy = xml.parse( new File('ivy.xml'))
5
6 def cfgs = ivy.configurations
7
8 if (cfgs.@defaultconfmapping.size() == 0) {
9 println "adding defaultconfmapping"
10 cfgs.@defaultconfmapping = '*->default'
11 }
12
13 if (!cfgs.children().find { it.@name == 'default' } ) {
14 println "adding default config"
15 cfgs.appendNode {
16 conf(name:"default")
17 }
18 }
19
20 groovy = ivy.dependencies.children().find { it.@org == 'org.codehaus.groovy' && it.@name == 'groovy' }
21 if (groovy) {
22 groovy.@conf = "*->default,optional"
23 println "Groovy ${groovy.@rev} conf changed to ${groovy.@conf}"
24 }
25
26 def sameConfMappings = ivy.dependencies.children().findAll { it.@conf in ['*->@','*->*'] }
27
28 println sameConfMappings.each {
29 it.@conf = "default->compile;%->@"
30 println "changing conf for ${it.@name} to ${it.@conf}"
31 }
32
33
34 def outputBuilder = new StreamingMarkupBuilder()
35 new File('ivy.xml').write( XmlUtil.serialize( outputBuilder.bind { mkp.yield ivy }).replaceAll('>','>'))