use of org.apache.maven.doxia.site.decoration.DecorationModel in project maven-plugins by apache.
the class CheckstyleReportTest method renderer.
/**
* Renderer the sink from the report mojo.
*
* @param mojo not null
* @param outputHtml not null
* @throws RendererException if any
* @throws IOException if any
*/
private void renderer(CheckstyleReport mojo, File outputHtml) throws RendererException, Exception {
Writer writer = null;
SiteRenderingContext context = new SiteRenderingContext();
context.setDecoration(new DecorationModel());
context.setTemplateName("org/apache/maven/doxia/siterenderer/resources/default-site.vm");
context.setLocale(Locale.ENGLISH);
try {
outputHtml.getParentFile().mkdirs();
writer = WriterFactory.newXmlWriter(outputHtml);
mojo.execute();
writer.close();
writer = null;
} finally {
IOUtil.close(writer);
}
}
use of org.apache.maven.doxia.site.decoration.DecorationModel in project maven-plugins by apache.
the class AbstractPmdReportTest method renderer.
/**
* Renderer the sink from the report mojo.
*
* @param mojo not null
* @param outputHtml not null
* @throws RendererException if any
* @throws IOException if any
*/
protected void renderer(AbstractPmdReport mojo, File outputHtml) throws RendererException, IOException {
SiteRenderingContext context = new SiteRenderingContext();
context.setDecoration(new DecorationModel());
context.setTemplateName("org/apache/maven/doxia/siterenderer/resources/default-site.vm");
context.setLocale(Locale.ENGLISH);
outputHtml.getParentFile().mkdirs();
try (Writer writer = WriterFactory.newXmlWriter(outputHtml)) {
mojo.getSiteRenderer().generateDocument(writer, (SiteRendererSink) mojo.getSink(), context);
}
}
use of org.apache.maven.doxia.site.decoration.DecorationModel in project webservices-axiom by apache.
the class PostProcessMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
DecorationModel decorationModel;
try {
decorationModel = siteTool.getDecorationModel(siteDirectory, siteTool.getSiteLocales(locales).get(0), project, reactorProjects, localRepository, repositories);
} catch (SiteToolException ex) {
throw new MojoExecutionException("SiteToolException: " + ex.getMessage(), ex);
}
String head = decorationModel.getBody().getHead();
DirectoryScanner ds = new DirectoryScanner();
ds.setIncludes(new String[] { "**/*.html" });
ds.setBasedir(javadocDirectory);
ds.scan();
for (String relativePath : ds.getIncludedFiles()) {
File file = new File(javadocDirectory, relativePath);
File tmpFile = new File(javadocDirectory, relativePath + ".tmp");
file.renameTo(tmpFile);
try {
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(tmpFile), "UTF-8"));
try {
PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
try {
String line;
while ((line = in.readLine()) != null) {
if (line.equals("</head>")) {
out.println(head);
}
out.println(line);
}
} finally {
out.close();
}
} finally {
in.close();
}
} catch (IOException ex) {
throw new MojoExecutionException("Failed to process " + relativePath + ": " + ex.getMessage(), ex);
}
tmpFile.delete();
}
}
use of org.apache.maven.doxia.site.decoration.DecorationModel in project maven-plugins by apache.
the class AbstractChangeLogReportTest method renderer.
/**
* Renderer the sink from the report mojo.
*
* @param mojo not null
* @param outputHtml not null
* @throws RendererException if any
* @throws IOException if any
*/
protected void renderer(ChangeLogReport mojo, File outputHtml) throws RendererException, IOException {
Writer writer = null;
SiteRenderingContext context = new SiteRenderingContext();
context.setDecoration(new DecorationModel());
context.setTemplateName("org/apache/maven/doxia/siterenderer/resources/default-site.vm");
try {
outputHtml.getParentFile().mkdirs();
writer = WriterFactory.newXmlWriter(outputHtml);
mojo.getSiteRenderer().generateDocument(writer, (SiteRendererSink) mojo.getSink(), context);
writer.close();
writer = null;
} finally {
IOUtil.close(writer);
}
}
use of org.apache.maven.doxia.site.decoration.DecorationModel in project maven-plugins by apache.
the class PdfMojo method getDefaultDecorationModel.
/**
* @return the DecorationModel instance from <code>site.xml</code>
* @throws MojoExecutionException if any
*/
private DecorationModel getDefaultDecorationModel() throws MojoExecutionException {
if (this.defaultDecorationModel == null) {
final Locale locale = getDefaultLocale();
final File descriptorFile = siteTool.getSiteDescriptor(siteDirectory, locale);
DecorationModel decoration = null;
if (descriptorFile.exists()) {
XmlStreamReader reader = null;
try {
reader = new XmlStreamReader(descriptorFile);
String siteDescriptorContent = IOUtil.toString(reader);
reader.close();
reader = null;
siteDescriptorContent = siteTool.getInterpolatedSiteDescriptorContent(new HashMap<String, String>(2), project, siteDescriptorContent);
decoration = new DecorationXpp3Reader().read(new StringReader(siteDescriptorContent));
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Error parsing site descriptor", e);
} catch (IOException e) {
throw new MojoExecutionException("Error reading site descriptor", e);
} catch (SiteToolException e) {
throw new MojoExecutionException("Error when interpoling site descriptor", e);
} finally {
IOUtil.close(reader);
}
}
this.defaultDecorationModel = decoration;
}
return this.defaultDecorationModel;
}
Aggregations