javascripteclipsemaven-2minifysts-springsourcetoolsuite

Eclipse (STS), Maven and maven-minify-plugin, can they work together?


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".


Solution

  • 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