---
title: "关于maven创建jar depoy发布源代码"
author: "hebad90"
date: "2014-07-05T18:14:00Z"
tags: ["maven", "源码"]
categories: ["开源软件"]
slug: "maven-jar-depoy"
draft: false
lastmod: "2014-07-10T21:19:46Z"
id: 2088625
url: "https://hebad90.iteye.com/blog/2088625"
---

1\. 本地target目录中生成 xxx-sources.jar 

执行:mvn source:jar即可

 

2.但是如果要发布到本地仓库或者别的地方的话，需要加上插件:

```
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
```

 执行：mvn clean install 即可.

ps:可以观察日志，看\*-source.jar是否发布到本地库上去了

**ps : 不管何种方式，都需要加上以上插件**