2013-06-04 17 views
14

mvn help:effective-pomコマンドを使用して、サンプルアプリケーションで有効なpomを生成しようとしました。 http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-pom.html この記事では、効果的なpomは、スーパーpomとアプリケーションpomの間のマージです。スーパーポームとアプリケーションPOMのマージPOM

しかし、私は自分の有効なポンを見ると、スーパーポンまたは有効なポンに含まれていない要素を含んでいます。

効果的なpomに何が入るかを決定する他の要因はありますか?

以下はスーパーpomとアプリケーションpomです。これらのpomの両方にmavne-jar-pluginやmaven-compiler-pluginはありませんが、私の有効なpomではビルドセクションにこれらのプラグインを見ることができます。だからどのように追加されます。

スーパー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> 

効果的なポンポンが

+1

効果的なpomを追加するのを忘れてしまったようです。 – Utku

答えて

20

有効なPOMは、選択したパッケージタイプ(つまり、アプリケーションPOMの1つの要素に基づく)に基づいて、デフォルトでライフサイクルにバインドされたスーパーPOM +アプリケーションPOM + settings.xmlコンテンツ+プラグインで構成されます。

maven-jar-pluginmaven-compiler-pluginについて尋ねました。これらはアプリケーションPOMがjarパッケージを指定しているため、デフォルトでライフサイクルにバインドされています。

$YOUR_REPO_LOCATION\org\apache\maven\maven-core\3.0.x\maven-core-3.0.x.jar\META-INF\plexus\components.xmlまたはdocumentationにデフォルトのバインディングが表示されます。

+1

この回答をありがとうございます。明確にするもう1つの質問ですので、デフォルトのライフサイクル権利の実行中、私は正しいですか? – KItis

+3

Mavenは有効なpomを構築し、ライフサイクルフェーズ(例えば 'mvn install')か特定のゴール(例えば' mvnバージョン:display-dependency-updates')のいずれかのコマンドの実行中にそれを使用します。 – user944849

+0

@ user944849ところで、私の 'maven-core-3.0.3.jar'は私のローカルリポジトリではなく、' $(MAVEN_HOME)/ lib/maven-core-3.0.3.jar'にありました。この理由は何でしょうか? – Utku

3

をこの問題を明確に上の任意の助けを事前に

おかげで、私の記憶が正しければ、効果的なPOM手段使用される実際のPOM

スーパーPOMに設定を組み込むこともその一部です。親POMを適用する、プロファイルを適用する、プロパティを代入するなど、他にもたくさんのことが含まれています。

私はあなたがどこから来たと思っている設定の一部を与えることができればよいと思います。彼らはどこから来たのかを特定することができます。

+0

私はSuper POM、アプリケーションpom、および有効なポームの新機能に関する質問を更新しました – KItis

関連する問題