重命名带有依赖项的 Maven jar

发布于 2025-01-10 03:02:39 字数 1229 浏览 0 评论 0原文

pom 文件中的插件部分如下所示:

  <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>

          <archive>
            <manifest>
              <mainClass>com.gateway.gatewayService</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

构建完成后,我留下以下文件:

gateway-1.1.0.pom
gateway-1.1.0.jar
gateway-1.1.0.jar-with-dependencies.jar

我想得到以下结果:

gateway-1.1.0.pom
gateway-1.1.0.jar
gateway-1.1.0-all.jar

这意味着更改 gateway-1.1.0.jar-with -dependency.jargateway-1.1.0-all.jar,这可能吗?

My plugin section in the pom file looks like this:

  <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>

          <archive>
            <manifest>
              <mainClass>com.gateway.gatewayService</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

After the build finishes, I'm left with the following files:

gateway-1.1.0.pom
gateway-1.1.0.jar
gateway-1.1.0.jar-with-dependencies.jar

I would like to get the following outcome instead:

gateway-1.1.0.pom
gateway-1.1.0.jar
gateway-1.1.0-all.jar

Which means changing gateway-1.1.0.jar-with-dependencies.jar to gateway-1.1.0-all.jar, is that possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

折戟 2025-01-17 03:02:39

内容然后尝试。

<descriptorRefs>
  <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>

删除第5,6&7行的

Remove the content

<descriptorRefs>
  <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>

Of line 5,6&7 and then try.

吐个泡泡 2025-01-17 03:02:39

您需要在 内添加两个标签,分别是

Set ;false

您需要更改您的 maven-assemble-plugin 如下

 <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <configuration>

          <finalName>all</finalName>   // name of your jar
          <appendAssemblyId>false</appendAssemblyId>  // append will be false

          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>

          <archive>
            <manifest>
              <mainClass>com.gateway.gatewayService</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

You need to add two tags which are <finalName> and <appendAssemblyId> inside <configuration>

Set <appendAssemblyId> to false

You need to change your maven-assembly-plugin as below

 <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <configuration>

          <finalName>all</finalName>   // name of your jar
          <appendAssemblyId>false</appendAssemblyId>  // append will be false

          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>

          <archive>
            <manifest>
              <mainClass>com.gateway.gatewayService</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文