Given the lisp way of 1-to-1 correspondence between a lisp file and a fasl, I expected this to be a trivial task to be done at the build system level. So, I kept searching for a solution in Ant (using standard components only). Surely I found the pathconvert and mapper building blocks, however, neither really seemed to work as the latter turned out not to be a generic mechanism but to be supported only by specific tasks (such as apply) and the former converts its output to a string instead of a set of paths.
Realizing that the issue of mapping source paths to output paths was left to the individual tasks, I turned to abcl to solve the problem as part of the compilation script. The final script between the CDATA tags as presented in the previous post looks like this:
(let* ((the-project (jcall "getProject" self)) (src-iterator (jcall (jmethod "org.apache.tools.ant.types.Path" "iterator") (jcall "getReference" the-project "lisp-files"))) (src-wildcard (pathname (format nil "~A**/*.lisp" (jcall "getProperty" the-project "build.src.dir")))) (dst-wildcard (pathname (format nil "~A**/*.abcl" (jcall "getProperty" the-project "build.dst.dir"))))) (when (and (jcall "hasNext" src-iterator)) (loop for src-path = (pathname (jcall (jmethod "java.lang.Object" "toString") (jcall "next" src-iterator))) for dst-path = (translate-pathname src-path src-wildcard dst-wildcard) do (compile-file src-path :output-file dst-path) while (and (jcall "hasNext" src-iterator)))))
It's based on 2 properties having been defined: "build.src.dir" and "build.dst.dir". In addition, it wants a set of paths (fileset or path set) to be defined called "lisp-files". Iterating over the set of source files, it calculates the output file by replacing a path prefix and the file extension.
In my NetBeans project settings, I had to exclude "**/*.lisp" from packaging in the destination JAR file.
Now the JAR contains the fasl instead of the source file!
Do you have useful or resourceful ABCL based scripts plugged into Ant? Let me know and post a reaction.