o little dom4j thingy to flip <id/> to <artifactId/> and <groupId/>
If you see any problems I'll fix the script and run it again. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d3afe92724
commit
ff31f37133
81
Fix.java
Normal file
81
Fix.java
Normal file
@ -0,0 +1,81 @@
|
||||
import org.dom4j.*;
|
||||
import org.dom4j.io.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Fix
|
||||
{
|
||||
public static void main( String[] args )
|
||||
throws Exception
|
||||
{
|
||||
SAXReader r = new SAXReader();
|
||||
|
||||
Document d = r.read( new FileReader( args[0] ) );
|
||||
|
||||
Element root = d.getRootElement();
|
||||
|
||||
Element deps = root.element( "dependencies" );
|
||||
|
||||
for ( Iterator i = deps.elementIterator( "dependency" ); i.hasNext(); )
|
||||
{
|
||||
Element e = (Element) i.next();
|
||||
|
||||
Element id = e.element( "id" );
|
||||
|
||||
if ( id != null )
|
||||
{
|
||||
String text = id.getText();
|
||||
|
||||
id.detach();
|
||||
|
||||
e.addElement( "groupId" ).addText( text );
|
||||
|
||||
e.addElement( "artifactId" ).addText( text );
|
||||
|
||||
Element v = e.element( "version" );
|
||||
|
||||
v.detach();
|
||||
|
||||
e.add( v );
|
||||
|
||||
Element u = e.element( "url" );
|
||||
|
||||
if ( u != null )
|
||||
{
|
||||
u.detach();
|
||||
|
||||
e.add( u );
|
||||
}
|
||||
|
||||
Element p = e.element( "properties" );
|
||||
|
||||
if ( p != null )
|
||||
{
|
||||
p.detach();
|
||||
|
||||
e.add( p );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File f = new File( args[0] );
|
||||
|
||||
f.delete();
|
||||
|
||||
OutputStream os = new FileOutputStream( args[0] );
|
||||
|
||||
OutputFormat format = new OutputFormat();
|
||||
|
||||
format.setIndentSize( 2 );
|
||||
|
||||
format.setNewlines( true );
|
||||
|
||||
format.setTrimText( true );
|
||||
|
||||
XMLWriter writer = new XMLWriter( format );
|
||||
|
||||
writer.setOutputStream( os );
|
||||
|
||||
writer.write( d );
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user