Perry Hoekstra
Perry Hoekstra

Reputation: 69

Maven Filtering in building an Android application

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?

Upvotes: 0

Views: 366

Answers (1)

Steven
Steven

Reputation: 3894

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).

Upvotes: 1

Related Questions