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