How to package source code in Maven

Source: Internet
Author: User

1. The source plugin can be used to create a jar file of the project sources from the command line or by binding the goal to the project's build lifecycle. to generate the jar from the command line, use the following command:

 

  MVN Source: jar <br/>A jar file of the test sources can also be generated by executing: MVN Source: Test-jar <br/>After running, the generated source file jar package is found in the target directory. 2. Add the following in POM. xml: <Build> <br/> <plugins> <br/> <plugin> <br/> <artifactid> Maven-source-plugin </artifactid> <br/> <version> 2.1 </version> <br/> <configuration> <br/> <attach> true </Attach> <br/> </configuration> <br/> <executions> <br/> <execution> <br/> <phase> compile </phase> <br/> <goals> <br/> <goal> jar </goal> <br/> </goals> <br/> </execution> <br/> </executions> <br/> </plugin> <br/> </plugins> <br/> </build>If phase is specified as compile in the configuration, the source file is packaged during the lifecycle compile, that is, the source code is packaged as long as the MVN Command executed includes the compile stage. Similarly, phase can also be specified as package, install, and so on.

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.