Effective-pom 是超级 pom 和应用 POM 的合并 [英] Is effective-pom a merge between super pom and application POM

查看:54
本文介绍了Effective-pom 是超级 pom 和应用 POM 的合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 mvn help:effective-pom 命令在示例应用程序上生成有效的 pom.http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-pom.html在这篇文章中,它说有效的 pom 是超级 pom 和应用程序 pom 之间的合并.

I have tried to generate effective pom on sample application using mvn help:effective-pom command. http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-pom.html at this article it says effective pom is a merge between super pom and application pom.

但是,当我查看我的有效 pom 时,它包含不包含在超级 pom 或有效 pom 中的元素.

But, When I look at my effective-pom, it contains elements which are not included in the either super pom or effective pom.

是否有其他因素决定了有效的 pom.xml 文件.

Is there other factor deciding what goes into effective pom.

下面给出的是超级 pom 和应用 pom,这两个 pom 都没有 mavne-jar-plugin 或 maven-compiler-plugin,但是在我的 Effective-pom 中,我可以在构建部分看到这些插件.那么它是如何添加的.

Given below is the super pom and application pom, Both of these pom's does not have mavne-jar-plugin or maven-compiler-plugin, but in my effective-pom , I can see those plugins in the build section. So how does it get added.

在此先感谢您对澄清此问题的任何帮助

Thanks in advance for any help on clarifying this issue

超级 POM

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!-- START SNIPPET: superpom -->
<project>
  <modelVersion>4.0.0</modelVersion>

  <repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <directory>${project.basedir}/target</directory>
    <outputDirectory>${project.build.directory}/classes</outputDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
    <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
    <resources>
      <resource>
        <directory>${project.basedir}/src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>${project.basedir}/src/test/resources</directory>
      </testResource>
    </testResources>
    <pluginManagement>
      <!-- NOTE: These plugins will be removed from future versions of the super POM -->
      <!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) -->
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <reporting>
    <outputDirectory>${project.build.directory}/site</outputDirectory>
  </reporting>

  <profiles>
    <!-- NOTE: The release profile will be removed from future versions of the super POM -->
    <profile>
      <id>release-profile</id>

      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
              <updateReleaseInfo>true</updateReleaseInfo>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
<!-- END SNIPPET: superpom -->

应用POM

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.sonatype.mavenbook.ch08</groupId>
    <artifactId>simplest-project</artifactId>
    <packaging>jar</packaging>
    <version>1</version>
</project>

有效的pom

推荐答案

Effective POM 由 Super POM + Application POM(s) + settings.xml 内容 + 根据选择的打包类型默认绑定到生命周期的插件组成(因此,基于应用程序 POM 中的一个元素).

Effective POM is composed of Super POM + Application POM(s) + settings.xml contents + plugins bound to the lifecycle by default based on the packaging type chosen (thus, based on one element in the Application POM).

您询问了 maven-jar-pluginmaven-compiler-plugin.这些默认绑定到生命周期,因为您的应用程序 POM 指定了 jar 包装.

You asked about maven-jar-plugin and maven-compiler-plugin. These are bound to the lifecycle by default because your application POM specifies jar packaging.

你可以在$YOUR_REPO_LOCATIONorgapachemavenmaven-core3.0.xmaven-core-3.0.x.jarMETA-INFplexuscomponents.xml中看到默认绑定文档.

这篇关于Effective-pom 是超级 pom 和应用 POM 的合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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