[英]Maven replacer plugin, regex no working
我正在使用Maven进行项目,并使用maven-replacer-plugin将我的所有CSS / javascript文件替换为缩小版本。
我要替换为:
<!-- JSMIN js/script.min.js -->
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="js/jquery.placeholder.min.js"></script>
<script src="js/smoothscroll.js" async=""></script>
<script src="js/javascript.js"></script>
<script src="js/swfobject.js"></script>
<script src="js/player.js"></script>
<!-- END JSMIN -->
有了这个:
<script src="js/script.js"></script>
类似的CSS。
该插件说,它已将正则表达式应用于我的4个html文件,这是正确的,但我看不到这些文件的更改。
这是插件的配置
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${project.basedir}/src/main/webapp/</basedir>
<outputDir>test</outputDir>
<includes>
<include>**/*.html</include>
</includes>
<regexFlags>
<regexFlag>CASE_INSENSITIVE</regexFlag>
<regexFlag>MULTILINE</regexFlag>
<regexFlag>DOTALL</regexFlag>
</regexFlags>
<replacements>
<replacement>
<token><!-- JSMIN (.*) -->(.*?(\r))+.*?<!-- END JSMIN --></token>
<value><script src="$1"></script></value>
</replacement>
<replacement>
<token><!-- CSSMIN (.*) -->(.*?(\r))+.*?<!-- END CSSMIN --></token>
<value><link href="$1" rel="stylesheet" type="text/css"/></value>
</replacement>
</replacements>
</configuration>
</plugin>
正则表达式对我和我的同事来说似乎是正确的...有什么帮助吗? 提前致谢
http://code.google.com/p/maven-replacer-plugin/wiki/UsageWithOtherPlugins
在将替换文件打包到战争中之前,需要有一个挂钩来运行替换文件。 如果两者都在同一阶段执行,请确保将它们添加在maven-replacer-plugin之前(即prepare-package)。 确保使用2.0.1或更低版本的war插件,因为常用的2.1.0+会复制资源两次,从而覆盖替换资源。 使用以下war插件配置,可以在打包文件之前对其进行修改。
我已将您的代码复制粘贴到测试pom中,并且工作正常。
确定要检查正确的文件吗? 更新的文件在/ src / main / webapp / test中
M.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.