2016-05-28 3 views
1

This вопрос спрашивает, что составляет эффективный POM. В ответе указывается, что эффективный ПОМ состоит из:Эффективный POM не равен супер POM + project POM?

  1. Приложение POM.
  2. Super POM.
  3. settings.xml
  4. Плагины привязаны к жизненному циклу по умолчанию в зависимости от выбранного типа упаковки.

Я создал минимальный POM для наблюдения за эффективным POM этого минимального POM. Файлы, как показано ниже:

Минимальная POM:

<project> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.mycompany.app</groupId> 
    <artifactId>my-app</artifactId> 
    <version>1</version> 
</project> 

Супер POM:

<project> 
    <modelVersion>4.0.0</modelVersion> 

    <repositories> 
    <repository> 
     <id>central</id> 
     <name>Central Repository</name> 
     <url>https://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>https://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>${project.basedir}/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.8</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.3.2</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> 

Эффективное POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.mycompany.app</groupId> 
    <artifactId>my-app</artifactId> 
    <version>1</version> 

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

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

    <build> 
    <sourceDirectory>/Users/utku/Minimal_POM_Test/src/main/java</sourceDirectory> 
    <scriptSourceDirectory>/Users/utku/Minimal_POM_Test/src/main/scripts</scriptSourceDirectory> 
    <testSourceDirectory>/Users/utku/Minimal_POM_Test/src/test/java</testSourceDirectory> 
    <outputDirectory>/Users/utku/Minimal_POM_Test/target/classes</outputDirectory> 
    <testOutputDirectory>/Users/utku/Minimal_POM_Test/target/test-classes</testOutputDirectory> 
    <resources> 
     <resource> 
     <directory>/Users/utku/Minimal_POM_Test/src/main/resources</directory> 
     </resource> 
    </resources> 
    <testResources> 
     <testResource> 
     <directory>/Users/utku/Minimal_POM_Test/src/test/resources</directory> 
     </testResource> 
    </testResources> 
    <directory>/Users/utku/Minimal_POM_Test/target</directory> 
    <finalName>my-app-1</finalName> 
    <pluginManagement> 
     <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.8</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.3.2</version> 
     </plugin> 
     </plugins> 
    </pluginManagement> 
    <plugins> 
     <plugin> 
     <artifactId>maven-clean-plugin</artifactId> 
     <version>2.5</version> 
     <executions> 
      <execution> 
      <id>default-clean</id> 
      <phase>clean</phase> 
      <goals> 
       <goal>clean</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-resources-plugin</artifactId> 
     <version>2.6</version> 
     <executions> 
      <execution> 
      <id>default-testResources</id> 
      <phase>process-test-resources</phase> 
      <goals> 
       <goal>testResources</goal> 
      </goals> 
      </execution> 
      <execution> 
      <id>default-resources</id> 
      <phase>process-resources</phase> 
      <goals> 
       <goal>resources</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-jar-plugin</artifactId> 
     <version>2.4</version> 
     <executions> 
      <execution> 
      <id>default-jar</id> 
      <phase>package</phase> 
      <goals> 
       <goal>jar</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.1</version> 
     <executions> 
      <execution> 
      <id>default-compile</id> 
      <phase>compile</phase> 
      <goals> 
       <goal>compile</goal> 
      </goals> 
      </execution> 
      <execution> 
      <id>default-testCompile</id> 
      <phase>test-compile</phase> 
      <goals> 
       <goal>testCompile</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.12.4</version> 
     <executions> 
      <execution> 
      <id>default-test</id> 
      <phase>test</phase> 
      <goals> 
       <goal>test</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-install-plugin</artifactId> 
     <version>2.4</version> 
     <executions> 
      <execution> 
      <id>default-install</id> 
      <phase>install</phase> 
      <goals> 
       <goal>install</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-deploy-plugin</artifactId> 
     <version>2.7</version> 
     <executions> 
      <execution> 
      <id>default-deploy</id> 
      <phase>deploy</phase> 
      <goals> 
       <goal>deploy</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-site-plugin</artifactId> 
     <version>3.3</version> 
     <executions> 
      <execution> 
      <id>default-site</id> 
      <phase>site</phase> 
      <goals> 
       <goal>site</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>/Users/utku/Minimal_POM_Test/target/site</outputDirectory> 
       <reportPlugins> 
       <reportPlugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-project-info-reports-plugin</artifactId> 
       </reportPlugin> 
       </reportPlugins> 
      </configuration> 
      </execution> 
      <execution> 
      <id>default-deploy</id> 
      <phase>site-deploy</phase> 
      <goals> 
       <goal>deploy</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>/Users/utku/Minimal_POM_Test/target/site</outputDirectory> 
       <reportPlugins> 
       <reportPlugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-project-info-reports-plugin</artifactId> 
       </reportPlugin> 
       </reportPlugins> 
      </configuration> 
      </execution> 
     </executions> 
     <configuration> 
      <outputDirectory>/Users/utku/Minimal_POM_Test/target/site</outputDirectory> 
      <reportPlugins> 
      <reportPlugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-project-info-reports-plugin</artifactId> 
      </reportPlugin> 
      </reportPlugins> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 

    <reporting> 
    <outputDirectory>/Users/utku/Minimal_POM_Test/target/site</outputDirectory> 
    </reporting> 

</project> 

Однако, обратите внимание на следующее:

<repositories> тег эффективного POM и Супер POM не то же самое:

  1. Порядок, которые появляются элементы <repositories> тега различны.
  2. Эффективное ПОМ отсутствует <layout>default</layout> часть.

Аналогичные различия существуют и для других тегов, а также.

Что является причиной этого? Два вопроса по этой теме являются:

  1. Из linked question, я думал, что эффективное ПОМ является просто суммирование POM проекта и супер ПОМ. Однако результаты показывают, что это не так просто. Проводит ли дальнейшая обработка в эффективную ПОМ?
  2. Если да, Maven плагин (или другие инструменты) используются для создания эффективной POM?
+0

Как вы оцениваете эффективную POM? – khmarbaise

+0

@khmarbaise 'mvn help: effective-pom' – Utku

+0

Вы использовали ту же версию maven? – khmarbaise

ответ

1

Значки эффективных POM и Super POM одинаковы относительно их эффективного контента. <layout>default - неудивительно, the default. Порядок деклараций обычно не имеет значения из-за декларативного характера ПОМ. (Если это упомянуто в документации.)

См Maven: The Complete Reference, 3.2.1. The Super POM для получения дополнительной информации.

Смотрите также Maven Model Builder:

эффективной модели построитель, с активацией профиля, наследование, интерполяция, ...

...

  • фаза 1
    • ...
    • родительская разрешение до super-pom
    • ...
Смежные вопросы