Eclipse(STS),Maven和maven-minify-plugin可以一起工作吗? [英] Eclipse (STS), Maven and maven-minify-plugin, can they work together?

查看:141
本文介绍了Eclipse(STS),Maven和maven-minify-plugin可以一起工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个我负责html,css和javascript的项目。我发现这个 maven-minify-plugin 似乎只是我想要的。



当我在服务器上部署maven时,一切都很好,但是当我使用Eclipse(STS,www.springsource.com/products/sts)运行项目时在本地主机上没有css和js文件是由插件生成的。



有没有人有这个Maven插件的经验,所以他们可以告诉我,如果应该可能或不运行在本地主机?有没有人知道另一个插件,我可以使用(组合和)minify javascript和css文件,当在本地主机在Eclipse中运行时,以及使用Maven进行部署?



任何帮助赞赏...



----额外信息----



我基本上只是复制了它在插件网页上说,所以我在pom.xml中有这些位:

  .... 
<建立>
< plugins>
....
< plugin>
< groupId> com.samaxes.maven< / groupId>
< artifactId> maven-minify-plugin< / artifactId>
< version> 1.1< / version>
<执行>
< execution>
< id> default-minify< / id>
< phase> process-resources< / phase>
< configuration>
< cssFiles>
....
< param> forms.css< / param>
< param> jquery.droppy.css< / param>
< param> jquery.jgrowl.css< / param>
< / cssFiles>
< jsFiles>
....
< param> jquery.droppy.js< / param>
< param> jquery.jgrowl.js< / param>
< / jsFiles>
< jsFinalFile> script.js< / jsFinalFile>
< linebreak> -1< / linebreak>
< nomunge> false< / nomunge>
< verbose> false< / verbose>
< preserveAllSemiColons> false< / preserveAllSemiColons>
< disableOptimizations> false< / disableOptimizations>
< bufferSize> 4096< / bufferSize>
< / configuration>
< goals>
< goal> minify< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>
....

应该/可以将插件绑定到差异阶段吗? / p>

我只是使用 mvn clean package ,并将快照移动到tomcat中以在服务器上部署。



我不确定如何解释如何在本地主机上运行webapp,但这里。我有一个vanilia tomcat,我在Eclipse中定义为一个服务器,然后定义webapp应该始终构建在server中。

解决方案

minify插件通常是绑定到进程资源阶段。这是你做的吗



更新:插件配置看起来很好(这是通过命令行构建按预期工作的事实证实的)。也许检查你是否在资源更改中调用Eclipse中的 process-resources 。为此,请在项目中右键单击,然后单击属性> Maven>生命周期映射,并找到与下面的捕获相似的内容(我使用M2Eclipse 0.10.0这可能会有所不同)



alt text http://img519.imageshack.us/img519/2817/screenshot009d.png


I am working on a project where I am in charge of html, css and javascript. I found this maven-minify-plugin that seemed to just what I wanted.

Everything is good when I deploy using maven on the server, but when I am using Eclipse (STS, www.springsource.com/products/sts) to run the project on localhost no css nor js file is generated by the plugin.

Does anyone have experience with this Maven plugin, so they can tell me if it should be possible or not run on localhost? Does anyone have knowledge of another plugin I can use to (combine and) minify javascript and css files when running on localhost in Eclipse and also when deploying using Maven?

Any help appreciated...

----extra information----

I basicly just copied in what it said on the plugin webpage, so I have these bits in my pom.xml:

....
<build>
    <plugins>
        ....
        <plugin>
            <groupId>com.samaxes.maven</groupId>
            <artifactId>maven-minify-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <id>default-minify</id>
                    <phase>process-resources</phase>
                    <configuration>
                        <cssFiles>
                            ....
                            <param>forms.css</param>
                            <param>jquery.droppy.css</param>
                            <param>jquery.jgrowl.css</param>
                        </cssFiles>
                        <jsFiles>
                            ....
                            <param>jquery.droppy.js</param>
                            <param>jquery.jgrowl.js</param>
                        </jsFiles>
                        <jsFinalFile>script.js</jsFinalFile>
                        <linebreak>-1</linebreak>
                        <nomunge>false</nomunge>
                        <verbose>false</verbose>
                        <preserveAllSemiColons>false</preserveAllSemiColons>
                        <disableOptimizations>false</disableOptimizations>
                        <bufferSize>4096</bufferSize>
                    </configuration>
                    <goals>
                        <goal>minify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
....

Should/Can I bind the plugin to a difference phase?

I just use mvn clean package and move the snapshot into tomcat to deploy on the server.

I am unsure on how to explain how I run the webapp on localhost, but here goes. I have a vanilia tomcat, that I defined as a server in Eclipse and then defined that the webapp should always build in that "server".

解决方案

The minify plugin is typically bound to the process-resources phase. Is this what you did?

Update: The plugin configuration looks fine (and this is confirmed by the fact that a command line build works as expected). Maybe check that you're calling process-resources inside Eclipse on resource changes. To do so, right-click on your project, then Properties > Maven > Lifecycle Mapping and find something equivalent to the capture below (I'm using M2Eclipse 0.10.0 so it might be different for you).

alt text http://img519.imageshack.us/img519/2817/screenshot009d.png

这篇关于Eclipse(STS),Maven和maven-minify-plugin可以一起工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆