Clojure plugin in gradle core?


(Magnus Rundberget) #1

I’d really love to see some clojure love in Gradle.

There is a clojure plugin clojuresque (https://bitbucket.org/clojuresque/clojuresque) which might serve as a start. Most clojure projects use leiningen (https://github.com/technomancy/leiningen), and I’m guessing polyglot maven projects use the clojure-maven-plugin (https://github.com/talios/clojure-maven-plugin).

In my current multiproject I ended up wrapping leiningen through javaexec tasks due to missing features in the clojuresque plugin (most notably (n)repl support and ease of using ring).

I’m a clojure noob so at the moment I wouldn’t be able to contribute much. However maybe there are others out there and maybe there is a growing clojure curiosity within the gradle core team ? :slight_smile:

any chance of a clojure plugin on the gradle roadmap ?

cheers Magnus


Clojure and Gradle: clojuresque can't find /src/main/clojure files
(Meikel Brandmeyer) #2

I’m the maintainer of clojuresque. I work on getting up to par with core plugins. As far as time allows. Currently the quality of the plugin is not good enough, IMO. However I’m working on splitting things into multiple plugins to make the whole story more modular.

Eg. nrepl support is (not well-tested on Windows) available in its own plugin. This is one of the first results of restructuring.

Current fields of needed work: * tests * tests * tests * integration of clojure tests in the test reporting (some work already done by Paudy Moriarty, but still stuck in my pipeline :frowning: )

I would appreciate any help to get things going.


(Ruben Rodriguez) #3

I’m in a similar situation as Magnus

I’m trying to either run or exclude clojure tests in a Gradle project with several subprojects but I dont know how the source dir for tests can be configured. I’ve tried with

sourceSets {
    main {
        clojure {
            excludes = ['**/export_xml*']
            srcDirs = ["src/main/clojure", "src/main/resources"] // resources is needed here even at compilation time
        }
    }
    test {
        clojure {
            testSrcDirs = ["src/test/clojure", "src/test/resources"]
        }
    }
    resources.srcDirs = ["src/main/resources"]
    resources.testSrcDirs = ["src/test/resources"]
}

But the testSrcDirs is not available. I tried with: test.clojure.srcDirs instead of test.clojure.testSrcDirs

Still a similar error No such property: srcDirs.

Are the tasks added by the clojure plugin documented somewhere?

Thanks.


(Meikel Brandmeyer) #4

I’m working on the documentation for clojuresque. In particular documenting the tasks. At the moment I writing up a guide. Finally there will also be a groovydoc reference documentation for the tasks.

I’m not sure what your problem with the tests is. The plugin provides the ‘clojureTest’ task, which runs any clojure tests in ‘src/test/clojure’. (At the moment using ‘clojure.test’.) However the integration with reporting is rather bad at the moment. There are first steps contributed by a user, but it is not complete, yet. I have no experience in this area. If someone could help me out here, this would be highly appreciated.

As for your problem with the resources directory:

sourceSets {
    main {
        clojure {
            exclude '**/export_xml*'
        }
    }
}
  compileClojure {
    classpath = project.files(classpath, project.sourceSets.main.resources.srcDirs)
}
  clojureTest {
    classpath = project.files(classpath, project.sourceSets.test.resources.srcDirs)
}

This should add the resources directories to the classpath of the Clojure related tasks.


(Ruben Rodriguez) #5

Thanks, I’ll try with that.