use of org.apache.maven.model.io.xpp3.MavenXpp3Writer in project che by eclipse.
the class EffectivePomWriter method writeEffectivePom.
/**
* method from org.apache.maven.plugins.help.EffectivePomMojo
* Method for writing the effective pom informations of the current build.
*
* @param project the project of the current build, not null.
* @param writer the XML writer , not null, not null.
* @throws MojoExecutionException if any
*/
private static void writeEffectivePom(MavenProject project, XMLWriter writer) throws MojoExecutionException {
Model pom = project.getModel();
cleanModel(pom);
String effectivePom;
StringWriter sWriter = new StringWriter();
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(sWriter, pom);
} catch (IOException e) {
throw new MojoExecutionException("Cannot serialize POM to XML.", e);
}
effectivePom = addMavenNamespace(sWriter.toString(), true);
writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");
writer.writeMarkup(effectivePom);
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Writer in project intellij-community by JetBrains.
the class MavenEffectivePomDumper method writeEffectivePom.
/**
* org.apache.maven.plugins.help.EffectivePomMojo#writeEffectivePom
*/
private static void writeEffectivePom(MavenProject project, XMLWriter writer) throws MojoExecutionException {
Model pom = project.getModel();
cleanModel(pom);
String effectivePom;
StringWriter sWriter = new StringWriter();
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(sWriter, pom);
} catch (IOException e) {
throw new MojoExecutionException("Cannot serialize POM to XML.", e);
}
effectivePom = addMavenNamespace(sWriter.toString(), true);
writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");
writer.writeMarkup(effectivePom);
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Writer in project maven-plugins by apache.
the class DeployFileMojo method generatePomFile.
/**
* Generates a minimal POM from the user-supplied artifact information.
*
* @return The path to the generated POM file, never <code>null</code>.
* @throws MojoExecutionException If the generation failed.
*/
private File generatePomFile() throws MojoExecutionException {
Model model = generateModel();
Writer fw = null;
try {
File tempFile = File.createTempFile("mvndeploy", ".pom");
tempFile.deleteOnExit();
fw = WriterFactory.newXmlWriter(tempFile);
new MavenXpp3Writer().write(fw, model);
fw.close();
fw = null;
return tempFile;
} catch (IOException e) {
throw new MojoExecutionException("Error writing temporary pom file: " + e.getMessage(), e);
} finally {
IOUtil.close(fw);
}
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Writer in project maven-plugins by apache.
the class InstallFileMojo method generatePomFile.
/**
* Generates a (temporary) POM file from the plugin configuration. It's the responsibility of the caller to delete
* the generated file when no longer needed.
*
* @return The path to the generated POM file, never <code>null</code>.
* @throws MojoExecutionException If the POM file could not be generated.
*/
private File generatePomFile() throws MojoExecutionException {
Model model = generateModel();
Writer writer = null;
try {
File pomFile = File.createTempFile("mvninstall", ".pom");
writer = WriterFactory.newXmlWriter(pomFile);
new MavenXpp3Writer().write(writer, model);
writer.close();
writer = null;
return pomFile;
} catch (IOException e) {
throw new MojoExecutionException("Error writing temporary POM file: " + e.getMessage(), e);
} finally {
IOUtil.close(writer);
}
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Writer in project maven-plugins by apache.
the class EffectivePomMojo method writeEffectivePom.
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
/**
* Method for writing the effective pom informations of the current build.
*
* @param project the project of the current build, not null.
* @param writer the XML writer , not null, not null.
* @throws MojoExecutionException if any
*/
private static void writeEffectivePom(MavenProject project, XMLWriter writer) throws MojoExecutionException {
Model pom = project.getModel();
cleanModel(pom);
String effectivePom;
StringWriter sWriter = new StringWriter();
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(sWriter, pom);
} catch (IOException e) {
throw new MojoExecutionException("Cannot serialize POM to XML.", e);
}
effectivePom = addMavenNamespace(sWriter.toString(), true);
writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");
writer.writeMarkup(effectivePom);
}
Aggregations