maven deploy 的时候加入源码

2020-08-12  本文已影响0人  匆匆岁月

maven-source-plugin提供项目自动将源码打包并发布的功能,在需要发布源码项目的pom.xml文件中添加如下代码即可:


<!-- Source attach plugin -->
 <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-source-plugin</artifactId>
              <executions>
                  <execution>
                      <id>attach-sources</id>
                      <goals>
                          <goal>jar</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>
      </plugins>
  </build>

执行 mvn install,maven会自动将source install到repository 。
执行 mvn deploy,maven会自动将source deploy到remote-repository 。
执行 mvn source:jar,单独打包源码。

注:在多项目构建中,将source-plugin置于顶层或parent的pom中并不会发挥作用,必须置于具体项目的pom中。

上一篇 下一篇

猜你喜欢

热点阅读