2013-06-04 5 views
14

मैंने एमवीएन सहायता का उपयोग कर नमूना अनुप्रयोग पर प्रभावी पोम उत्पन्न करने का प्रयास किया है: प्रभावी-पोम कमांड। इस लेख में http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-pom.html यह कहता है कि प्रभावी पोम सुपर पोम और एप्लिकेशन पोम के बीच एक विलय है।प्रभावी पोम सुपर पोम और एप्लिकेशन के बीच एक विलय है 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 --> 

आवेदन पोम

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

प्रभावी पोम

+1

मुझे लगता है कि आप प्रभावी पोम जोड़ना भूल गए हैं। – Utku

उत्तर

20

प्रभावी पीओएम सुपर पीओएम + एप्लिकेशन पीओएम (सेटिंग्स) + सेटिंग्स.एक्सएमएल सामग्री + प्लगइन्स से बना है जो डिफ़ॉल्ट रूप से पैकेजिंग प्रकार के आधार पर जीवन चक्र से जुड़ा हुआ है (इस प्रकार, एप्लिकेशन पीओएम में एक तत्व के आधार पर)।

आपने maven-jar-plugin और maven-compiler-plugin के बारे में पूछा। ये डिफ़ॉल्ट रूप से जीवन चक्र से बंधे हैं क्योंकि आपका एप्लिकेशन पीओएम 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

में नई सुविधाओं के साथ प्रश्न अपडेट किया है, इस उत्तर के लिए धन्यवाद, स्पष्टीकरण के लिए एक और सवाल, तो मैवेन डिफ़ॉल्ट जीवन चक्र के निष्पादन के दौरान प्रभावी पोम पर काम करेगा, क्या मैं सही हूँ ? – KItis

+3

मेवेन प्रभावी पोम बनाता है, उसके बाद किसी भी आदेश के निष्पादन के दौरान इसका उपयोग करता है, चाहे जीवन चक्र चरण (उदा। 'एमवीएन इंस्टॉल') या विशिष्ट लक्ष्य (उदा।' एमवीएन संस्करण: प्रदर्शन-निर्भरता-अद्यतन')। – user944849

+0

@ user944849 वैसे, मेरा 'maven-core-3.0.3.jar' मेरे स्थानीय भंडार पर नहीं था, लेकिन '$ (MAVEN_HOME)/lib/maven-core-3.0.3.jar' पर था। इसके लिए क्या कारण हो सकता है? – Utku

3

अगर मैं सही ढंग से याद, प्रभावी पोम साधन स्पष्ट पर किसी भी मदद के लिए अग्रिम धन्यवाद इस्तेमाल करने के लिए वास्तविक पीओएम।

सुपर पीओएम में सेटिंग शामिल करना इसका हिस्सा है। इसमें माता-पिता पीओएम लागू करने, प्रोफाइल लागू करने, गुणों को प्रतिस्थापित करने, आदि जैसे

मुझे लगता है कि अगर आप उन सेटिंग्स की कुछ स्निपेट दे सकते हैं जो आपको लगता है कि कहीं से नहीं आता है तो यह बेहतर होगा। कि हम पहचान सकते हैं कि वे कहां से आते हैं।

+0

मैंने सुपर पोम, एप्लिकेशन पोम, और प्रभावी-पोम – KItis

संबंधित मुद्दे