Maven add-ons-the maven-source-plugin of Maven plugin learning

Source: Internet
Author: User

Add the following code under the Pom.xml File build node:

1<plugin>2<groupId>org.apache.maven.plugins</groupId>3          <artifactId>maven-source-plugin</artifactId> 4<version>2.1.1</version>5<executions>6<execution>7<id>attach-sources</id>8                 <phase>package</phase>9<goals>Ten<goal>jar-no-fork</goal> One</goals> A</execution> -</executions> -</plugin>

The user can bind any plug-in target to the stage of any life cycle as needed, such as binding the jar-no-fork target of Maven-source-plugin to the package stage of the default life cycle, so that later execution mvn Package command when packaging a project, source code packaging is performed after the packages phase

Execution can be configured under the Phase property, which means the source file is packaged at what stage. such as <PHASE>INSTALL</PHASE>: package source code when executing mvn install

DOS execution mvn Install build Source.jar

1[INFO]------------------------------------------------------------------------2[INFO] Building Common-base 0.0.13[INFO]------------------------------------------------------------------------4Downloading:http://121.41.105.153:8081/nexus/content/groups/public/org/apache/m5aven/plugins/maven-source-plugin/maven-Metadata.xml6Downloaded:http://121.41.105.153:8081/nexus/content/groups/public/org/apache/ma7Ven/plugins/maven-source-plugin/maven-metadata.xml (746 B at 5.6 kb/sec)8Downloading:http://121.41.105.153:8081/nexus/content/groups/public/org/codehaus9/mojo/cobertura-maven-plugin/maven-Metadata.xmlTenDownloaded:http://121.41.105.153:8081/nexus/content/groups/public/org/codehaus/ OneMojo/cobertura-maven-plugin/maven-metadata.xml (605 B at 4.7 kb/sec) ADownloading:http://121.41.105.153:8081/nexus/content/groups/public/org/apache/m -aven/plugins/maven-help-plugin/maven-Metadata.xml -Downloaded:http://121.41.105.153:8081/nexus/content/groups/public/org/apache/ma theVen/plugins/maven-help-plugin/maven-metadata.xml (493 B at 3.7 kb/sec) - [INFO][INFO]---maven-resources-plugin:2.4.3:resources (default-resources) @ common-b18 ASE--- +[INFO] Using ' UTF-8 'encoding to copy filtered resources. -[INFO] Copying 6Resources + [INFO] A[INFO]---maven-compiler-plugin:2.0.2:compile (default-compile) @ common-base- at-- -[INFO] Compiling. source files to E:\cncrowd_workspace\common-deploy\common-b - ase\target\classes - [INFO] -[INFO]---maven-resources-plugin:2.4.3:testresources (default-testresources) @ -Common-base--- in[INFO] Using ' UTF-8 'encoding to copy filtered resources. -[INFO] Copying 2Resources to [INFO] +[INFO]---maven-compiler-plugin:2.0.2:testcompile (default-testcompile) @ Commo -N-base--- the[INFO] Nothing to compile-All classes is up to date * [INFO] $[INFO]---maven-surefire-plugin:2.7.2:test (default-test) @ common-base---Panax Notoginseng[INFO] Surefire Report directory:e:\cncrowd_workspace\common-deploy\common-Base -\target\surefire-reports the There is no tests to run. + [INFO] A[INFO]---maven-jar-plugin:2.4:jar (default-jar) @ common-base--- the[INFO] Building jar:e:\cncrowd_workspace\common-deploy\common-Base\target\commo +n-base-0.0.1. Jar - [INFO] $[INFO] >>> Maven-source-plugin:2.4:jar (attach-sources) @ common-base >>> $ [INFO] -[INFO] <<< Maven-source-plugin:2.4:jar (attach-sources) @ common-base <<< - [INFO][INFO]---maven-source-plugin:2.4:jar (attach-sources) @ common-base---[info] Building JAR:E:\CNCROWD_WORKSP Ace\common-deploy\common-base\target\commo51 N-base-0.0.1-sources.jar the [INFO] -[INFO]---maven-install-plugin:2.5.1:install (default-install) @ common-base-- Wu- -[INFO] Installing E:\cncrowd_workspace\common-deploy\common-base\target\common-b AboutAse-0.0.1.jar to D:\Maven\repository\com\common\item\base\common-base\0.0.1\comm $on-base-0.0.1. Jar -[INFO] Installing E:\cncrowd_workspace\common-deploy\common-Base\pom.xml to D:\m -aven\repository\com\common\item\base\common-base\0.0.1\common-base-0.0.1. Pom[INFO] Installing E:\cncrowd_workspace\common-deploy\common-base\target\common-b61 Ase-0.0.1-sources.jar to D : \maven\repository\com\common\item\base\common-base\0.62 0.1\common-base-0.0.1-sources.jar

Execution Result:

Add:

Executing MVN install,maven automatically install the source to repository.

Executing MVN Deploy,maven will automatically deploy the source to Remote-repository.

Execute MVN source:jar, separate packaging source.

Manually install the MAVEN installation source code to the local library:

MVN install:install-file-dfile=e:/common-base-0.0.1-sources.jar-dgroupid=net.spy-dartifactid=spymemcached- Dversion=2.10.3-dpackaging=jar-dclassifier=sources

Maven add-ons-the maven-source-plugin of Maven plugin learning

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.