2

mavenを使用して、%APP_NAME%をjdbc.propertiesの環境変数に置き換えようとしています。私は呼び出すとMaven-Replacer-Pluginはmaven-war-pluginで呼び出されません

<pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>com.google.code.maven-replacer-plugin</groupId> 
        <artifactId>replacer</artifactId> 
        <version>1.5.2</version> 
        <executions> 
         <execution> 
          <phase>package</phase> 
          <goals> 
           <goal>replace</goal> 
          </goals> 
         </execution> 
        </executions> 
        <configuration> 
         <basedir>${project.build.directory}/classes</basedir> 
         <includes> 
          <include>jdbc.properties</include> 
         </includes> 
         <replacements> 
          <replacement> 
           <token>%APP_NAME%</token> 
           <value>${env.BRANCH_NAME}</value> 
          </replacement> 
         </replacements> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-war-plugin</artifactId> 
        <version>2.6</version> 
        <configuration> 
         <failOnMissingWebXml>false</failOnMissingWebXml> 
        </configuration> 
        <executions> 
         <execution> 
          <!-- First step is to disable the default-war build step. --> 
          <id>default-war</id> 
          <phase>none</phase> 
         </execution> 
         <execution> 
          <!-- Second step is to create an exploded war. Done in prepare-package --> 
          <id>war-exploded</id> 
          <phase>prepare-package</phase> 
          <goals> 
           <goal>exploded</goal> 
          </goals> 
         </execution> 
         <execution> 
          <!-- Last step is to make sure that the war is built in the package 
           phase --> 
          <id>custom-war</id> 
          <phase>package</phase> 
          <goals> 
           <goal>war</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 
       <plugin> 
        <artifactId>maven-eclipse-plugin</artifactId> 
        <version>2.9</version> 
        <configuration> 
         <additionalProjectnatures> 
          <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> 
         </additionalProjectnatures> 
         <additionalBuildcommands> 
          <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> 
         </additionalBuildcommands> 
         <downloadSources>true</downloadSources> 
         <downloadJavadocs>true</downloadJavadocs> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>2.5.1</version> 
        <configuration> 
         <source>1.8</source> 
         <target>1.8</target> 
         <!-- <compilerArgument>-Xlint:all</compilerArgument> --> 
         <showWarnings>true</showWarnings> 
         <showDeprecation>true</showDeprecation> 
         <compilerArguments> 
          <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> 
         </compilerArguments> 
        </configuration> 
       </plugin> 
     </plugins> 
</pluginManagement> 

を::

mvn clean package 

または

mvn clean install 

代用プラグインが呼び出されていない私には、次の構成を有しています。なぜ誰に教えてもらえますか?それを動作させるために何ができるでしょうか?あるいはReplacerが将来のwarプラグインと互換性がない場合、誰も私に戦争を構築する前にjdbc.propertiesの文字列を置き換える他の方法を教えてもらえますか?

<pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>com.google.code.maven-replacer-plugin</groupId> 
      <artifactId>replacer</artifactId> 
      <version>1.5.2</version> 
... 

はPOMのため<build><plugins>ブロックを探す:

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 
    <executions> 
     <execution> 
      <id>deploy-ui</id> 
      <phase>package</phase> 
      <inherited>false</inherited> 
      <configuration> 
       <tasks> 
        <replace dir="${basedir}/src/main/resources"> 
         <include name="**/jdbc.properties" /> 
         <replacefilter token="%APP_NAME%" value="${env.BRANCH_NAME}"/> 
        </replace> 
       </tasks> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
+0

[Maven:what is pluginManagement?](http://stackoverflow.com/questions/10483180/maven-what-is-pluginmanagement)の可能な複製 –

答えて

1

プラグインが<pluginManagement>ブロックで定義されている..私はまた、アリのプラグインを見ましたが、同じ設定で、それは、以下の実施例..あまりにも呼ばれていません代替品は実行して、以下を追加する必要がある場合:

<plugin> 
    <groupId>com.google.code.maven-replacer-plugin</groupId> 
    <artifactId>replacer</artifactId> 
</plugin> 

プラグインの管理ではなく、プラグインが呼び出されたときにどうするかのテンプレートのようなものです。プラグインが<build><plugins>ブロックで参照されていない場合は、何も起こりません。

関連する問題