MAVEN package generates source and Javadoc packages

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.