android-maven-plugin and resource filtering

回眸只為那壹抹淺笑 提交于 2019-11-30 22:59:03

Now it works, i change <resourceDirectory>${project.build.directory}/filtered-assets</resourceDirectory> to <assetsDirectory>${project.build.directory}/filtered-assets</assetsDirectory>. Results POM:

<properties>
    <myProperty>MY PROPERTY!!!!111</myProperty>
</properties>

    <resources>
        <resource>
            <directory>${project.basedir}/assets</directory>
            <filtering>true</filtering>
            <targetPath>${project.build.directory}/filtered-assets</targetPath>
            <includes>
                <include>**/*.properties</include>
            </includes>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <phase>initialize</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <sdk>
                    <platform>8</platform>
                </sdk>
                <emulator>
                    <avd>2.3.3_API-10</avd>
                </emulator>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
                <assetsDirectory>${project.build.directory}/filtered-assets</assetsDirectory>
            </configuration>
            <extensions>true</extensions>
        </plugin>

If you are specifying the property in your pom you shouldn't have it declared in a separate file as well. Conversely, if you want to specify it in a separate file you shouldn't declare it in your POM.

However, I am not sure exactly what you are trying to do - maven properties are only valid within your pom file and are for use during the build process. You can't access them from within your application. Android/java have no idea they exist and can't see them, so the reason you see the ${helloFromPOM} in your code instead of MY PROPERTY is that android/java is just displaying the text - it doesn't know that it stands for a property and it has no way to parse it into a variable or other value.

Mood

Sometimes it's caused by an inappropriate platform version. Try to set it right in your pom file. Look for smthg like

<sdk>
    <platform>17</platform>
</sdk>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!