开发者

Maven Filtering in building an Android application

开发者 https://www.devze.com 2023-03-21 15:04 出处:网络
I am using Maven (3.x) to build an Android application within Hudson. I use filtering/profiles to do text substition of the strings.xml file as part of the build.

I am using Maven (3.x) to build an Android application within Hudson. I use filtering/profiles to do text substition of the strings.xml file as part of the build.

So within the strings.xml, I will have entries such as:

<string name="app_name">${app_name}</string>

Within the pom.xml file, I have profile entries:

<profiles>
<profile>开发者_如何转开发;
    <id>local</id>
    <properties>
        <app_env>local</app_env>
        <app_name>Acme-loc</app_name>
    </properties>
</profile>  
<profile>
    <id>dev</id>
    <properties>
        <app_env>dev</app_env>
        <app_name>Acme-dev</app_name>
    </properties>
</profile>      
....

When I look inside the *.apk, the strings.xml file is substituted correctly. However, when installed in device, I see ${app_name} which leads me to believe that the substitution is happening after the compile of app (the R file is compiled before the substition). Has anyone used this approach successully and if so, how are you specifying which step of the build the substitution happens so that the substitution happens before the R file is compiled? Is there a better alternative to Maven filtering to achieve what I am looking for?


Either configure the maven-resources-plugin to fire in the generate sources phase, or use maven-replacer-plugin to do the replacement (which allows you to execute in any phase you wish).

0

精彩评论

暂无评论...
验证码 换一张
取 消