Skip to content

Build System Integration

nzakas edited this page Oct 25, 2011 · 15 revisions

CSS Lint fits in well with any existing build or automation scripts.

Ant

It's easy to include CSS Lint as part of your Ant build system. The exact format of the task depends on which command line interface you're using.

Using Rhino

If you're using Rhino as your JavaScript engine, then make sure to download the Rhino version of CSS Lint from Git. Then, place the following target in your build.xml file:

<target name="csslint">       
    <fileset dir="${src.dir}" includes="**/*.css" id="cssfiles.raw"/>
    <pathconvert pathsep=" " property="cssfiles.clean" refid="cssfiles.raw" />
    <exec executable="java" failonerror="true">
        <arg line="-jar"/>
        <arg path="${lib.dir}/js.jar"/>
        <arg path="${lib.dir}/csslint-rhino.js" />      

        <!-- your customized arguments go here -->
        <arg line="${cssfiles.clean} --warnings=box-model,floats --errors=ids,important"/>
    </exec>        
</target>

This target assumpts that src.dir is the location of your CSS files and that lib.dir is the location of both the Rhino JAR file (js.jar) as well as the csslint-rhino.js file.

Using Node.js

If you're using the Node.js version of CSS Lint, then ensure you've installed the latest version using npm. Once installed, you can use the following Ant target:

<target name="csslint">       
    <fileset dir="${src.dir}" includes="**/*.css" id="cssfiles.raw"/>
    <pathconvert pathsep=" " property="cssfiles.clean" refid="cssfiles.raw" />
    <exec executable="csslint" failonerror="true"> 

        <!-- your customized arguments go here -->
        <arg line="${cssfiles.clean} --warnings=box-model,floats --errors=ids,important"/>
    </exec>        
</target>

Usage

Once you've created the target name, you can run from the command line via:

ant csslint

Maven

CSS Lint is included as part of the wro4j Maven plugin. You can define a Maven goal for CSS Lint using the following:

<plugins>
    <plugin>
        <groupId>ro.isdc.wro4j</groupId>
        <artifactId>wro4j-maven-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
            <execution>
                <goals>
                    <goal>csslint</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>

Read more about wro4j-maven-plugin.

Jenkins

Although the Violations Plugin doesn't natively support CSS Lint, you can run CSS Lint and have it output Checkstyle XML results that can be consumed by the plugin.

Clone this wiki locally