我正在尝试过滤项目资产目录中的属性文件。这样我就不必在我的应用程序的dev,SIT和prod版本之间不断更改值。我正在使用maven& intelliJ IDEA(最终)有不同的配置文件,但目前我只是想让构建过程获取过滤后的资产目录(如果可能的话)
我已将这些资源行添加到我的POM中:
<resource>
<filtering>true</filtering>
<directory>assets</directory>
<includes>
<include>**/*.properties</include>
</includes>
<targetPath>
../assets
</targetPath>
</resource>
<resource>
<filtering>false</filtering>
<directory>assets</directory>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
<targetPath>
../assets
</targetPath>
</resource>
有没有办法让构建过程查看过滤后的资产目录?
答案 0 :(得分:4)
试试这个:
<build>
<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>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>maven-android-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<sdk>
<platform>7</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<resourceDirectory>${project.build.directory}/filtered-assets</resourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
查看MorseFlash示例项目here。