避免 maven-jar 的最佳方法是什么? [英] What is the best way to avoid maven-jar?

查看:43
本文介绍了避免 maven-jar 的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用不同的插件 (ant4eclipse) 来 jar 我的文件.避免 maven-jar 插件执行的最佳方法是什么?

I am using a different plugin (ant4eclipse) to jar my files. What is the best way to avoid the maven-jar plugin from executing?

  • 我试图删除 maven-jar-plugin
  • 我试图<代码><排除>**/*
  • 我试图true

没有工作

推荐答案

在 Maven 3.0.x(我尝试了 3.0.2)中,您可以通过绑定 来禁用 maven-jar-plugindefault-jar 执行到不存在的阶段,如 @bmargulies 建议.不幸的是,这在 2.2.1 中不起作用,但是您可以通过设置替代 default-jar 执行;它仍然会创建一个 jar,但它将被设置为项目的辅助工件,并且不会覆盖您创建的那个.下面是一个适用于 Maven 2 和 Maven 3 的示例:

In Maven 3.0.x (I tried 3.0.2) you can disable maven-jar-plugin by binding the default-jar execution to a nonexistent phase, as @bmargulies suggested. Unfortunately that doesn't work in 2.2.1, but you can prevent it from interfering with your own jar by setting an alternative <finalName> and <classifier> for the default-jar execution; it will still create a jar, but it will be set as a secondary artifact for the project and won't overwrite the one you've created. Here's an example that should work in both Maven 2 and Maven 3:

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>test</groupId>
  <artifactId>test</artifactId>
  <version>0.1-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>default-jar</id>
            <phase>none</phase>
            <configuration>
              <finalName>unwanted</finalName>
              <classifier>unwanted</classifier>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

一旦您禁用了 maven-jar-pluginmaven-install-plugin 也可能会给您带来麻烦.在 Maven 3 中,它可以像 maven-jar-plugin 一样被禁用:将 default-install 绑定到一个不存在的阶段.但是,在 Maven 2 中 maven-install-plugin 要求 target/classes 目录存在,并且当没有主要工件时它将安装虚拟 jar.

Once you've disabled maven-jar-plugin, maven-install-plugin may give you trouble too. In Maven 3 it can be disabled the same as maven-jar-plugin: bind default-install to a nonexistent phase. However, in Maven 2 maven-install-plugin requires that the target/classes directory exist, and it will install the dummy jar when there isn't a primary artifact present.

这篇关于避免 maven-jar 的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆