Maven 如何在项目中编译和运行自定义Doclet类?
我试图在编译时将所有类javadoc comment(最好是库网页类的子类)转储到.properties文件中,格式为Maven 如何在项目中编译和运行自定义Doclet类?,maven,maven-2,javadoc,maven-javadoc-plugin,doclet,Maven,Maven 2,Javadoc,Maven Javadoc Plugin,Doclet,我试图在编译时将所有类javadoc comment(最好是库网页类的子类)转储到.properties文件中,格式为classname=comment 到目前为止,我已经: 已创建doclet类SiteMapDoclet 该类被定义为扫描项目中的所有Javadoc并将它们转储到.properties文件中 在my pom.xml中添加了必要的配置以使其正常工作 版本:Java 1.6.0.21、Maven 2.2.1 问题: mvn站点返回: Embedded error: Error
classname=comment
到目前为止,我已经:
- 已创建doclet类
SiteMapDoclet
- 该类被定义为扫描项目中的所有Javadoc并将它们转储到.properties文件中
- 在my pom.xml中添加了必要的配置以使其正常工作
mvn站点
返回:
Embedded error: Error rendering Maven report:
Exit code: 1 - java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at us.ak.state.revenue.cssd.Personnel.utils.SiteMapDoclet.<clinit>(SiteMapDoclet.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
注意:${m2Repository}
定义为文件上方的属性,定义为
${env.USERPROFILE}/.m2/存储库
${bootClassPath}
定义为文件上方的属性,定义为
${env.JRE_6_HOME}\lib\rt.jar${env.JAVA_HOME}\lib\tools.jar代码>
如何修复NoClassDefFoundError
此外,我希望我的站点地图文件作为正常构建过程的一部分运行,
在编译之后
但在打包之前
我尝试在构建中定义它,但是没有创建javadoc,也没有看到Doclet的任何日志输出
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>build-siteMap-Descriptions</id>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
到配置部分,但这不起作用。您可以尝试将您的
作为插件依赖项:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<dependencies>
<dependency>
<groupId>us.ak.state.revenue.cssd</groupId>
<artifactId>CSSD-Web</artifactId>
<version>${CSSDWebBase.version}</version>
</dependency>
...
org.apache.maven.plugins
maven javadoc插件
2.9
us.ak.state.revenue.cssd
CSSD网站
${CSSDWebBase.version}
...
要将javadoc插件附加到您的正常构建过程中,我认为您只需要指定目标,最好将其附加到准备包阶段(以便在您运行测试阶段时不会生成javadoc):
org.apache.maven.plugins
maven javadoc插件
2.9
附加javadoc
准备包装
罐子
您可以尝试将您的
作为插件依赖项:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<dependencies>
<dependency>
<groupId>us.ak.state.revenue.cssd</groupId>
<artifactId>CSSD-Web</artifactId>
<version>${CSSDWebBase.version}</version>
</dependency>
...
org.apache.maven.plugins
maven javadoc插件
2.9
us.ak.state.revenue.cssd
CSSD网站
${CSSDWebBase.version}
...
要将javadoc插件附加到您的正常构建过程中,我认为您只需要指定目标,最好将其附加到准备包阶段(以便在您运行测试阶段时不会生成javadoc):
org.apache.maven.plugins
maven javadoc插件
2.9
附加javadoc
准备包装
罐子
基于@ben75s的优秀建议,我终于可以让它运行了。
这“有效”。这感觉不对,我希望看到更好的方法
以下是我所做的:
- 使用javadoc目标在构建部分定义插件。
- 确保tools.jar和rt.jar位于
- 将
定义为\${project.build.outputDirectory}代码>
\代码>是必需的,因为maven没有正确追加
- 还必须显式地将路径添加到一些包中,以防止继承冲突版本。(特别是Log4J)
- 使用抛出
NoClassDefFoundError的类的包定义
我的插件现在看起来像这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>build-siteMap-Descriptions</id>
<phase>process-classes</phase>
<goals>
<!--<goal>aggregate</goal>-->
<goal>javadoc</goal>
</goals>
<configuration>
<doclet>
us.ak.state.revenue.cssd.Personnel.utils.SiteMapDoclet
</doclet>
<!-- the initial '\;.;' is required
because maven doesn't separate the path statements properly
The 5 packages are necessary
because otherwise slf4j complains about multiple bindings
-->
<docletPath>
\;.;${project.build.outputDirectory};
${m2Repository}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar;
${m2Repository}/log4j/log4j/1.2.16/log4j-1.2.16.jar;
${m2Repository}/log4j/apache-log4j-extras/1.1/apache-log4j-extras-1.1.jar;
${m2Repository}/us/ak/state/revenue/cssd/CSSD-Web/${CSSDWebBase.version}/CSSD-Web-${CSSDWebBase.version}.jar;
${m2Repository}/org/apache/wicket/wicket-core/${wicket.version}/wicket-core-${wicket.version}.jar;
${m2Repository}/org/apache/wicket/wicket-util/${wicket.version}/wicket-util-${wicket.version}.jar;
</docletPath>
<docletArtifacts>
<!--
<docletArtifact>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</docletArtifact>
-->
<docletArtifact>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.2</version>
</docletArtifact>
<!-- how do I fix the download errors? -->
<!--
<docletArtifact>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
</docletArtifact>
-->
<!--
<artifact>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</artifact>
-->
<!--
<docletArtifact>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>1.1</version>
</docletArtifact>
<docletArtifact>
<groupId>us.ak.state.revenue.cssd</groupId>
<artifactId>CSSD-Web</artifactId>
<version>${CSSDWebBase.version}</version>
</docletArtifact>
<docletArtifact>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>${wicket.version}</version>
</docletArtifact>
-->
</docletArtifacts>
<!-- the initial '\;.;' is required
because maven doesn't separate the path statements properly -->
<bootclasspath>
\;.;
${bootClassPath};
${env.CLASSPATH};
</bootclasspath>
<destDir>SiteMap</destDir>
<author>false</author>
<!-- don't print the packages/classes it's running on -->
<quiet>true</quiet>
<debug>true</debug> <!-- save options -->
<useStandardDocletOptions>false</useStandardDocletOptions>
<name>SiteMapDoclet</name>
<description>Page Descriptions for SiteMap generation</description>
</configuration>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
maven javadoc插件
2.9
构建站点地图描述
进程类
javadoc
us.ak.state.revenue.cssd.Personal.utils.SiteMapDoclet
\;.;${project.build.outputDirectory};
${m2Repository}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.jar;
${m2Repository}/log4j/log4j/1.2.16/log4j-1.2.16.jar;
${m2Repository}/log4j/apache-log4j-extras/1.1/apache-log4j-extras-1.1.jar;
${m2Repository}/us/ak/state/revenue/cssd/cssd-Web/${CSSDWebBase.version}/cssd-Web-${CSSDWebBase.version}.jar;
${m2Repository}/org/apache/wicket/wicket-core/${wicket.version}/wicket-core-${wicket.version}.jar;
${m2Repository}/org/apache/wicket/wicket util/${wicket.version}/wicket util-${wicket.version}.jar;
org.slf4j
slf4j-log4j12
1.6.2
\;.;
${bootClassPath};
${env.CLASSPATH};
网站地图
假的
真的
真的
假的
SiteMapDoclet
用于生成站点地图的页面说明
基于@ben75s的优秀建议,我终于可以让它运行了。
这“有效”。这感觉不对,我希望看到更好的方法
以下是我所做的:
- 使用javadoc目标在构建部分定义插件。
- 确保tools.jar和rt.jar位于
- 将
定义为\${project.build.outputDirectory}代码>
\代码>是必需的,因为maven没有正确追加
- 还必须显式地将路径添加到一些包中,以防止继承冲突的VER
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>attach-javadoc</id>
<phase>prepare-package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>build-siteMap-Descriptions</id>
<phase>process-classes</phase>
<goals>
<!--<goal>aggregate</goal>-->
<goal>javadoc</goal>
</goals>
<configuration>
<doclet>
us.ak.state.revenue.cssd.Personnel.utils.SiteMapDoclet
</doclet>
<!-- the initial '\;.;' is required
because maven doesn't separate the path statements properly
The 5 packages are necessary
because otherwise slf4j complains about multiple bindings
-->
<docletPath>
\;.;${project.build.outputDirectory};
${m2Repository}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar;
${m2Repository}/log4j/log4j/1.2.16/log4j-1.2.16.jar;
${m2Repository}/log4j/apache-log4j-extras/1.1/apache-log4j-extras-1.1.jar;
${m2Repository}/us/ak/state/revenue/cssd/CSSD-Web/${CSSDWebBase.version}/CSSD-Web-${CSSDWebBase.version}.jar;
${m2Repository}/org/apache/wicket/wicket-core/${wicket.version}/wicket-core-${wicket.version}.jar;
${m2Repository}/org/apache/wicket/wicket-util/${wicket.version}/wicket-util-${wicket.version}.jar;
</docletPath>
<docletArtifacts>
<!--
<docletArtifact>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</docletArtifact>
-->
<docletArtifact>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.2</version>
</docletArtifact>
<!-- how do I fix the download errors? -->
<!--
<docletArtifact>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
</docletArtifact>
-->
<!--
<artifact>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</artifact>
-->
<!--
<docletArtifact>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>1.1</version>
</docletArtifact>
<docletArtifact>
<groupId>us.ak.state.revenue.cssd</groupId>
<artifactId>CSSD-Web</artifactId>
<version>${CSSDWebBase.version}</version>
</docletArtifact>
<docletArtifact>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>${wicket.version}</version>
</docletArtifact>
-->
</docletArtifacts>
<!-- the initial '\;.;' is required
because maven doesn't separate the path statements properly -->
<bootclasspath>
\;.;
${bootClassPath};
${env.CLASSPATH};
</bootclasspath>
<destDir>SiteMap</destDir>
<author>false</author>
<!-- don't print the packages/classes it's running on -->
<quiet>true</quiet>
<debug>true</debug> <!-- save options -->
<useStandardDocletOptions>false</useStandardDocletOptions>
<name>SiteMapDoclet</name>
<description>Page Descriptions for SiteMap generation</description>
</configuration>
</execution>
</executions>
</plugin>