When we develop a common module that deploy it to the MAVEN repository, it is best to provide both source and Javadoc packages so that users can go directly to the dependent source in the IDE to see the details of their implementation.
Because generating source packages and Javadoc packages are extremely common requirements, MAVEN officially provides plug-ins to help users complete this task
, CONFIGURED as follows:
<build> <plugins> <plugin> <GROUPID>ORG.APACHE.MAVEN.PLUGINS</GROUPID&G
T <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> &L T;configuration> <source>${java.version}</source> <target>${java.vers Ion}</target> <testSource>${java.version}</testSource> <testtarget> ;${java.version}</testtarget> </configuration> </plugin> <!--configuration Build Javadoc Package --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifact Id>maven-javadoc-plugin</artifactid> <version>2.10.4</version> <configurat
Ion> <encoding>UTF-8</encoding> <aggregate>true</aggregate> <charset>UTF-8</charset> <docencoding>UTF-8</docencoding> </con figuration> <executions> <execution> <id>attach-javad
Ocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <!--matching Build Source Pack--> <plugin> <groupId>org.apache.maven.plugins</groupId> <ar Tifactid>maven-source-plugin</artifactid> <version>3.0.1</version> <execut Ions> <execution> <id>attach-sources</id> ;goals> <goal>jar</goal> </goals> </ex
Ecution></executions> </plugin> </plugins> </build>
In the process of using idea to generate Java doc, it may appear that the idea console output Chinese garbled, even if we specify the character set in the Maven-javadoc-plugin plug-in as UTF-8, is still garbled, because MAVEN's default platform encoding is GBK.
Solution:
In idea, open File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner add-DFILE.ENCODING=GBK to VM options, remember that it must be GBK. Reference
Maven Combat (ix)--Packaging tips: http://www.infoq.com/cn/news/2011/06/xxb-maven-9-package