You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/12/29 17:58:49 UTC

cvs commit: maven-plugins Fix2.java

jvanzyl     2003/12/29 08:58:49

  Added:       .        Fix2.java
  Log:
  o little dom4j tool to flip "id" to "artifactId" at the project level.
  
  Revision  Changes    Path
  1.1                  maven-plugins/Fix2.java
  
  Index: Fix2.java
  ===================================================================
  import org.dom4j.*;
  import org.dom4j.io.*;
  import java.io.*;
  import java.util.*;
  
  public class Fix2
  {
      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 id = root.element( "id" );
          
          if ( id != null )
          {
              System.out.println( id.getName() );
              
              id.setName( "artifactId" );
          }
          
          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 );
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org