Is effective-pom a merge between super pom and application POM
Asked Answered
O

3

16

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.

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

Is there other factor deciding what goes into 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

Super 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 -->

Application POM

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

effective pom

Osburn answered 4/6, 2013 at 10:36 Comment(1)
I guess you forgot to add the effective pom.Sanctimonious
B
24

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).

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.

You can see the default bindings in $YOUR_REPO_LOCATION\org\apache\maven\maven-core\3.0.x\maven-core-3.0.x.jar\META-INF\plexus\components.xml or in the documentation.

Bonze answered 4/6, 2013 at 17:28 Comment(4)
Thank you for this answer, One more question to clarify, So maven will be acting on effective pom during the execution of default life cycle right, am i correct ?Osburn
Maven constructs the effective pom, then uses that during execution of any command given, whether lifecycle phase (e.g. mvn install) or specific goal (e.g. mvn versions:display-dependency-updates).Bonze
@Bonze By the way, my maven-core-3.0.3.jar was not at my local repository, but at $(MAVEN_HOME)/lib/maven-core-3.0.3.jar. What might be the reason for this?Sanctimonious
I happened to find the artifact in my local repository so I stopped looking in other places. You found it in the application installation. If the version is the same, should be the same information.Bonze
X
3

If I remember correctly, effective POM means the actual POM to be used.

Incorporating settings in super POM is part of it. It also includes a lot other things, like applying parent POM, applying profiles, substituting properties, and etc.

I think it will be better if you can give some snippet of the settings you thought that comes from no where, so that we can identify where do they come from.

Xyloid answered 4/6, 2013 at 10:45 Comment(1)
I have updated the question with Super POM, application pom , and new features in effective-pomOsburn
S
0

Besides incorporating the super POMs, in the dependency management section of effective pom it also includes the "imported" pom.

   <dependencyManagement>
<dependencies>
  <dependency>
    <groupId>maven</groupId>
    <artifactId>A</artifactId>
    <version>1.0</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
</dependencyManagement>

It's documented here :https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#importing-dependencies

Selfanalysis answered 29/9, 2022 at 8:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.