söndag 29 januari 2012

Zip-filter.xml

I've added som examples of the zip-filter.xml/xml-> at the great site ClojureDocs.org.

I'm not sure it's always the best tool to use to generate xml, I'm still looking for a good way to represent complicated (or, should I say, complected) xml structures.

Search and replace of tokens in an XML-template should also works in many pure generate some xml-file cases.

lördag 28 januari 2012

Using Leiningens java-source-path

There's a functionality :java-source-path in Leiningen.

I wanted to know whether this compiled the java-sources in sub-folders as well, and could handle packages-notation, a good functionality when already having a code base in java . Leiningen did not put me down, it did take good care of all this.

I added a

:java-source-path "java"

to Leiningen's project.clj. And then

mkdir java/se/linusericsson/www

where I created a small TestPackage.java:

package www.linusericsson.se;
public class TestPackage {
int i = 100;
public int geti() {return i}
public void seti(int j) {i = j;}}

I ran lein javac (says something like one file compiled)

in lein repl

(import 'www.linusericsson.se.TestPackage)
(def tp (TestPackage.))
(.geti tp)
=> 100
(.seti 145 tp)
(.geti tp)
=>145 ;;OK!

note:
(Xxx.) means new Xxx in java.
(.geti ) is part of the standard java interop for clojure.