我試圖在編譯時將所有類javadoc註釋(最好是庫WebPage類的子類)轉儲到格式爲classname=comment
的.properties文件中。如何在我的項目中編譯和運行我的Custom Doclet類?
到目前爲止,我有:
- 創建的doclet類
SiteMapDoclet
- 類定義掃描項目中的所有的javadoc和轉儲他們.properties文件
- 添加必要的配置給我的pom.xml以使其工作。
版本:的Java 1.6.0.21,Maven的2.2.1
問題:
mvn site
回報:
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)
我嘗試設置瓶當AdditionalDependencies
,即使它們是我的項目的正常依賴關係。 我也嘗試添加路徑到罐子,我期望我的類需要作爲bootclasspath的一部分。
我的pom.xml的報告部分看起來是這樣的:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<reportSets>
<reportSet>
<id>html</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>siteMap</id>
<configuration>
<doclet>
us.ak.state.revenue.cssd.Personnel.utils.SiteMapDoclet
</doclet>
<docletPath>${project.build.outputDirectory}</docletPath>
<destDir>SiteMap</destDir>
<author>false</author>
<useStandardDocletOptions>false</useStandardDocletOptions>
<!-- there has got to be a better way to do this! -->
<!-- how can I fix the CSSD-Web - Base to use a proper manifest file? -->
<bootclasspath>
${bootClassPath};
${env.CLASSPATH};
${m2Repository}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar;
${m2Repository}/org/apache/wicket/wicket-core/${wicket.version}/wicket-core-${wicket.version}.jar;
${m2Repository}/us/ak/state/revenue/cssd/CSSD-Web/${CSSDWebBase.version}/CSSD-Web-${CSSDWebBase.version}.jar
</bootclasspath>
<additionalDependencies>
<additionalDependency>
<groupId>us.ak.state.revenue.cssd</groupId>
<artifactId>CSSD-Web</artifactId>
<version>${CSSDWebBase.version}</version>
</additionalDependency>
<additionalDependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>${wicket.version}</version>
</additionalDependency>
<additionalDependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</additionalDependency>
<additionalDependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</additionalDependency>
</additionalDependencies>
<name>SiteMapDoclet</name>
<description>Page Descriptions for SiteMap generation</description>
</configuration>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
注:
${m2Repository}
被定義爲一個屬性越往上文件,
定義爲${env.USERPROFILE}/.m2/repository
${bootClassPath}
定義作爲文件較高的財產,
定義爲${env.JRE_6_HOME}\lib\rt.jar;${env.JAVA_HOME}\lib\tools.jar;
我該如何修復NoClassDefFoundError
?
另外我想我的SiteMap文件作爲正常構建過程的一部分運行, 在compile
之後但在package
之前運行。
我試過在build
中定義這個,但是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>
UPDATE:
感謝@ ben75的建議。我刪除了我的pom.xml中的<reporting>
部分,現在在構建過程中失敗。我添加了<goals>
並複製了<reporting>
中的<configuration>
部分。
它仍然扔NoClassDefFoundError
,但它發生在我想要的地方。我試着加入:
<includeDependencySources>true</includeDependencySources>
<dependencySourceIncludes>
<dependencySourceInclude>org.apache.wicket:wicket-core:*</dependencySourceInclude>
<dependencySourceInclude>org.apache.commons.logging:*</dependencySourceInclude>
<dependencySourceInclude>us.ak.state.revenue.cssd:CSSD-Web:*</dependencySourceInclude>
</dependencySourceIncludes>
到配置部分,但沒有奏效。
我仍然得到'NoNoClassDefFoundError',但現在我已經在'mvn package'上得到了它。:)我只需要將''從報告複製/粘貼到build。 –
Raystorm
2013-02-20 22:02:28