2

maven을 사용하여 jdbc.properties에서 % APP_NAME % 문자열을 환경 변수로 바꾸려고합니다. 내가 호출 할 때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 plugin과 호환되지 않는다면 누가 전쟁을 구축하기 전에 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 : 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> 블록에서 참조되지 않으면 아무 일도 일어나지 않습니다.

관련 문제