我想知道在Maven资源过滤中是否有一种方法来执行if条件语句。例如,允许我执行以下操作:
somefile.txt:
...
#if($some.project.property == true)
some text to include here
#endif
...
与Velocity类似的东西。
简短回答是否。但如果你真的需要条件,你可以查看velocity-maven-plugin,它可以解决你的问题。但它并不是用于过滤资源的,但在你的使用情况下可能会有效。
<plugin>
<groupId>com.googlecode.velocity-maven-plugin</groupId>
<artifactId>velocity-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<templateFiles>
<directory>/src/main/resources</directory>
<includes>
<include>*.vm</include>
</includes>
</templateFiles>
<templateValues>
<test>foo</test>
</templateValues>
</configuration>
</plugin>
在某些情况下,仅设置属性(每个配置文件)可能是有用的。
<yourProperty><![CDATA[ <your> <block>of code</block> </your> ]]></yourProperty>
${variable}
能正确打印吗? - Sergiu Dumitriu