Search code examples
html5boilerplate

ANT build script CSSlint output xml


Is that any way to export CSSlint output to a valid XML format with ant build script?

I modified project.properties file in: tool.csslint.opts = --format=lint-xml section, but I think this is not enough, because csslint needs to specify output file like so:

csslint --format=lint-xml test.css > results.xml

How can I modify ant target to work?

Thank you.


Solution

  • Basics: Ant already has an output property. So you can just add the format option and output it to a file specified as an output property on the apply element. in an h5bp project this will output "output.xml" to the root of your project.

    <apply dir="${dir.source}/${dir.css}" 
         executable="java" parallel="true" 
         failonerror="true" output="output.xml">
    
        <fileset dir="./${dir.source}/">
                <include name="**/${dir.css}/*.css"/>
                <exclude name="**/*.min.css"/>
                <exclude name="**/${dir.publish}/"/>
            </fileset>
            <arg value="-jar" />
            <arg path="./${dir.build.tools}/${tool.rhino}" />
            <arg path="./${dir.build.tools}/${tool.csslint}" />
            <arg value="--format=lint-xml" />
            <srcfile/>           
    </apply>