use*_*448 6 resources gwt placeholder maven
我有gwt web项目,它必须使用在代码中作为TextResource加载的application.properties(在客户端).一切正常,但现在我想集中maven pom.xml中的所有属性值.所以我使用像key1 = $ {param1}这样的占位符创建了application.properties,并在pom.xml中配置了属性param1Value
所以,发生的事情是maven替换了目标dir中application.properties中的占位符,但似乎gwt编译器使用src/main/resources中的application.properties文件.我检查了已编译的js文件,我可以看到占位符没有替换为pom.xml中的值(目标的application.properties是正确的).
更新:问题是,我正在过滤的属性文件是一个gwt消息资源包文件,从我看到,maven创建一个"生成"文件夹,并根据根项目源中找到的属性文件放置生成的java文件文件夹而不是目标文件夹.之后,它将它合并到javascript通用文件中.这意味着我有两种可能性:1)告知资源插件覆盖位于源文件夹的属性文件(我不是与冷静,因为我会certanly对未来颠覆更新问题)2)告诉GWT-Maven的插件在target/classes文件夹中查找属性文件,我认为这是不可能的
你怎么看 ?
我通过使用 resources:copy-resources 执行和 build-helper 插件解决了同样的问题。特别是配置资源插件:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filter-sources</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>${project.build.directory}/gwt-extra</outputDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/filtered-sources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
并使用构建助手包含它:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source-gwt</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/gwt-extra</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)