> Did I oversee something? I'd really appreciate some guidance and
> examples so that I don't have to read trough the sources of several
> existing report plugins to find out how it works by myself.
Hello,
I fear that this may actually be the only way right now. Another
solution is providing a document reporting your efforts for
integration into maven's doc base ;-)
Anyway, here is a small example. HTH
/**
*
*/
package fr.lifl.fidl.maven;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import fr.lifl.fidl.FIDL;
import fr.lifl.fidl.idl3.impl.RootScope;
import fr.lifl.fidl.idl3.parser.ParseException;
import fr.lifl.parsing.LoggingParserListener;
/**
* A maven 2.0 plugin for generating images of the automata in a FIDL
* descriptor. This plugin is used in the <code>site</code> phase to generate
* HTML pages describing the specifications of each automaton in a given set of
* files.
*
*
* @author nono
* @goal fidl-graph
* @phase site
*/
public class GraphGeneratorMojo extends AbstractMavenReport {
/**
* The directory containing source code to parse.
*
* @parameter expression="${basedir}/src/main/fidl"
* @required
*/
private File sourceDir;
/**
* The list of source files to parse, relative to source directory.
*
* @parameter
* @required
*/
private List sources;
/**
* The list of directories to include for import resolution.
*
* @parameter
*/
private List includes;
/**
* The output directory.
*
* @parameter expression="${project.build.directory}/generated-sources/fidl"
* @required
*/
private File outputDirectory;
/**
* Format of graphical output. Defaults to png.
*
* @parameter expression="png"
*/
private String format = "png";
/**
* Generate automaton xml descriptor ?
* @parameter expression="false"
*/
private boolean auto = false;
/**
* <i>Maven Internal</i>: The Doxia Site Renderer.
*
* @component
*/
private Renderer siteRenderer;
/**
* <i>Maven Internal</i>: The Project descriptor.
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
/**
* @return Returns the auto.
*/
public boolean isAuto() {
return auto;
}
/**
* @param auto
* The auto to set.
*/
public void setAuto(boolean auto) {
this.auto = auto;
}
/**
* @return Returns the format.
*/
public String getFormat() {
return format;
}
/**
* @param format
* The format to set.
*/
public void setFormat(String format) {
this.format = format;
}
/*
* (non-Javadoc)
*
* @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
*/
protected String getOutputDirectory() {
return outputDirectory.getAbsolutePath();
}
/**
* @return Returns the siteRenderer.
*/
public Renderer getSiteRenderer() {
return siteRenderer;
}
protected MavenProject getProject() {
return project;
}
protected void executeReport(Locale arg0) throws MavenReportException {
/* configure parser */
FIDL fidl = new FIDL();
fidl.setIncludes(getIncludes());
fidl.setRoot(new RootScope());
LogWrapper wr = new LogWrapper(getLog());
fidl.addParserListener(new LoggingParserListener(wr));
/* create output */
if (!outputDirectory.exists())
outputDirectory.mkdirs();
/* loop over source files */
for (Iterator it = getSources().iterator(); it.hasNext();) {
/* get source file and check it */
String src = (String) it.next();
File f = new File(getSourceDir(), src);
if (!f.exists()) {
getLog().warn("Source file " + f.getPath() + " does not exist");
continue;
}
/* input into generator */
FileInputStream fis;
try {
fis = new FileInputStream(f);
getLog().info("Generating documentation from FIDL source " + f);
fidl.parse(fis, src);
} catch (IOException e) {
throw new MavenReportException("Error in opening file stream for " + f,
e);
} catch (ParseException e) {
throw new MavenReportException("Error in generating documentation for "
+ f, e);
}
}
Sink sink = getSink();
/* generate graphs pages */
GraphGenerator ggen = new GraphGenerator();
ggen.setOutputDir(outputDirectory);
ggen.setRoot(fidl.getRoot());
ggen.setLog(getLog());
ggen.setFormat(format);
ggen.setAuto(auto);
ggen.generate();
/* generate HTML pages */
FIDLHTMLGenerator html = new FIDLHTMLGenerator();
html.setOutputDir(outputDirectory);
html.setRoot(fidl.getRoot());
html.setFormat(format);
html.setLog(getLog());
try {
html.generate(sink);
} catch (IOException e) {
throw new MavenReportException("Error in generating html report", e);
}
}
public String getOutputName() {
return "fidl/index";
}
public String getName(Locale arg0) {
return "FIDL Graph report";
}
public String getDescription(Locale arg0) {
return "Generate graph and HTML summary for FIDL specification";
}
/**
* @return Returns the includes.
*/
public List getIncludes() {
return includes;
}
/**
* @param includes
* The includes to set.
*/
public void setIncludes(List includes) {
this.includes = includes;
}
/**
* @return Returns the sourceDir.
*/
public File getSourceDir() {
return sourceDir;
}
/**
* @param sourceDir
* The sourceDir to set.
*/
public void setSourceDir(File sourceDir) {
this.sourceDir = sourceDir;
}
/**
* @return Returns the sources.
*/
public List getSources() {
return sources;
}
/**
* @param sources
* The sources to set.
*/
public void setSources(List sources) {
this.sources = sources;
}
/**
* @param outputDirectory
* The outputDirectory to set.
*/
public void setOutputDirectory(File outputDirectory) {
this.outputDirectory = outputDirectory;
}
/**
* @param siteRenderer
* The siteRenderer to set.
*/
public void setSiteRenderer(Renderer siteRenderer) {
this.siteRenderer = siteRenderer;
}
/**
* For testing purpose only.
* @param project The project to set.
*/
public void setProject(MavenProject project) {
this.project = project;
}
}
Regards
--
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]