Apache Maven Source Plugin-Maven打包源码到私服

使用插件Apache Maven Source Plugin

官网说明:https://maven.apache.org/plugins/maven-source-plugin/index.html

Goals Overview

source:jar 是默认的。
The Source Plugin has five goals:

  • source:aggregate aggregrates sources for all modules in an aggregator project.
  • source:jar is used to bundle the main sources of the project into a jar archive.
  • source:test-jar on the other hand, is used to bundle the test sources of the project into a jar archive.
  • source:jar-no-fork is similar to jar but does not fork the build lifecycle.
  • source:test-jar-no-fork is similar to test-jar but does not fork the build lifecycle.

POM Demo

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.0.1</version><!--版本号查询官网最新版-->
        <configuration>
          <outputDirectory>/absolute/path/to/the/output/directory</outputDirectory>
          <finalName>filename-of-generated-jar-file</finalName>
          <attach>false</attach>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

快速使用

  1. 配置好发布的私服地址。
<project>
  ...
    <distributionManagement>
        <repository>
            <id>deploymentRepo</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.1.53:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshot</id>
            <name>snapshot</name>
            <url>http://192.168.1.53:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
  ...
</project>
  1. 配置好插件,然后 mvn deploy
mvn deploy

进阶用法

打包源码jar包

mvn source:jar

打包源码 测试 jar包

mvn source:test-jar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值