---
title: "maven部署的时候同时部署source和javadoc"
author: "asialee"
date: "2013-05-30T14:21:19Z"
tags: ["Javadoc", "maven", "snapshot", "sources"]
categories: ["编程语言"]
slug: "maven-source-javadoc"
draft: false
lastmod: "2013-05-30T14:21:19Z"
id: 1879960
url: "https://asialee.iteye.com/blog/1879960"
---

**今天用maven遇到两小个问题**

    **1. 上传失败，根据提示才发现是需要填写distributionManagement的repository和snapshotRepository。**

**代码如下：**

       

```
<distributionManagement>
		<repository>
			<id>xxx_local</id>
			<name>XXXX Local Repository</name>
			<url>http://maven.scm.xxx.com:8081/nexus/content/repositories/XXXX_Local</url>
		</repository>
		<snapshotRepository>
			<id>xxx_local_snapshot</id>
			<name>XXX Local Snapshot Repository</name>
			<url>http://maven.scm.xxx.com:8081/nexus/content/repositories/XXX_Local_Snapshots</url>
		</snapshotRepository>

	</distributionManagement>
```

 

        **2.  向maven私服上传jar的时候没有上传source和javadoc，后来发现，只要添加相关的plugin就可以了，特此记录一下。**

       

```
<plugin>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
						<phase>deploy</phase>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-javadoc-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<phase>deploy</phase>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<!-- explicitly define maven-deploy-plugin after other to force exec 
					order -->
				<artifactId>maven-deploy-plugin</artifactId>
				<executions>
					<execution>
						<id>deploy</id>
						<phase>deploy</phase>
						<goals>
							<goal>deploy</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
```