2013-05-28 1 views
4

나는 이렇게 정의 된 maven 프로파일을 가지고있다;Maven에서 프로파일 간의 프로파일 구성을 쉽게 공유 할 수 있습니까?

<profile> 
      <id>instrumentation</id> 
      <activation> 
       <activeByDefault>false</activeByDefault> 
       <property> 
        <name>instrumentation.enabled</name> 
        <value>true</value> 
       </property> 
      </activation> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>cobertura-maven-plugin</artifactId> 
         <version>2.5.1</version> 
         <configuration> 
          <formats> 
           <format>xml</format> 
           <format>html</format> 
          </formats> 
          <instrumentation> 
           <ignores> 
           </ignores> 
           <excludes> 
            <exclude>**/Test*.class</exclude> 
            <exclude>**/Abstract*.java</exclude> 
            <!-- Log Classes --> 
            <exclude>**/Log.class</exclude> 
            <!-- Exception Classes --> 
            <exclude>**/*Exception.class</exclude> 
           </excludes> 
          </instrumentation> 
         </configuration> 
         <executions> 
          <execution> 
           <phase>prepare-package</phase> 
           <goals> 
            <goal>cobertura</goal> 
           </goals> 
          </execution> 
         </executions> 
        </plugin> 
        <plugin> 
         <artifactId>maven-resources-plugin</artifactId> 
         <version>2.6</version> 
         <executions> 
          <execution> 
           <id>copy-resources</id> 
           <phase>package</phase> 
           <goals> 
            <goal>copy-resources</goal> 
           </goals> 
           <configuration> 
           <!-- this is important --> 
            <overwrite>true</overwrite> 
            <!-- target --> 
            <outputDirectory>${env.DERBASE}/java/${project.artifactId}/target/classes</outputDirectory> 
            <resources> 
             <resource> 
             <!-- source --> 
              <directory>${env.DERBASE}/java/${project.artifactId}/target/generated-classes/cobertura</directory> 
             </resource> 
            </resources> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 

그래서이 행을 변경하고 싶습니다.

<goal>cobertura</goal> 

this to this; 이러한 INSTRUMENTATION_EXCLUDE_TESTS 같은 ENV 변수가 설정되면

<goal>instrumentation</goal> 

.

이 작업을 수행하는 가장 좋은 방법은 무엇일까요? (즉, 단일 행이 변경된 프로필을 복사하여 붙여 넣기하지 않고)

감사합니다.

답변

2

그래서 환경 변수를 설정하여이 문제를 해결했습니다.

export COBERTURA_GOAL=cobertura 

또는

export COBERTURA_GOAL=instrument 

다음, 내 치어에서 다음 속성을 정의;

<cobertura.goal>${env.COBERTURA_GOAL}</cobertura.goal> 

<goal>${cobertura.goal}</goal>