2013-02-01 4 views
12

親のpomを作成しようとしていますが、プラグインが定義されていますが、継承されたすべてのインスタンスの設定を変更する必要があります。だから、私は<pluginManagement>の定義にいくつかの設定を置くことができ、<plugin>でそれを上書きすることができますが、どのように子供たちをデフォルトのバージョンに戻すことができますか?Mavenの親/子プラグインの設定継承で苦闘

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-checkstyle-plugin</artifactId> 
       <version>2.9.1</version> 
       <executions...> 
       <configuration> 
        <configLocation> 
         (used by all children) 
        </configLocation> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <configuration> 
       <configLocation> 
        (unique to the parent) 
       </configLocation> 
      </configuration> 
     </plugin> 
    </plugins> 
<build> 

したがって、子どもは親の設定を引き続き表示します。

答えて

12

[OK]を、私はそれを持っていると思うの答えは、私の場合には、あなたが指定したものに関連する - 私は、タグを必要としましたが解決策は、タグ内にあった。。。非にそれを結合することにより、私が知ったのは、私が発見したのは、それが上書きされるようにします。したがって、configは決して解析されず、重要ではありません。

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <!-- Main declaration of the plugin --> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-checkstyle-plugin</artifactId> 
       <version>2.9.1</version> 
       <executions> 
        <execution> 
         <!--This must be named--> 
         <id>checkstyle</id> 
         <phase>compile</phase> 
         <goals> 
          <goal>check</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration...> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
    <plugins> 
     <plugin> 
      <!-- Uses the default config --> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <inherited>false</inherited> 
      <executions> 
       <execution> 
        <!--This matches and thus overrides--> 
        <id>checkstyle</id> 
        <phase>none</phase> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
7

あなたが明示的にプラグインが継承されるべきではないと、あなたの親ポンポンで指定することができます。

<build> 
    <pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <version>2.9.1</version> 
      <executions...> 
      <configuration> 
       <configLocation> 
        (used by all children) 
       </configLocation> 
      </configuration> 
     </plugin> 
    </plugins> 
</pluginManagement> 
<plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-checkstyle-plugin</artifactId> 
     <inherited>false</inherited>      <!-- Add this line --> 
     <configuration> 
      <configLocation> 
       (unique to the parent) 
      </configLocation> 
     </configuration> 
    </plugin> 
    </plugins> 
<build> 

そして、あなたの子供のポンポンで、あなたがプラグインを指定する必要があります(設定は、その後<pluginManagement>親要素から来ます。

<build> 
    <plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-checkstyle-plugin</artifactId> 
    </plugin> 
    </plugins> 
<build> 
+1

はい、正しいです。ただし、*すべての*子に明示的にプラグインを指定することを意味します。私は親から自動的に継承できると思っていました。 –

関連する問題