Skip to content
stubbornella edited this page Sep 10, 2012 · 3 revisions

CSS Lint uses a build system to make updating code faster and easier. Doing so allows a simple, clean directory and file structure that is easy to navigate and expand upon without needing to reference dozens of JavaScript files in a page. Understanding the build system is key to working with the CSS Lint source code.

Installing Ant

In order to build CSS Lint, you must first download and install Ant. Ant is a Java-based command line build tool that works with the build.xml file found in the root directory.

If you're using Mac OS X, Ant is already installed for you. If for some reason it's not installed, be sure to install MacPorts and run:

sudo port install apache-ant

If you're using Ubuntu, you can simply type:

sudo apt-get install ant

Other operating systems should refer to http://ant.apache.org/manual/install.html for more information.

The build targets

Ant works by defining build targets. A target is really just a collection of steps to take. CSS Lint has several build targets:

  • build.core - builds the core CSS Lint JavaScript library
  • build.worker - builds the CSS Lint JavaScript Web Worker
  • build.rhino - builds the CSS Lint JavaScript CLI for Rhino
  • build.node - builds the CSS Lint JavaScript CLI for Node.js
  • build.tests - combines all unit tests into a single file
  • build.docs - processes the documentation files and places them in the build directory
  • build.all - executes all of the previous targets (those beginning with build.)
  • changelog.update - automatically updates the CHANGELOG file with change information (admin use only)
  • lint - runs lint tools on the source code to find possible errors
  • release - prepares an official release by inputting version numbers and copying files to release directory (admin use only)
  • parser.update - downloads the latest version of the CSS parser and installs it in the lib directory
  • test - builds everything, runs lint tools on the source code, and runs all unit tests on the command line

In order to run a particular target, go into the csslint directory and use the following command:

ant <target>

For instance, if you just want to build the tests, run this:

ant build.tests

If you want to build everything, type:

ant build.all

Since build.all is the default target, you can shorten this by simply typing:

ant

When there is no target specified on the command line, Ant will automatically use the default. build.all is the most frequently run target so it is set as the default.

Note: It's important that you run this command only in the csslint directory. Builds do not work in subdirectories.

The build.xml file

Ant uses the build.xml to define targets and other related information. In general, you won't ever need to touch this file unless you're creating a new build target.

The property csslint.version is defined at the top of the file. This version number is embedded in the source files when the release target is run. This value should not be changed except by the CSS Lint maintainers.

Workflow

Whenever you make changes to the CSS Lint source files, you'll need to run the build.all target to regenerate the combined source files. The workflow is:

  1. Make changes
  2. Run ant test to build and run tests on the command line

If you want to run CSS lint on node against a specific css file during development, your workflow will need to be a bit different.

  1. Make changes
  2. Run ant test to build and run tests on the command line
  3. Edit build/npm/package.json give it a version number like 1.0.0
  4. Run [sudo] npm link (in the build/npm dir)
  5. Run csslint <options> <file-name>

You'll have to do this each time you make a change. It can be helpful to begin development using only tests, then when the code is more or less stable, test it against specific files.

Clone this wiki locally