yuicompressor maven插件和maven-war-plugin [英] yuicompressor maven plugin and maven-war-plugin
问题描述
我一直在努力使此插件与maven-war-plugin很好地兼容,这已经有两个小时了,我认为现在是时候寻求帮助了.我的插件定义如下:
I've been struggling with getting this plugin to play nicely with the maven-war-plugin for a couple of hours now and I thought it was time to ask for help. I have the plugin defined as follows:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<id>compressyui</id>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<jswarn>false</jswarn>
</configuration>
</execution>
</executions>
</plugin>
如果我删除nosuffix = true,那么我可以看到压缩/缩小的-min.js文件按预期进入战争,但是带有此标志的文件被maven-war-plugin覆盖(我假设),当它生成war文件时.我确实确实需要文件名保持不变……有人会知道我需要更改什么才能使用相同的文件名,同时仍将最小化版本打入最后一战吗?
If I remove nosuffix=true then I can see the compressed/minified -min.js files get into the war as expected, but with this flag on they are being overwritten by the maven-war-plugin (I'm assuming) when it builds the war file. I really need the file names to remain the same though ... does anyone have an idea of what I need to change in order to use the same filenames and still get the minified versions into the final war?
推荐答案
确定.我终于想通了.您需要在yuicompressor插件中定义<webappDirectory>
,然后可以在maven-war-plugin中将其引用为<resource>
.在下面的示例中,我正在使用 <directory>${project.build.directory}/min</directory>
OK. I finally figured this out. You need to define a <webappDirectory>
in the yuicompressor plugin that can then be referenced as a <resource>
in the maven-war-plugin. In the example below I'm using <directory>${project.build.directory}/min</directory>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<id>compressyui</id>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<webappDirectory>${project.build.directory}/min</webappDirectory>
<jswarn>false</jswarn>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
<configuration>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<encoding>UTF-8</encoding>
<webResources>
<resource>
<directory>${project.build.directory}/min</directory>
</resource>
</webResources>
</configuration>
</plugin>
这篇关于yuicompressor maven插件和maven-war-plugin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!