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 maven-plugins by apache.
the class PdfMojo method copyResources.
/**
* Parse the decoration model to find the skin artifact and copy its resources to the output dir.
*
* @param locale not null
* @throws MojoExecutionException if any
* @see #getDefaultDecorationModel()
*/
private void copyResources(Locale locale) throws MojoExecutionException {
final DecorationModel decorationModel = getDefaultDecorationModel();
if (decorationModel == null) {
return;
}
File skinFile;
try {
skinFile = siteTool.getSkinArtifactFromRepository(localRepository, project.getRemoteArtifactRepositories(), decorationModel).getFile();
} catch (SiteToolException e) {
throw new MojoExecutionException("SiteToolException: " + e.getMessage(), e);
}
if (skinFile == null) {
return;
}
if (getLog().isDebugEnabled()) {
getLog().debug("Copy resources from skin artifact: '" + skinFile + "'...");
}
try {
final SiteRenderingContext context = siteRenderer.createContextForSkin(skinFile, new HashMap<String, Object>(2), decorationModel, project.getName(), locale);
context.addSiteDirectory(new File(siteDirectory, locale.getLanguage()));
siteRenderer.copyResources(context, workingDirectory);
} catch (IOException e) {
throw new MojoExecutionException("IOException: " + e.getMessage(), e);
} catch (RendererException e) {
throw new MojoExecutionException("RendererException: " + e.getMessage(), e);
}
}
use of org.apache.maven.doxia.site.decoration.DecorationModel in project maven-plugins by apache.
the class DocumentModelBuilderTest method getDecorationModelFromFile.
private DecorationModel getDecorationModelFromFile(File descriptorFile) throws IOException, XmlPullParserException {
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(descriptorFile);
final DecorationModel decorationModel = new DecorationXpp3Reader().read(reader);
reader.close();
reader = null;
return decorationModel;
} finally {
IOUtil.close(reader);
}
}
use of org.apache.maven.doxia.site.decoration.DecorationModel in project maven-plugins by apache.
the class DocumentModelBuilderTest method testGetDocumentModelWithSiteDescriptor.
/**
* Test of getDocumentModel method, of class DocumentModelBuilder.
* @throws Exception if something happens.
*/
public void testGetDocumentModelWithSiteDescriptor() throws Exception {
File descriptorFile = new File(testBaseDir() + "src/site/", "model_builder_site.xml");
DecorationModel dModel = getDecorationModelFromFile(descriptorFile);
DocumentModel model = new DocumentModelBuilder(new ModelBuilderMavenProjectStub(), dModel).getDocumentModel();
DocumentTOC toc = model.getToc();
assertEquals(1, toc.getItems().size());
assertEquals("Intro", toc.getItems().get(0).getName());
assertEquals("index.html", toc.getItems().get(0).getRef());
}
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);
}
}
Aggregations