com.googlecode.jslint4java.ant
Class JSLintTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.googlecode.jslint4java.ant.JSLintTask
All Implemented Interfaces:
Cloneable

public class JSLintTask
extends org.apache.tools.ant.Task

Run JSLint over a tree of files in order to pick holes in your JavaScript.

Example build.xml usage:

 <project name="build-test" xmlns:jsl="antlib:com.googlecode.jslint4java">
   <target name="jslint">
     <jsl:jslint options="undef">
       <formatter type="plain" />
       <fileset dir="." includes="*.js" excludes="*.pack.js" />
     </jsl:jslint>
   </target>
 </project
 

You have to specify one or more nested fileset elements. You may optionally specify a formatter element in order to generate output (as opposed to just a build failed message). Usually, you will want the plain formatter, but in case you want to generate a report, the xml formatter mighht be useful.

Attributes

encoding
Optional. The encoding of the JavaScript files. Defaults to system encoding.
haltOnFailure
Optional. Specify if the build should fail if there are files which do not pass JSLint. Defaults to true.
options
Optional. A comma separated list of Option names. No default.
timeout
Optional. The maximum amount of time that JSLint can run.

Author:
dom
See Also:
jslint.com< /a>, FormatterElement

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
JSLintTask()
           
 
Method Summary
 void add(org.apache.tools.ant.types.ResourceCollection rc)
          Check the contents of this ResourceCollection.
 void addConfiguredFormatter(FormatterElement fe)
          Add in a ResultFormatter through the medium of a FormatterElement.
 void addPredef(PredefElement predef)
          Capture a predef element.
 void applyOptions(JSLint lint)
           
 void execute()
          Scan the specified directories for JavaScript files and lint them.
 JSLint makeLint()
          Create a new JSLint object.
 void setEncoding(String encoding)
          Set the encoding of the source files that JSLint will read.
 void setFailureProperty(String failureProperty)
          The name of a property to set upon failure.
 void setHaltOnFailure(boolean haltOnFailure)
          Should the build stop if JSLint fails? Defaults to true.
 void setJslint(File jslint)
          Specify an alternative version of jslint.
 void setOptions(String optionList)
          Set the options for running JSLint.
 void setTimeout(long timeout)
          Set the maximum time JSLint can run for in seconds.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSLintTask

public JSLintTask()
Method Detail

add

public void add(org.apache.tools.ant.types.ResourceCollection rc)
Check the contents of this ResourceCollection.

Parameters:
rc - Any kind of resource collection, e.g. fileset.

addConfiguredFormatter

public void addConfiguredFormatter(FormatterElement fe)
Add in a ResultFormatter through the medium of a FormatterElement.

Parameters:
fe -

addPredef

public void addPredef(PredefElement predef)
Capture a predef element.


applyOptions

public void applyOptions(JSLint lint)

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Scan the specified directories for JavaScript files and lint them.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

makeLint

public JSLint makeLint()
                throws org.apache.tools.ant.BuildException
Create a new JSLint object.

Throws:
org.apache.tools.ant.BuildException

setEncoding

public void setEncoding(String encoding)
Set the encoding of the source files that JSLint will read. If not specified, the default is the system encoding (via the file.encoding property). If that isn't present, default to UTF-8.

Parameters:
encoding - a valid charset identifier.

setFailureProperty

public void setFailureProperty(String failureProperty)
The name of a property to set upon failure. This property will contain the log message.


setJslint

public void setJslint(File jslint)
Specify an alternative version of jslint.


setHaltOnFailure

public void setHaltOnFailure(boolean haltOnFailure)
Should the build stop if JSLint fails? Defaults to true.

Parameters:
haltOnFailure -

setOptions

public void setOptions(String optionList)
                throws org.apache.tools.ant.BuildException
Set the options for running JSLint. This is a comma separated list of Option names. The names are case-insensitive.

NB: If you want to put an Option.PREDEF in here, you should use a <predef> child element instead. Otherwise, it could be difficult to specify a comma separated list as an element of a comma separated list…

Throws:
org.apache.tools.ant.BuildException

setTimeout

public void setTimeout(long timeout)
Set the maximum time JSLint can run for in seconds.



Copyright © 2007-2012. All Rights Reserved.