Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

#This project is deprecated

I won't being performing any maintanence on this project other than merging pull requests that merge automatically.

My personal preference is now to use gulp + jshint instead.

#Ant task for JSHint

Easily automate JSHint ( validation on your Javascript code base with Apache Ant.

To get started download the ant-jshint jar file and include the following code in your Ant build file.

<!-- Define the task -->
<taskdef name="jshint" classname="com.philmander.jshint.JsHintAntTask" 
    classpath="${basedir}/jshint/ant-jshint-0.3.6-SNAPSHOT-deps.jar" />

<target name="runJsHint">
  <!-- Lint the code -->
  <jshint dir="${basedir}/src/js" includes="**/*.js" />

There is also a zip containing all the jars. To use them, unpack the zip and include the following code in your Ant build file.

<!-- Define the task -->
<taskdef name="jshint" classname="com.philmander.jshint.JsHintAntTask">
        <fileset dir="${basedir}/jshint" excludes="lib/closure*.jar" />
        <!-- make closure-compiler last in classpath -->
        <fileset dir="${basedir}/jshint" includes="lib/closure*.jar" />


###Task attributes

Attribute Description Required
dir The directory to scan for files to validate yes
options A comma separated list of jshint options. E.g. evil: true, maxlen: 100 no
optionsFile A java properties file containing a list of jshint options (Files with a '.json' extension will be interpreted as JSON). You may prefer this for managing a larger amount of options. The options parameter will override options specified in the options file no
globals A comma separated list of jshint globals. E.g. jQuery: true, myApp: true no
globalsFile A java properties file containing a list of jshint globals. You may prefer this for managing a larger amount of globals. The globals parameter will override options specified in the globals file no
fail Instructs the task to fail the build if any jshint errors are found no (defaults to true)
jshintSrc The task is packaged with jshint embedded, but an alternative jshint src file can be specified here no

The task is an implicit fileset. See for more parameters used for file matching or see the usage examples below.

If a .jshintrc file is present in the base directory of the project and no optionsFile attribute is specified, this will automatically be loaded as the optionsFile (interpreted as JSON)

###Nested elements


Attribute Description Required
type The type of report. Available values are plain, xml and jslint-xml (for compatibility with the JSLint plugins) no (defaults to 'plain')
destFile The file to write the report to yes

##Usage examples

###Typical fileset Lint all JS except minimized source files

<jshint dir="${basedir}/src/js">
    <include name="**/*.js"/>
    <exclude name="**/*.min.js"/>

###Setting JSHint options

<jshint dir="${basedir}/src/js" options="evil=true,forin=true,devel=false">
    <include name="**/*.js"/>
    <exclude name="**/*.min.js"/>

###Setting options in an external file

<jshint dir="${basedir}/src/js" optionsFile="${basedir}/jshint/">
    <include name="**/*.js"/>
    <exclude name="**/*.min.js"/>



###Specifying global variables

<jshint dir="${basedir}/src/js" globals="$:true">
    <include name="**/*.js"/>
    <exclude name="**/*.min.js"/>

###Use for reporting purposes The task will not fail upon jshint errors and will write results to a file in xml format:

<jshint dir="${basedir}/src/js" fail="false">
	<include name="**/*.js"/>
	<exclude name="**/*.min.js"/>
	<report type="xml" destFile="${basedir}/jshint/results.xml" />

Running the task in Maven

Ant-Jshint isn't deployed to the Maven Central Repository yet, but you can install locally either by cloning the project and running

mvn install

or downloading the jar release and running

mvn install:install-file -Dfile=/path/to/ant-jshint-0.3.6-SNAPSHOT-deps.jar -DgroupId=com.philmander.jshint -DartifactId=ant-jshint -Dversion=0.3.6 -Dpackaging=jar

Now use the antrun plugin to add jshint to your Maven build

					<taskdef name="jshint" classname="com.philmander.jshint.JsHintAntTask"
						classpathref="maven.plugin.classpath" />

					<jshint dir="${project.basedir}/src/js" options="evil=true,forin=true,devel=false">
						<include name="**/*.js" />
						<exclude name="**/*.min.js" />

Fork and run locally

Ant-Jshint is built using Apache Maven.

To run tests against your code run mvn test

To create a jar file run mvn package