我有一個龐大的多模塊Maven構建版本。我需要爲所有模塊生成javadoc,並生成一個「聚集的」javadoc結果,我可以將其部署到一個框中供用戶使用。如何在未重新生成javadoc的情況下聚合Maven子項目javadoc輸出
我確實在這段時間內工作得非常好,直到我嘗試實現具有特定功能和要求的自定義小標籤,這使得這更加複雜。
所有子模塊都繼承了不是聚合器pom的父pom。在那個父pom中,我定義了maven-javadoc-plugin。這就是它看起來像之前我添加的自定義Taglet的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<bottom>Unified Service Layer - bottom</bottom>
<doctitle>Unified Service Layer - title</doctitle>
<footer>Unified Service Layer - footer</footer>
<groups></groups>
<header>Unified Service Layer - header</header>
<level>public</level>
<packagesheader>Unified Service Layer - packagesheader</packagesheader>
<top>Unified Server Layer - top</top>
<windowtitle>Unified Service Layer - windowtitle</windowtitle>
</configuration>
<executions>
<execution>
<id>module-javadoc-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<show>protected</show>
<detectLinks>false</detectLinks>
</configuration>
</execution>
<execution>
<id>aggregated-documentation</id>
<phase>package</phase>
<inherited>false</inherited>
<goals>
<goal>aggregate-jar</goal>
</goals>
<configuration>
<show>protected</show>
<detectLinks>false</detectLinks>
</configuration>
</execution>
</executions>
</plugin>
有了這個,我可以建立所有所有的模塊,這將產生自己的javadoc(我現在知道的只是一個驗證步驟,如聚集jar不使用這個輸出)。我有一個單獨的步驟,我從jenkins調用,在根項目中運行「javadoc:aggregate-jar」,它生成我部署的聚合javadoc jar。
再一次,這一直工作得很好,直到現在。
我實現了一個自定義的javadoc小標籤,它需要訪問與它所包含的源文件關聯的Class對象。我得到這個工作,至少在個別模塊建立加入上述以下的配置:
<taglets>
<taglet>
<tagletClass>com.att.det.taglet.ValidationConstraintsTaglet</tagletClass>
</taglet>
<taglet>
<tagletClass>com.att.det.taglet.ValidationConstraintsCombinedTaglet</tagletClass>
</taglet>
</taglets>
<tagletArtifacts>
<tagletArtifact>
<groupId>com.att.detsusl.taglets</groupId>
<artifactId>validationJavadocTaglet</artifactId>
<version>0.0.1-SNAPSHOT</version>
</tagletArtifact>
</tagletArtifacts>
爲了有Taglet的獲取訪問的類文件,我不得不添加一個最小的插件配置每個子項目的pom.xml,它看起來像這樣:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<tagletArtifacts combine.children="append">
<tagletArtifact>
<groupId>com.att.detsusl</groupId>
<artifactId>artifact-name</artifactId>
<version>${current.pom.version}</version>
</tagletArtifact>
</tagletArtifacts>
</configuration>
</plugin>
有了這些最小的變化,我在每個模塊在運行生成,生成的Javadoc,並檢查各個模塊中生成的Javadoc輸出,驗證它所有的工作。
但是,問題是,當我在根項目中運行「javadoc:aggregate-jar」時,所有已經生成的輸出都被忽略。它重新生成所有子項目的javadoc生成,並且忽略每個子項目pom.xml文件中附加的tagletArtifacts列表。因此,當它試圖獲取類文件時,我得到了ClassNotFound錯誤。
我可以通過將所有子項目GAV放入頂層「tagletArtifacts」列表中來「解決」這個問題,但我絕對不希望這樣做。我喜歡能夠在子項目pom.xml中指定它(with combine.children =「append」)以使其工作。
我需要的是一個用於所有子項目的整體javadoc包,其中小標籤能夠訪問類文件,而不會強制父pom知道其所有子項目。我怎樣才能做到這一點?