Greg's Blog

helping me remember what I figure out

Maven Example POM File to Build With Jasmine, JSlint, SASS and YUI

| Comments

Since we seem to be repeating these steps time and again here’s an example of a POM file to run JSLint, Jasmine, SASS and YUI as part of the build Maven build process:
<build>
   <plugins>
        <plugin>
            <groupId>com.github.searls</groupId>
            <artifactId>jasmine-maven-plugin</artifactId>
            <version>1.2.0.0</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <jsSrcDir>${project.basedir}/src/main/js</jsSrcDir>
                <jsTestSrcDir>${project.basedir}/src/test/js</jsTestSrcDir>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.jasig.maven</groupId>
            <artifactId>sass-maven-plugin</artifactId>
            <version>1.0.0</version>
            <executions>
                <execution>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>update-stylesheets</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <sassSourceDirectory>${project.basedir}/src/main</sassSourceDirectory>
                <baseOutputDirectory>${project.build.directory}/classes/assets/stylesheets</baseOutputDirectory>
                <sassOptions>
                    <cache_location>'${project.build.directory}/sass_cache'</cache_location>
                    <always_update>true</always_update>
                    <style>:compressed</style>
                </sassOptions>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                    <version>13.0.1</version>
                </dependency>
            </dependencies>
        </plugin>

        <plugin>
            <groupId>com.googlecode.jslint4java</groupId>
            <artifactId>jslint4java-maven-plugin</artifactId>
            <version>2.0.2</version>
            <executions>
                <execution>
                    <id>lint</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>lint</goal>
                    </goals>
                    <configuration>
                        <failOnError>true</failOnError>
                        <sourceFolders>
                            <sourceFolder>${project.basedir}/src/main/js</sourceFolder>
                        </sourceFolders>
                        <options>
                            <predef>jQuery, $</predef>
                            <browser>true</browser>
                        </options>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <version>1.3.0</version>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <nosuffix>true</nosuffix>
                <preserveAllSemiColons>true</preserveAllSemiColons>
                <sourceDirectory>${project.basedir}/src/main/js/</sourceDirectory>
                <outputDirectory>${project.build.directory}/js-min/</outputDirectory>
                <excludes>
                    <exclude>**/vendor/*.js</exclude>
                </excludes>
                <aggregations>
                    <aggregation>
                        <insertNewLine>true</insertNewLine>
                        <output>${project.build.directory}/classes/assets/js/all.js</output>
                        <includes>
                            <include>${project.build.directory}/js-min/HelloWorld.js</include>
                        </includes>
                    </aggregation>
                </aggregations>
            </configuration>
        </plugin>
    </plugins>
</build>