10

Is there an Maven plugin that just combines js and css resources but doesn't do any minification, obsucation, compressing etc? Just simple resources concatenation.

4 Answers 4

6

Make the following changes to your project:

  1. In your pom.xml, <dependencies> tag, place:

    <!-- JAVASCRIPT COMBINATION -->
    <dependency>
        <groupId>ro.isdc.wro4j</groupId>
        <artifactId>wro4j-core</artifactId>
    </dependency>
    
  2. In your pom.xml, <plugins> tag, place:

    <plugin>
        <groupId>ro.isdc.wro4j</groupId>
        <artifactId>wro4j-maven-plugin</artifactId>
        <version>1.4.3</version>
        <executions>
            <execution>
                <phase>process-resources</phase>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <targetGroups>allDev</targetGroups>
            <destinationFolder>${basedir}/src/main/webapp/</destinationFolder>
            <contextFolder>${basedir}/src/main/webapp/</contextFolder>
        </configuration>
    </plugin>
    
  3. In your pom.xml (or the parent pom.xml) <dependencyManagement> tag, place:

    <!-- JAVASCRIPT COMBINATION -->
    <dependency>
        <groupId>ro.isdc.wro4j</groupId>
        <artifactId>wro4j-core</artifactId>
        <version>1.8.0</version>
    </dependency>
    
  4. Create a wro.xml under /project/src/main/webapp/WEB-INF and place something like the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <groups xmlns="http://www.isdc.ro/wro">  
        <group name="allDev">  
            <js minimize="false">/my1stJsFolder/*.js</js>
            <js minimize="false">/my2ndJsFolder/*.js</js>
            <js minimize="false">/someFileDirectlyUnderWEBINF.js</js>
        </group>
    </groups>  
    
  5. In web.xml insert:

    <filter>
        <filter-name>WebResourceOptimizer</filter-name>
        <filter-class>ro.isdc.wro.http.WroFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>WebResourceOptimizer</filter-name>
        <url-pattern>/wro/*</url-pattern>
    </filter-mapping>
    

allDev.js will be generated under /project/src/main/webapp.

I am not sure yet how I could tell wro4j to only generate one in target (now you have two - one in the project source files and one in target).

When compressing with yui plugin I only get one in target. But this should not be that big of a problem for you.

For more:

ADDITIONALLY:

If you have any problems with the resource processing try adding to <build> tag:

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>

And also to <plugins> add

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>pdf</nonFilteredFileExtension>
            <nonFilteredFileExtension>swf</nonFilteredFileExtension>
            <nonFilteredFileExtension>jpg</nonFilteredFileExtension>
            <nonFilteredFileExtension>jpeg</nonFilteredFileExtension>
            <nonFilteredFileExtension>class</nonFilteredFileExtension>
            <nonFilteredFileExtension>jks</nonFilteredFileExtension>
            <nonFilteredFileExtension>exe</nonFilteredFileExtension>
            <nonFilteredFileExtension>wmv</nonFilteredFileExtension>
            <nonFilteredFileExtension>jar</nonFilteredFileExtension>
            <nonFilteredFileExtension>zip</nonFilteredFileExtension>
            <nonFilteredFileExtension>gz</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>  
Sign up to request clarification or add additional context in comments.

Comments

2

I think most tools will allow you to turn off the minification.

Here is another couple that look interesting:

http://jawr.java.net/

https://code.google.com/p/wro4j/

Comments

0

Looks about right :

http://hammerfest.sourceforge.net/maven-javascript-plugin/merge-mojo.html

1 Comment

I am guessing this won't work for a maven 3 project (I can see its a maven 2 project dependent). Also the jar is not available anywhere for download. I installed a newer version that apparently supports maven3 (mojo.codehaus.org/javascript-maven-tools/… repo1.maven.org/maven2/org/codehaus/mojo/…), but got "No plugin descriptor found at META-INF/maven/plugin.xml" when building. And also I cannot see a merge goal on this one. Is there any way we could get descent library that could deal with this?
0

I've used YUI Compressor for years. Used to do it in ANT, but there is also a maven plugin as well. The following link is an example for aggregation:

http://alchim.sourceforge.net/yuicompressor-maven-plugin/ex_aggregation.html

1 Comment

I did not find a way to turn off compression. You can do aggregation only after compression.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.