File pom = new File( source.getLocation() );
source = new FileModelSource( new File( pom.getPath().replaceFirst( "[.]tesla[.]", "" ) ) );
((Map)options).put( ModelProcessor.SOURCE, source );
ModelReader reader = manager.getReaderFor(options);
Model model = reader.read(source.getInputStream(), options);
MavenXpp3Writer xmlWriter = new MavenXpp3Writer();
StringWriter xml = new StringWriter();
xmlWriter.write( xml, model );
FileUtils.fileWrite( pom, xml.toString() );
// dump pom if filename is given via the pom properties
String dump = model.getProperties().getProperty( "tesla.dump.pom" );
if ( dump == null )
{
// just nice to dump the pom.xml via commandline switch
dump = System.getProperty( "tesla.dump.pom" );
}
if ( dump != null )
{
File dumpPom = new File( pom.getParentFile(), dump );
if ( !dumpPom.exists() || ! FileUtils.fileRead( dumpPom ).equals( xml.toString() ) )
{
dumpPom.setWritable( true );
FileUtils.fileWrite( dumpPom, xml.toString() );
if ( "true".equals( model.getProperties().getProperty( "tesla.dump.readonly" ) ) )
{
dumpPom.setReadOnly();
}
}
}
model.setPomFile(pom);
return model;
}
else {
ModelReader reader = manager.getReaderFor(options);
return reader.read(input, options);
}
}