RSS

Category Archives: apache ant

XINS 3.0 Beta1 Released

Just now I tagged 3.0-beta1 of my experimental XINS fork (which is not so experimental from the perspective that it has been running in production-sites since 2007).

Source and related stuff available from GitHub:

For a complete download, get this ZIP package:

Recent changes include:

  • Ant 1.8.0 is now properly supported
  • Logdoc definitions are now validated using XSDs (Logdoc 0.3 included)
  • Default runtime config file reload interval is now 5 instead of 60 seconds.
  • Not initializing logging subsystem (Log4J) if system property org.xins.server.logging.init is set to false.
  • Not setting context IDs (in Log4J terminology: NDC.push() calls) if property org.xins.server.contextID.push is set to false (system, bootstrap or runtime property).
 
Leave a comment

Posted by on 28 April 2010 in ant, apache ant, github, logdoc, xins, xins3

 

Improving Ant Output

>Ant is a very popular build tool in Java environments. Numerous tasks have been developed for it that allow integration with various services and products quite easy.

One area Ant could improve in is output. Running a typical build file produces a lot of output that is not really relevant to the user. Also, when an error occurs, it would be nice to have a stack trace giving more information, but then you need to rerun Ant with the -verbose option, which enables verbose output for all tasks, not just the failing one.

And note that there may be situations in which rerunning the task is suboptimal:

  • the error does not occur again (but it may come back to hunt you later on)
  • executing the build takes a lot of time

Here are some guidelines I propose for improving Ant output:

  1. keep output to stdout very limited;
  2. after completion of the build run, provide access to more output, including the stacktrace, without rerunning the task

Here’s an example of some Ant output:

-init-properties:

-init-site-properties:

check-questions:

transform-questions-xml:
[xmlvalidate2] 10 file(s) have been successfully validated.
[xslt] Transforming into /Users/ernst/albizia/build/contentdbsrc/xsite/content
[xslt] Processing /Users/ernst/albizia/build/contentdbsrc/xsite/content/AOW.QuestionsCategory.xml to /Users/ernst/albizia/build/contentdbsrc/xsite/content/Vragen_AOW.SourcePage.xml
[xslt] Loading stylesheet /Users/ernst/albizia/src/build-xslt/PreprocessQuestions.xslt
[xslt] Processing /Users/ernst/albizia/build/contentdbsrc/xsite/content/Berekenen.QuestionsCategory.xml to /Users/ernst/albizia/build/contentdbsrc/xsite/content/Vragen_Berekenen.SourcePage.xml

The output from the xmlvalidate2 task is very brief. That’s nice. In fact the question is whether the output should be shown at all. The output from the xslt task, however, is quite verbose. Instead of listing all files being processed, it could just give a summary of what it did. When -verbose is passed, it could output what is currently output.

Here are some possible options for achieving the goals I stated above:

  1. When a certain Ant option is enabled (which could at some point be enabled by default), send all verbose output to a file on the file system, for example build.log or .build.log. This file can be examined by the user after the build is finished (or cancelled).
  2. When using the default output mode for stdout, do not output the names of tasks that are not actually run (depending on the if and unless attributes).
  3. By default make all tasks just output a single line with a summary of what it did.
  4. Do not put an empty line between each executed task.
  5. When using this mode, use fixed-width output for the target names, and put the task output behind that. Target and task names may have to be cropped for that. For example:
    -init-prope.:
    -init-site-.:
    check-quest.:
    transform-q.:xmlvali.: 10 file(s) validated.
       xslt: 15 file(s) processed, 0 unmodified file(s) skipped.

Note that the output Ant 1.7.1 currently produces when running Ant with the -verbose option is always available after the build run, so the reduction of initial output is not limiting the investigation options for the user, but is in fact extending those.

What do you think of this? Do you consider the current Ant output too verbose or just fine? Have you every had issues examining why an Ant build failed and you wish you would have passed -verbose in the first place? And what do you think of the suggested changes?

 
4 Comments

Posted by on 3 September 2009 in ant, apache ant, output, stdout, verbose, verbosity

 

Ant Task for Invoking LessCSS (Updated)

>Update (August 26, 2009): I’ve polished the Ant task for LessCSS files quite a bit and implemented support for both lessc and plessc (the LessPHP alternative).

Features:

  • converts .less files to .css
  • supports both lessc and plessc (at least one is required)
  • supports time-outs
  • only processes changed files
  • supports separate source/target directories, with include/exclude patterns

It’s available under de BSD-license for download from github: http://github.com/znerd/lesscss-ant-task/.

Notes:

  • for lessc (tested lessc v1.1.13) to work to fail properly when lesscs fails, a minor change to one of the lessc files is required, this may be resolved in an upcoming version of the task and/or an upcoming version of lessc
  • plessc v0.1.6 works well with the task, but has a rather annoying bug related to negative background positions.

Below is the original blog post.


Here’s some sample code for implementating an Apache Ant task for invoking lesscss:
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.MatchingTask;

public final class LesscssTask extends MatchingTask {
public LesscssTask() {
setIncludes("*.less");
}

private File _sourceDir;
private File _destDir;

public void setDir(File dir) {
_sourceDir = dir;
}

public void setToDir(File dir) {
_destDir = dir;
}

@Override
protected void execute() throws BuildException {
for (String inFileName : getDirectoryScanner(_sourceDir).getIncludedFiles()) {
File inFile = new File(_sourceDir, inFileName);
String outFileName = inFile.getName().replaceFirst("\\.less$", ".css");
String outFilePath = new File(_destDir, outFileName).getPath();
String inFilePath = inFile.getPath();

log("lesscss: From \"" + inFilePath + "\" to \"" + outFilePath + "\".");

Execute.runCommand(this, new String[] { "lessc", inFilePath, outFilePath });
}
}
}

After defining the lesscss task in your build file (using a taskdef) invoking it is as simple as:

<lesscss dir="src/htdocs" todir="build/htdocs" />
 
Leave a comment

Posted by on 20 August 2009 in ant, apache ant, java, lesscss, task