mirror of
https://github.com/apache/maven.git
synced 2025-02-22 18:04:52 +00:00
o Code from netbeans integration that will write out changes to a model and preserve the existing structure for the most part.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@493817 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d47e7c221c
commit
ed381aec0d
@ -22,10 +22,16 @@
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.Format;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.InputStream;
|
||||
import java.nio.channels.FileLock;
|
||||
|
||||
//TODO: turn this into a component
|
||||
|
||||
@ -75,4 +81,63 @@ public static void write( Writer w,
|
||||
|
||||
writer.write( newModel, doc, w, format );
|
||||
}
|
||||
|
||||
/*
|
||||
public static void writePomModel( FileObject pom,
|
||||
Model newModel )
|
||||
throws IOException
|
||||
{
|
||||
InputStream inStr = null;
|
||||
|
||||
FileLock lock = null;
|
||||
|
||||
OutputStreamWriter outStr = null;
|
||||
|
||||
try
|
||||
{
|
||||
inStr = pom.getInputStream();
|
||||
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
|
||||
Document doc = builder.build( inStr );
|
||||
|
||||
inStr.close();
|
||||
|
||||
inStr = null;
|
||||
|
||||
lock = pom.lock();
|
||||
|
||||
MavenJDOMWriter writer = new MavenJDOMWriter();
|
||||
|
||||
String encoding = newModel.getModelEncoding() != null ? newModel.getModelEncoding() : "UTF-8";
|
||||
|
||||
outStr = new OutputStreamWriter( pom.getOutputStream( lock ), encoding );
|
||||
|
||||
Format form = Format.getRawFormat().setEncoding( encoding );
|
||||
|
||||
writer.write( newModel, doc, outStr, form );
|
||||
|
||||
outStr.close();
|
||||
|
||||
outStr = null;
|
||||
}
|
||||
catch ( JDOMException exc )
|
||||
{
|
||||
exc.printStackTrace();
|
||||
throw (IOException) new IOException( "Cannot parse the POM by JDOM." ).initCause( exc );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( inStr );
|
||||
|
||||
IOUtil.close( outStr );
|
||||
|
||||
if ( lock != null )
|
||||
{
|
||||
lock.releaseLock();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user