Maven Filtering

試著忘記壹切 提交于 2019-12-06 04:31:51

In a standard maven build, resource filtering happens at process-resources, which comes before compile, which comes before package. It's hard to say more without more details about how you have resource filtering set up and how your package is built.

Edit: It looks like you're probably generating the R.java file using the android plugin's generate-sources goal, right? That's most likely bound to the generate-sources phase. Your strings.xml doesn't get filtered until the process-resources phase, which comes later in the build. You need to make sure that the android goal runs after the resource filtering happens and that it points at the output strings.xml file, not the source file.

There is an example of how to apply Maven resource filtering to Android resource files in the Maven-Android-Plugin samples, and also a brief discussion about it.

Specifically have a look at the Morseflash app pom.xml in the samples.

The key points are:-

  • run resource filtering during the initialize phase, putting the output into /target/filtered-res
  • configure the maven-android-plugin to then pickup it's resources from the filtered resources directory e.g.:

<resourceDirectory>${project.build.directory}/filtered-res</resourceDirectory>

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