maven 包打source的方法

  1. 准备工作 官方文档中,上面这种情况被称作Artifact Bundles,官方描述如下:Artifact Bundles就是指拥有相同GAV坐标(gourpId、artifactId、version)的一组组件。要想编译一个Bundles,你工程的POM文件,必须要包含以下元素。

[html] view plain copy <project>
<modelVersion></modelVersion>
<groupId></groupId>
<artifactId></artifactId>
<packaging></packaging>
<name></name>
<version></version>
<description></description>
<url></url>
<licenses></licenses>
<scm></scm>
<url></url>
<connection></connection>
</scm>
</project>

下面是一个最简单是POM.XML的示例 [html] view plain copy <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonatype.sample</groupId>
<artifactId>sample-project</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>sample-project</name>
<description>A Sample Project for the Nexus Book</description>
<url>http://books.sonatype.com</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>
scm:git:git://github.com/sonatype/sample-project.git
</connection>
<url>http://github.com/sonatype/sample-project.git</url>
<developerConnection>
scm:git:git://github.com/sonatype-sample-project.git
</developerConnection>
</scm>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

注意,上面例子中<scm></scm>中的链接地址并不需要是自己的私人地址,直接把我这里的拷贝过去用就可以。 2. 编译 修改好pom.xml以后,就可以编译了,编译使用下面的命令。

mvn clean javadoc:jar source:jar repository:bundle-create

转自 http://blog.csdn.net/zhu19774279/article/details/49813303

猜你喜欢

转载自my.oschina.net/u/264182/blog/1626308