53586551
When we develop a public module and deploy it to the MAVEN repository, it is best to provide both the source and Javadoc packages so that the user can access the dependent source code directly in the IDE to see the details of its implementation.
Since the generation of source packages and Javadoc packages is a very common requirement, MAVEN has provided plugins to help users with this task
, CONFIGURED as follows:
<Build><Plugins><Plugin><Groupid>org.apache.maven.plugins</Groupid><Artifactid>maven-compiler-plugin</Artifactid><version>3.5.1</Version><Configuration><Source>${java.version}</Source><Target>${java.version}</Target><Testsource>${java.version}</Testsource><Testtarget>${java.version}</Testtarget></Configuration></Plugin><!--configuration generates Javadoc package--<Plugin><Groupid>org.apache.maven.plugins</Groupid><Artifactid>maven-javadoc-plugin</Artifactid><version>2.9.1</Version><Configuration><Encoding>utf-8</Encoding><Aggregate>true</Aggregate><Charset>utf-8</Charset><Docencoding>utf-8</Docencoding></Configuration><Executions><Execution><Id>attach-javadocs</Id><Goals><Goal>jar</Goal></Goals></Execution></Executions></Plugin><!--configuration Generate source Package--<Plugin><Groupid>org.apache.maven.plugins</Groupid><Artifactid>maven-source-plugin</Artifactid><version>3.0.1</Version><Executions><execution> < id>attach-sources</id> <goals> < Goal>jar</goal> </goals> </execution> </executions> </ plugin> </plugins></BUILD>
In the process of using idea to generate Java doc, it is possible that the idea console output is garbled, even if we specify the character set as UTF-8 in the Maven-javadoc-plugin plugin, because MAVEN's default platform encoding is GBK.
Workaround:
In idea, open File | Settings | Build, execution, Deployment | Build Tools | Maven | Runner Add-DFILE.ENCODING=GBK to the 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
MAVEN package generates source and Javadoc packages