什么引用< id> Maven插件执行的价值? [英] What references the <id> value of a Maven plugin execution?

查看:154
本文介绍了什么引用< id> Maven插件执行的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Maven < plugin> 元素中,有一个< executions> 元素,其中包含多个< execution> 元素。每个< execution> 元素都可以包含一个包含字符串的< id> 元素。什么引用那些< id> ...< / id> 元素?省略该元素意味着什么? < id> 元素的语义是什么?

In a Maven <plugin> element there is an <executions> element which contains multiple <execution> elements. Each <execution> element can have an <id> element containing a string. What references those <id>...</id> elements? What does it mean to omit that element? What are the semantics of the <id> element?

例如:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>default-jar-execution</id>
            <configuration>
              <finalName>mainjar</finalName>
            </configuration>
          </execution>
          <execution>
            <id>extra-jar-execution</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <finalName>anotherjar</finalName>
            </configuration>
          </execution>
        </exectutions>
      </plugin>
      [...]
    </plugins>
  </build>
</project>

什么引用那些< id> default-jar-execution< / id> ; < id> extra-jar-execution< / id> 值?改变这些字符串的行为差异是什么?删除这些元素意味着什么?

What references those <id>default-jar-execution</id> and <id>extra-jar-execution</id> values? What is the behavioral difference of changing either of those strings? What does it mean to remove those elements?

推荐答案

id 元素有两个功能:


  1. 文档

  2. 允许Maven知道你何时想要创建一个执行以及何时修改现有

  1. Documentation
  2. Allow Maven to know when you want to create a new execution and when you want to modify an existing one.

第一种情况很简单:它只允许你给执行一个有意义的名字。

The first case is simple: It just allows you to give the execution a meaningful name.

第二种情况意味着Maven带有默认执行,你可以在运行<$ c时看到例如,$ c> mvn help:effective-pom 。如果要替换/扩展现有执行,则需要使用相同的 id 。 Maven然后将两者合并。

The second case means that Maven comes with default executions which you can see when you run mvn help:effective-pom, for example. If you want to replace/extend an existing execution, you need to use the same id. Maven will then merge the two.

参见 http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag


合并来自不同POM的相同ID的执行。

Executions of the same id from different POMs are merged.

这篇关于什么引用&lt; id&gt; Maven插件执行的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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