2014-04-02 1 views
1

Maven을 사용하여 Android 애플리케이션을 빌드합니다. 동일한 코드 기반으로 다른 앱을 만들어야했습니다. 그러나 각각에는 다른 주제가 포함되어 있습니다 (버튼 및 페이지 색상은 color.xml이고 드로어 블 폴더의 색상 아이콘). 각 앱을 출시하기 전에 매번 수동으로 교체합니다.빌드 중 color.xml 및 이미지 바꾸기

공구로이 작업을 쉽게 수행 할 수있는 방법을 제안 할 수 있습니까? 또는 원하는 디렉토리 경로를 제공하여 Maven을 통해 color.xml과 이미지를 바꿀 수 있습니까?

인터넷을 통해 검색했지만이 특정 문제에 대한 답변을 찾을 수 없습니다.

답변

1

당신은 당신이 당신의 pom.xml의 프로파일을 정의 할 필요가 maven profiles

resource plugin를 사용하여이 작업을 수행 할 수 있습니다

</profiles> 
    <profile> 
     <id>variantA</id> 
     <build> 
      <!-- custom conf for variant A --> 
     </build> 
    </profile> 
    </profile> 
    <profile> 
     <id>variantB</id> 
     <build> 
      <!-- custom conf for variant B --> 
     </build> 
    </profile> 
</profiles> 

그런 다음 원하는 프로파일로 빌드 invoque : 또한

mvn clean install -P variantB 

Resource 플러그인을 사용하면 전체 color.xml 파일을 덮어 쓸 수 있습니다 (이 예제에서는을 만듭니다).3210 파일 src/templates/resVariantA) :

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-resources-plugin</artifactId> 
    <executions> 
     <execution> 
      <phase>initialize</phase> 
      <goals> 
       <goal>copy-resources</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${project.basedir}/res</outputDirectory> 
       <overwrite>true</overwrite> 
       <resources> 
        <resource> 
         <directory>${project.basedir}/src/templates/resVariantA</directory> 
         <targetPath>${project.basedir}/res</targetPath> 
         <filtering>true</filtering> 
        </resource> 
       </resources> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

희망이 있습니다.

관련 문제