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>html

下面是一個最簡單是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>java

注意,上面例子中<scm></scm>中的連接地址並不須要是本身的私人地址,直接把我這裏的拷貝過去用就能夠。 2. 編譯 修改好pom.xml之後,就能夠編譯了,編譯使用下面的命令。git

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

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

相關文章
相關標籤/搜索