Last active
December 13, 2015 21:58
-
-
Save arthurtsang/4981229 to your computer and use it in GitHub Desktop.
Custom Maven Report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Mojo( name="gemini", requiresDependencyResolution = ResolutionScope.COMPILE ) | |
@Execute( phase = LifecyclePhase.GENERATE_SOURCES ) | |
public class GeminiDoc extends AbstractMavenReport { | |
@Component | |
protected MavenProject project; | |
@Parameter( defaultValue = "${reactorProjects}", readonly = true) | |
protected List<MavenProject> reactorProjects; | |
@Override | |
protected Renderer getSiteRenderer() { | |
return null; | |
} | |
@Override | |
protected String getOutputDirectory() { | |
return null; | |
} | |
@Override | |
protected MavenProject getProject() { | |
return project; | |
} | |
protected boolean isAggregator(){ return false; } | |
@Override | |
public boolean canGenerateReport() { | |
return ( project.getModules().size() == 0 ); | |
} | |
@Override | |
/* Abused by Maven site plugin, a '/' denotes a directory path! | |
* http://4thline.org/articles/Howto%20write%20a%20Maven%20report%20plugin.html | |
*/ | |
public String getOutputName() { | |
// The site plugin will make the directory (and regognize the '/') in the path, | |
// it will also append '.html' onto the filename and there is nothing (yes, I tried) | |
// you can do about that. Feast your eyes on the code that instantiates | |
// this (good luck finding it): | |
// org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext | |
return "geminidocs/index"; | |
} | |
@Override | |
public String getName(Locale locale) { | |
return "Gemini Dependencies"; | |
} | |
@Override | |
public String getDescription(Locale locale) { | |
return "Gemini Dependencies"; | |
} | |
@Override | |
protected void executeReport(Locale locale) throws MavenReportException { | |
Sink sink = getSink(); | |
sink.head(); | |
sink.title(); | |
sink.text("My Report"); | |
sink.title_(); | |
sink.head_(); | |
sink.body(); | |
if( isAggregator() ) | |
sink.rawText("yes, aggregated"); | |
else | |
sink.rawText("RAW TEXT!"); | |
sink.body_(); | |
sink.flush(); | |
sink.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment