0

I am using the method proposed in this answer to compile Clojure *.clj files to *.class (and subsequently jar them), using more or less the structure of the compile-clojure target from the build.xml file that's found at the root of the Clojure distribution (e.g. in clojure-1.5.1.zip). In my case:

<java classname="clojure.lang.Compile" 
      failonerror="true"
      fork="true">
  <classpath refid="compile.classpath"/>
  <sysproperty key="clojure.compile.path" value="${cljbuild.dir}"/>
  <arg value="${project.MainClass.name}"/>
</java>

The problem with this approach is that it keeps compiling the *.clj files even though they haven't changed. Any ways around this?

Community
  • 1
  • 1
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
  • Is this a mixed Java/Clojure/Something-else project? Is there a strong reason not to use Leiningen? – Arthur Ulfeldt Oct 14 '13 at 23:38
  • @ArthurUlfeldt: It's a mixed Java/Clojure project (ultimately trying to package some Clojure code as an Ant task to be used by my build process). Prefer not to use Leiningen, yet, before I understand a bit of the magic it "hides". – Marcus Junius Brutus Oct 14 '13 at 23:41

2 Answers2

0

For building Clojure projects where for various reasons I could not use Leiningen I have been much happier using the Zi plugin and letting maven decide what needs to be re-compiled.

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284
0

I ended up using ant-contrib's OutOfDate task (e.g. as also described in this answer for the more general case of invoking Ant's exec task).

<contrib:outofdate>
    <deletetargets all="true"/>
    <sourcefiles>
        <path refid="compile.dependency.artifacts"/>
    </sourcefiles>
    <targetfiles>
        <fileset dir="${cljbuild.dir}">
            <include name="**/*.class"/>
        </fileset>
    </targetfiles> 
    <sequential>
        <java classname="clojure.lang.Compile" 
              failonerror="true"
              fork="true">
          <classpath refid="compile.classpath"/>
          <sysproperty key="clojure.compile.path" value="${cljbuild.dir}"/>
          <arg value="${project.MainClass.name}"/>
        </java>
    </sequential>
</contrib:outofdate>
Community
  • 1
  • 1
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331