English 中文(简体)
Maven和POM.xml
原标题:Plugins in Maven and POM.xml

I just started using Maven and I read that plugins are additional components that can be used.
A typical structure of pom.xml file is

<project>
  <groupId>org.koshik.javabrains</groupId>
  <artifactId>JarName</artifactId> (A fldernamed JarName was created) 
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>JarName</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

。 在什么地方,我应插入plugintag? 例如:

<plugin>
  <groupId>org.jibx</groupId>
  <artifactId>jibx-maven-plugin</artifactId>
  <version>1.2.4</version>
  <executions>
    <execution>
      <goals>
        <goal>bind</goal>
      </goals>
    </execution>
  </executions>
</plugin>

在依赖之前或之后<代码>依赖性标签? 是否有必要?

最佳回答
<project>
    <groupId>org.koshik.javabrains</groupId>
    <artifactId>JarName</artifactId> (A fldernamed JarName was created) 
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>JarName</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jibx</groupId>
                <artifactId>jibx-maven-plugin</artifactId>
                <version>1.2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bind</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

如果你使用剪辑,你还可以在<代码><build> section of <profile>上放置 p。 命令没有问题。

问题回答

www.un.org/spanish/ecosoc 关于两个重要要点的说明:

Where to place plugin
A plugin should indeed be added in most of the cases within the build/plugins section, however there is an important difference between placing it within plugins against placing it within pluginManagement/plugins.

这种误解是:often,原因是在Maven没有援引皮条,或者更难击::

  • Plugins under build/plugins are directly part of the default Maven build, if they specify an execution or if they configure something for the default build (see below)
  • Plugins under build/pluginManagement/plugins are not necessarely part of the default Maven build, that is, is a management, it s an hint to maven: it you happen to use this plugin, then please use the version, the configuration, the executions I specify here, in this management.

    www.un.org/spanish/ecosoc 但是,happen to use means? 手段:如果在<代码>build/<>>>>>>上出现同一条块,则适用这一管理(只有这样才会有效);or,如果Maven缺席援引该金,则也适用。

    www.un.org/spanish/ecosoc 但是,在违约时如何援引一种假想? 它是 后的主要理念的一部分:公约的组合。 通过公约,如果你具体指明某种<代码> 包装(default jar,但可以打上war,例如,你希望援引某些假想。 援引maven-jar-plugin/code>;建立war <>/code>,build/<><>>/code>pluginManage<<>/code>上指明了一种对Maven建筑有约束力的原始.,那么也将使用这一代谢。

Ordering
Concerning the ordering of sections within the pom.xml file, a further clarification is required: it s indeed irrelevant in most of the cases, however the order of plugin element wihtin the build/plugins section may be important. Since Maven 3.0.3 (
MNG-2258), different plugin executions attached to the same Maven phase will be invoked in their order of declaration in the pom.xml file. That is, ordering is important in this case, since it may affect the behavior of the build.

Additionally, also order of dependency declarations may affect your build towards Dependency Mediation, that is, the first declared dependency wins in case of conflict against a transitive dependency. So, once again, ordering is important in certain cases.

最后,但并非最不重要的是,尽管对<代码>>pom.xml文档的其他部分而言,订单并不重要,但好的习惯是遵循官方网站 rel=“noreferer>。 • 《公约》第22条:

<project>
  <modelVersion/>

  <parent/>

  <groupId/>
  <artifactId/>
  <version/>
  <packaging/>

  <properties/>

  <dependencyManagement/>
  <dependencies/>

  <build/>

  <reporting/>

  <profiles/>
</project>

https://github.com/Ekryd/sortpom”rel=“noretinger”>sortpom-maven-plugin 也可自动适用这一标准令,仅在有关<条码>上援引以下内容:

mvn com.github.ekryd.sortpom:sortpom-maven-plugin:2.5.0:sort 
     -Dsort.keepBlankLines -Dsort.predefinedSortOrder=recommended_2008_06 

www.un.org/spanish/ecosoc 供进一步阅读<>。

<plugin>should be placed into <plugins> section which should be placed into <build> or <pluginManagement> section. The order of <dependency> or <build> section doesn t matter.

http://maven.apache.org/pom.html

如果你想利用这一花.来建设你,就可以使用以下结构。

<project>
 <build>
  <plugins>
  </plugins>
 </build>
</project>

您可在以下两个条目中插入其第二版:<plugins></plugins> tags>。

POM公司的命令是没有意义的。 总的来说,在Maven有 p树和 reporting树。 您的个案是利用微粒,使您不得不将<代码><plugin>栏编为<project><build><plugins>... section。

参看,其中涉及一些关于原始成分的基本内容。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签