RSS

Category Archives: 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

 

Weird Error While Executing LessCSS

>This is really odd: I got the following output while running lessc on some .less files from an Apache Ant task:

-lesscss:
[003:221] MagicCam 0: Current process: java, Flash is loaded: no
[003:221] Error(magiccammac.cc:276): MagicCam 0: MagicCamOpen: Not an allowed process!
[000:002] MagicCam 0: Current process: java, Flash is loaded: no
[000:002] Error(magiccammac.cc:276): MagicCam 0: MagicCamOpen: Not an allowed process!
[000:001] MagicCam 1: Current process: java, Flash is loaded: no
[000:001] Error(magiccammac.cc:276): MagicCam 1: MagicCamOpen: Not an allowed process!
[000:002] MagicCam 1: Current process: java, Flash is loaded: no
[000:002] Error(magiccammac.cc:276): MagicCam 1: MagicCamOpen: Not an allowed process!
[lesscss] 0 file(s) transformed in 4 ms; 7 unmodified file(s) skipped.

Now I had it at a different point in the build process:

do-generate-headings:
Warning: Reference saxon.classpath has not been set at runtime, but was found during
build file parsing, attempting to resolve. Future versions of Ant may support
referencing ids defined in non-executed targets.
[xslt] Processing /Users/ernst/albizia/build/contentdb/pfizer/content/PreprocessedSite.xml to /Users/ernst/albizia/build/contentdb/pfizer/content/PageHeadings.ErigeronStrings.xml
[xslt] Loading stylesheet /Users/ernst/albizia/src/build-xslt/GeneratePageHeadings.xslt
[xmlvalidate2] 1 file(s) have been successfully validated.
[000:224] MagicCam 0: Current process: java, Flash is loaded: no
[000:224] Error(magiccammac.cc:276): MagicCam 0: MagicCamOpen: Not an allowed process!
[000:003] MagicCam 0: Current process: java, Flash is loaded: no
[000:003] Error(magiccammac.cc:276): MagicCam 0: MagicCamOpen: Not an allowed process!
[000:000] MagicCam 1: Current process: java, Flash is loaded: no
[000:001] Error(magiccammac.cc:276): MagicCam 1: MagicCamOpen: Not an allowed process!
[000:002] MagicCam 1: Current process: java, Flash is loaded: no
[000:002] Error(magiccammac.cc:276): MagicCam 1: MagicCamOpen: Not an allowed process!

There is a tiny bit of information here:

 
1 Comment

Posted by on 22 September 2009 in ant, flash, google talk, googletalk, java, lesscss, magiccam, magiccamopen

 

OptiPNG Ant Task

>OptiPNG is a tool for optimizing PNG images. And now, there’s an Ant task for executing it from an Ant build file:

Mini-HOWTO for Linux/UNIX/Mac OS X systems, assuming you already have Apache Ant installed:

  1. download OptiPNG source code from SourceForge (TAR GZ file)
  2. execute: ./configure
  3. execute: make
  4. execute: sudo make install
    (enter your password if required); the command optipng is now installed in /usr/local/bin/
  5. download the optipng-ant-task source code from http://github.com/znerd/optipng-ant-task/downloads – take the latest version available (you can choose between a ZIP and a TAR GZ file)
  6. unpack the download file, this will create a new directory with an odd name like: znerd-optipng-ant-task-604de975b4cc4a1a2766e385c91b749318af038e (you may want to rename it to optipng-ant-task or so)
  7. in that directory, execute: ant
    this will compile the classes, run the available unit test and build the JAR file

Then you can use the Ant task from your own build file, for example as follows:

<taskdef name="optipng" classname="com.pensioenpage.jynx.optipng.OptiPNGTask" classpath="lib/optipng-ant-task.jar" />
<optipng dir="src/htdocs" todir="build/htdocs" />

 
Leave a comment

Posted by on 8 September 2009 in ant, optipng, png, task, taskdef

 

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

 

>Eclipse on Mac OS X

>
Because I wanted to apply some automated refactoring, I decided to give Eclipse a chance, after sticking with Vim for years. I tried other tools, but always fell back to Vim, because it just works very good for me.

Here’s some of the things I found:

  • Creating a new project from an existing Ant build file works flawlessly.
  • The look-and-feel is not exactly Mac-like, but the integrated window with panels inside are a lot more screenspace-efficient than the floating windows that typical Mac applications (e.g. Keynote) offer.
  • Customizing Java code style preferences is intuitive and powerful.
  • Keyboard shortcuts are properly converted to Ma-style (e.g. Shift-Cmd-L).
  • The Save As command is not bound to the standard keybaord shortcut Shift-Cmd-S. Instead, this keyboard combo saves all files.
  • Refactoring tools work very well.
  • By default, the Javadoc for the JDK is not found, so hovering over a JavaSE class, such as java.lang.Object, does not show a description, but rather an error message. I would expect this to be standard functionality, perhaps offered as an option during installation or at least as a warning (e.g. “Unable to find Javadoc for JDK”).
  • There does not seem to be a way to indent variable declarations like this:
int       groupCount = groups.length;
int itemGroupSpacing = _config.getItemGroupSpacing();
  • Code completion is more advanced than in Vim; the alternative for Ctrl-P in Vim seems to be Ctrl-Period in Eclipse, but Eclipse also offers Ctrl-Space.
  • Cmd-P shows a Page Setup dialog, instead of a standard Print dialog.
  • The About dialog is referenced both from the program menu and from the Help menu.
  • Triple-click (with the left mouse button) does not select the whole line. This is a typical mouse shortcut with editors.

I tested Eclipse 3.2.1. The current version may be (even) better.

 
Leave a comment

Posted by on 6 August 2007 in ant, eclipse, java, refactoring, vim