franz see <[EMAIL PROTECTED]> writes:
> Good day to you, Arnaud,
>
Thanks fro your answer Franz,
That's actually the way I did it. Here is the mojo code:
/*______________________________________________________________________________
*
* Copyright (C) 2006 Arnaud Bailly / OQube
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*
* email: [EMAIL PROTECTED]
* creation: Thu Sep 21 2006
*/
package oqube.muse.maven;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import oqube.muse.literate.LiterateMuse;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.MavenProject;
/**
* This plugin generates source files and documentation from literate sources in
* muse format. This plugin executes normally at the beginning of a lifecycle
* (phase <code>generate-sources</code>) and does the following:
* <ul>
* <li>Parse literate muse files found in the <code>source</code>
parameter,</li>
* <li>Generate corresponding source files and store them in the
* <code>sourceOutput</code> parameter,</li>
* <li>Generate muse files from literate source and store them in the
* <code>docOutput</code> parameter.</li>
* </ul>
* This plugin is a simple wrapper around
* [EMAIL PROTECTED] oqube.muse.literate.LiterateMuse} class.
*
* @author [EMAIL PROTECTED]
* @version $Id: LiterateMuseMojo.java 80 2007-01-29 08:52:36Z /CN=nono $
* @goal publish
* @phase generate-sources
*/
public class LiterateMuseMojo extends AbstractMojo {
/**
* The directory containing literate muse source to parse.
*
* @parameter expression="${basedir}/src/site/muse"
* @required
*/
private File source;
/**
* Exclusion patterns. All files (and directories) from source directory that
* matches one of these patterns are excluded.
*
* @parameter
*/
private List excludes;
/**
* Output directory for generated sources.
*
* @parameter
expression="${project.build.directory}/generated-sources/literate"
*/
private File sourceOutput;
/**
* Output directory for generated documentation. This parameter defaults to
* null as the input file themselves may be used for documentation generation.
* If documentation format is different then this paramater shoudl be set
* accordingly.
*
* @parameter
*/
private File docOutput = null;
/**
* The generated documentation format to use. If this is null (the default),
* then no documentation is generated.
*
* @parameter
*/
private String format;
/**
* Name of header file to prepend to each generated source file.
*
* @parameter
*/
private String header;
/**
* Name of footer file to append to each generated source file.
*
* @parameter
*/
private String footer;
/**
* If true, then source files are aggregated over the whole set of input
* files. This allows splitting a source file over several documents and
* producing a single source.
*
* @parameter expression="false"
*/
private boolean multifile;
/**
* The current project object.
*
* @parameter expression="${project}"
* @required
*/
private MavenProject project;
/**
* The encoding used for generating source and document files.
*
* @parameter
*/
private String outputEncoding;
/**
* The encoding used for reading literate sources.
*
* @parameter
*/
private String inputEncoding;
/**
* The inclusion filter for fragments to generate. This pattern can be used to
* control which fragments get their source files generated by the mojo: A
* fragment is generated if it is <em>included</em> and it is not
* <em>excluded</em>.
*
* @parameter expression=".*"
*/
private String filterIn;
/**
* The exclusion filter for fragments to generate. This pattern can be used to
* control which fragments get their source files generated by the mojo. This
* is very useful for distinguishing test and source files.
*
* @parameter expression="^$"
*/
private String filterOut;
/**
* Tells whether processed sources are test sources or standard sources.
*
* @parameter expression="false"
*/
private boolean testSource;
/**
* A flag for literate publishing that says whether missing referenced
* fragments should be ignored or not.
*
* @parameter expression="false"
*/
private boolean lenient;
public void execute() throws MojoExecutionException, MojoFailureException {
// configuring publishing system
LiterateMuse muse = new LiterateMuse();
muse.setHeader(header);
muse.setFooter(footer);
muse.setMultifile(multifile);
muse.setSourceOutputDirectory(sourceOutput);
muse.setOutputEncoding(outputEncoding);
muse.setDocOutputDirectory(docOutput);
muse.setInputEncoding(inputEncoding);
muse.setFormat(format);
muse.setExcludes(excludes);
muse.setLog(new LogWrapper(getLog()));
muse.setInclude(Pattern.compile(filterIn));
muse.setExclude(Pattern.compile(filterOut));
muse.setLenient(lenient);
List l = new ArrayList();
l.add(source);
muse.setFiles(l);
// run
try {
muse.run();
// add generated sources to project's source path or test source path
if (project != null)
if (!testSource)
project.addCompileSourceRoot(sourceOutput.getAbsolutePath());
else
project.addTestCompileSourceRoot(sourceOutput.getAbsolutePath());
} catch (Exception e) {
getLog().error(e);
}
}
/**
* For testing purpose only.
*
* @param proj
*/
void setProject(MavenProject proj) {
this.project = project;
}
}
--
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]