Saturday, September 3, 2011

JVM classpath integration (Maven et. al.)

Disclaimer: I loathe Maven. But I love users, so by unpopular (to me) demand as part of the upcoming abcl-0.27.0 release we've bowed to the inevitable by adding integration for Armedb Bear Common Lisp with Maven in svn r13550.

We've added the ASDF:MVN subclass ASDF:COMPONENT (by way of of ASDF:IRI) that refers to a purely virtual artifact, namely a given jar specified as a mvn dependency whose classes will be loaded in the hosting JVM (i.e. added to the running *classpath*).

The following 'log4j.asd' placed in a file on your local filesystem and then added the the ASDF:*CENTRAL-REGISTRY*:
     ;;;; -*- Mode: LISP -*-

(in-package :asdf)
(defsystem :log4j
:components ((:mvn "log4j/log4j"
:version "1.4.9")))

then when the abcl-contrib.jar is loaded via

CL-USER> (require 'abcl-asdf)

an invocation of

CL-USER> (asdf:load-system 'log4j)

with ensure that log4j-1.4.9.jar and all its transitive dependencies as defined by the distributed Maven POM descriptions will be downloaded to the local filesystem if not already present. It will then dynamically add all of these Java classes to the currently hosting JVM.

Further details about additional ASDF extensions for both individual jar files and contents of directories are documented within the contrib/abcl-asdf/README.markdown file from SVN trunk.

Thanks to Alan Ruttenburg for great inspiration (and code) from invoke.lisp which was the first extension to ASDF that could actuall dynamically add jar files to the hosting JVM process.


  1. This comment has been removed by the author.

  2. Unfortunately, we managed to ship abcl-0.27.0 with one too many parentheses, so the ABCL-ASDF contrib doesn't compile. To fix, either update with or wait a week or so for abcl-0.27.1.