Here's a patch to optionally add the output directory to the compileSourceRoot. It looks in thams for the plugin for a "destdir" param, else uses the default output directory.
To use:
.....
<configs>
<config>
<plugin>org.xdoclet.plugin.qtags.impl
.QTagImplPlugin</plugin>
<params>
<destdir>${basedir}/target/src/main/java</destdir>
</params>
<includes><include>**/*.java</include></includes>
<addSourceRoot>true</addSourceRoot>
</config>
<config>
<plugin>org.xdoclet.plugin.qtags.impl.QTagLibraryPlugin</plugin>
<params>
<destdir>${basedir}/target/src/main/java</destdir>
<packagereplace>org.xdoclet.plugin.keel.qtags</packagereplace>
</params>
<includes><include>**/*.java</include></includes>
<addSourceRoot>true</addSourceRoot>
</config>
....
I had to change the version of the jelly tags JAR in the POM. Also, in the xdoclet2 POM, the qtags JAR version is not dwnloadable (POM does not exist), so I had to change that to qdox-1.6-SNAPSHOT.
I am also attaching a parent POM to go in the xdoclet-plugins base directory. I still have no clue why the xdoclet-plugin-plugin will not run from maven2-xdoclet2-plugin, but works fine from maven-antrun-plugin. Also, the "namespace" property needs to be provided as a property, doesn't seem to work, I have posted a message on the Maven list (for now hardcoded "yournamespace"). Finally, the plugin dependencies seem to need to be duplicated in the parent POM as well as the module POM. Anyway, a starting point...but needs more work.
<params>
<destdir>${basedir}/target/src/main/java</destdir>
</params>
<includes><include>**/*.java</include></includes>
<addSourceRoot>true</addSourceRoot>
</config>
<config>
<plugin>org.xdoclet.plugin.qtags.impl.QTagLibraryPlugin</plugin>
<params>
<destdir>${basedir}/target/src/main/java</destdir>
<packagereplace>org.xdoclet.plugin.keel.qtags</packagereplace>
</params>
<includes><include>**/*.java</include></includes>
<addSourceRoot>true</addSourceRoot>
</config>
....
I had to change the version of the jelly tags JAR in the POM. Also, in the xdoclet2 POM, the qtags JAR version is not dwnloadable (POM does not exist), so I had to change that to qdox-1.6-SNAPSHOT.
I am also attaching a parent POM to go in the xdoclet-plugins base directory. I still have no clue why the xdoclet-plugin-plugin will not run from maven2-xdoclet2-plugin, but works fine from maven-antrun-plugin. Also, the "namespace" property needs to be provided as a property, doesn't seem to work, I have posted a message on the Maven list (for now hardcoded "yournamespace"). Finally, the plugin dependencies seem to need to be duplicated in the parent POM as well as the module POM. Anyway, a starting point...but needs more work.
Index: pom.xml
===================================================================
RCS file: /home/projects/xdoclet/scm/maven2-plugin/pom.xml,v
retrieving revision 1.2
diff -u -r1.2 pom.xml
--- pom.xml 23 Dec 2005 01:32:38 -0000 1.2
+++ pom.xml 29 Dec 2005 17:52:27 -0000
@@ -43,7 +43,7 @@
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly-tags-xml</artifactId>
- <version>20050823.222913</version>
+ <version>1.0</version>
<scope>runtime</scope>
</dependency>
Index: src/main/java/org/codehaus/xdoclet/Config.java
===================================================================
RCS file:
/home/projects/xdoclet/scm/maven2-plugin/src/main/java/org/codehaus/xdoclet/Config.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Config.java
--- src/main/java/org/codehaus/xdoclet/Config.java 23 Dec 2005 00:44:41
-0000 1.1.1.1
+++ src/main/java/org/codehaus/xdoclet/Config.java 29 Dec 2005 17:52:27
-0000
@@ -16,6 +16,7 @@
private Set excludes = new HashSet();
private String encoding = System.getProperty("file.encoding");
private Map params = new HashMap();
+ private boolean addSourceRoot = false;
public String getPlugin() {
return plugin;
@@ -57,12 +58,21 @@
this.params = params;
}
+ public boolean isAddSourceRoot() {
+ return addSourceRoot;
+ }
+
+ public void setAddSourceRoot(boolean addSourceRoot) {
+ this.addSourceRoot = addSourceRoot;
+ }
+
public String toString() {
return "Config{" +
"plugin='" + plugin + '\'' +
", includes=" + includes +
", excludes=" + excludes +
", encoding='" + encoding + '\'' +
+ ", addSourceRoot='" + addSourceRoot + '\'' +
", params=" + params +
'}';
}
Index: src/main/java/org/codehaus/xdoclet/XDocletMojo.java
===================================================================
RCS file:
/home/projects/xdoclet/scm/maven2-plugin/src/main/java/org/codehaus/xdoclet/XDocletMojo.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 XDocletMojo.java
--- src/main/java/org/codehaus/xdoclet/XDocletMojo.java 23 Dec 2005 00:44:41
-0000 1.1.1.1
+++ src/main/java/org/codehaus/xdoclet/XDocletMojo.java 29 Dec 2005 17:52:27
-0000
@@ -57,7 +57,7 @@
* @required
*/
private List configs = new LinkedList();
-
+
public MavenProject getProject() {
return project;
}
@@ -101,6 +101,14 @@
} catch (RuntimeException e) {
throw new MojoFailureException(e.getMessage());
}
+ if (config.isAddSourceRoot()) {
+ String addedSourceRoot = resolveOutputDir(config,
outputDir);
+ if ( project != null )
+ {
+ getLog().info("Adding " + addedSourceRoot + " to
compiler path");
+ project.addCompileSourceRoot(addedSourceRoot);
+ }
+ }
}
}
final Resource resource = new Resource();
@@ -108,6 +116,23 @@
resource.setDirectory(outputDir);
//resource.addInclude("* * / *.xml");
project.addResource(resource);
+ }
+
+ private String resolveOutputDir(Config config, String outputDir) {
+ String sourceRoot = outputDir;
+ Map params = config.getParams();
+ if (params != null) {
+ String destDir = null;;
+ try {
+ destDir = (String)params.get("destdir");
+ } catch (RuntimeException e) {
+ // ignore ....
+ }
+ if (destDir != null) {
+ sourceRoot = destDir;
+ }
+ }
+ return sourceRoot;
}
private File getSourceRoot() {
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>xdoclet-plugins</artifactId> <!--<groupId>org.codehaus.xdoclet-plugin</groupId>--> <groupId>xdoclet-plugins</groupId> <packaging>pom</packaging> <name>XDoclet2 Plugin Parent POM</name> <version>1.0.4-SNAPSHOT</version> <inceptionYear>2005</inceptionYear> <build> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ssh-external</artifactId> <version>1.0-alpha-5</version> </extension> </extensions> <resources> <resource> <directory>${pom.build.sourceDirectory}</directory> <includes> <include>**/*.jelly</include> <include>**/*.vm</include> <include>**/*.xml</include> <include>**/*.dtd</include> <include>**/*.xsd</include> <include>**/*.png</include> <include>**/*.jpg</include> <include>**/*.gif</include> </includes> </resource> </resources> <testResources> <testResource> <directory>${pom.build.testSourceDirectory}</directory> <includes> <include>**/*.java</include> <include>**/*.xml</include> <include>**/*.vm</include> <include>**/*.tld</include> <include>**/*.properties</include> <include>**/*.confluence</include> </includes> </testResource> </testResources> <pluginManagement> <plugins> <plugin> <groupId>xdoclet</groupId> <artifactId>maven2-xdoclet2-plugin</artifactId> <version>2.0.5-SNAPSHOT</version> <inherited>true</inherited> <dependencies> <dependency> <groupId>xdoclet-plugins</groupId> <artifactId>xdoclet-plugin-qtags</artifactId> <version>1.0.3</version> </dependency> <dependency> <groupId>xdoclet-plugins</groupId> <artifactId>xdoclet-plugin-plugin</artifactId> <version>1.0.3</version> </dependency> </dependencies> <configuration> <configs> <config> <plugin>org.xdoclet.plugin.qtags.impl.QTagImplPlugin</plugin> <params> <destdir>${basedir}/target/src/main/java</destdir> </params> <includes><include>**/*.java</include></includes> <addSourceRoot>true</addSourceRoot> </config> <config> <plugin>org.xdoclet.plugin.qtags.impl.QTagLibraryPlugin</plugin> <params> <destdir>${basedir}/target/src/main/java</destdir> <packagereplace>org.xdoclet.plugin.yournamespace.qtags</packagereplace> </params> <includes><include>**/*.java</include></includes> <addSourceRoot>true</addSourceRoot> </config> <config> <plugin>org.xdoclet.plugin.qtags.xdoc.QTagXDocPlugin</plugin> <params> <destdir>${basedir}/target/generated-xdocs</destdir> <namespace>yournamespace</namespace> </params> <includes><include>**/*.java</include></includes> </config> <config> <plugin>org.xdoclet.plugin.qtags.confluence.QTagConfluencePlugin</plugin> <params> <destdir>${basedir}/target/confluence</destdir> <namespace>yournamespace</namespace> </params> <includes><include>**/*.java</include></includes> </config> <!-- <config> <plugin>org.xdoclet.plugin.plugin.PluginPlugin</plugin> <params> <basedir>${basedir}</basedir> <destdir>${basedir}/target/plugindoc</destdir> </params> </config> --> </configs> </configuration> <executions> <execution> <goals> <goal>xdoclet</goal> </goals> </execution> </executions> </plugin> <!-- <plugin> <artifactId>maven-antrun-plugin</artifactId> <inherited>true</inherited> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <path id="xdoclet.task.classpath"> <pathelement location="${basedir}/target/classes" /> <path refid="maven.dependency.classpath" /> </path> <taskdef name="xdoclet" classname="org.xdoclet.ant.XDocletTask" classpathref="xdoclet.task.classpath" /> <xdoclet verbose="true"> <fileset dir="${pom.build.sourceDirectory}"> <include name="**/*.java" /> </fileset> <component classname="org.xdoclet.plugin.qtags.impl.QTagImplPlugin" destdir="${basedir}/target/src/main/java"/> <component classname="org.xdoclet.plugin.qtags.impl.QTagLibraryPlugin" destdir="${basedir}/target/src/main/java" packagereplace="org.xdoclet.plugin.yournamespace.qtags" /> <component classname="org.xdoclet.plugin.qtags.xdoc.QTagXDocPlugin" destdir="${basedir}/target/generated-xdocs" namespace="yournamespace" /> <component classname="org.xdoclet.plugin.qtags.confluence.QTagConfluencePlugin" destdir="${basedir}/target/confluence" namespace="yournamespace" /> <component classname="org.xdoclet.plugin.plugin.PluginPlugin" basedir="${basedir}" destdir="${basedir}/target/plugindoc" /> </xdoclet> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>xdoclet</groupId> <artifactId>maven2-xdoclet2-plugin</artifactId> <version>2.0.5-SNAPSHOT</version> </dependency> <dependency> <groupId>xdoclet-plugins</groupId> <artifactId>xdoclet-plugin-qtags</artifactId> <version>1.0.3</version> </dependency> <dependency> <groupId>xdoclet-plugins</groupId> <artifactId>xdoclet-plugin-plugin</artifactId> <version>1.0.3</version> </dependency> </dependencies> </plugin> -->
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>xdoclet</groupId>
<artifactId>maven2-xdoclet2-plugin</artifactId>
<version>2.0.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xdoclet-plugins</groupId>
<artifactId>xdoclet-plugin-qtags</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>xdoclet-plugins</groupId>
<artifactId>xdoclet-plugin-plugin</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>dist.codehaus.org</id>
<layout>legacy</layout>
<url>http://dist.codehaus.org</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>codehaus</id>
<name>beaver.codehaus.org</name>
<url>scpexe://beaver.codehaus.org:/dist/</url>
</repository>
<site>
<id>codehaus</id>
<name>codehaus</name>
<url>scp://beaver.codehaus.org/home/projects/xdoclet/public_html/maven</url>
</site>
</distributionManagement>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>xdoclet-plugins</groupId> <artifactId>xdoclet-plugins</artifactId> <version>1.0.4-SNAPSHOT</version> </parent> <artifactId>xdoclet-plugin-test</artifactId> <!--<groupId>org.codehaus.xdoclet</groupId>--> <groupId>xdoclet-plugins</groupId> <packaging>jar</packaging> <name>XDoclet2 Test Plugin</name> <version>0.0.1</version> <inceptionYear>2005</inceptionYear> <properties> <namespace>test</namespace> </properties> <build> <sourceDirectory>${basedir}/src/main/java</sourceDirectory> <plugins> <plugin> <groupId>xdoclet</groupId> <artifactId>maven2-xdoclet2-plugin</artifactId> <version>2.0.5-SNAPSHOT</version> <dependencies> <dependency> <groupId>xdoclet-plugins</groupId> <artifactId>xdoclet-plugin-qtags</artifactId> <version>1.0.3</version> </dependency> <dependency> <groupId>xdoclet-plugins</groupId> <artifactId>xdoclet-plugin-plugin</artifactId> <version>1.0.3</version> </dependency> </dependencies> </plugin> <!-- <plugin> <artifactId>maven-antrun-plugin</artifactId> </plugin> --> </plugins> </build> </project>
