dev.clojurephant.clojure

Base Clojure Support

Applies the dev.clojurephant.clojure-base plugin.

Java Support

Applies the Gradle built-in java plugin to get convention-based support for the JVM ecosystem.

The high-level features of the java plugin are:

  • Creating a main source set for your production code

  • Creating a jar task that packages the main source set’s output

  • Creating a test source set for use with JUnit testing

    • The test source set depends on the main source set’s output (i.e. Java classes)

    • Creates a test task to execute the tests

Project Layout

This is the default project layout.

settings.gradle
build.gradle
src/
  main/
    java/
    resources/
  test/
    java/
    resources/

Full Project Layout

settings.gradle
build.gradle
src/
  main/
    clojure/
    java/
    resources/
  test/
    clojure/
    java/
    resources/
  dev/
    clojure/
    java/
    resources/

Main Source

By default the main build runs with build.checkAll(). This will let you know if any of your code is invalid and would fail a compile (without producing AOT classes).

Test Source

By default the test build runs with build.aotAll() since the only reliable way to run Clojure tests via Gradle’s native Test task is to have them pre-compiled into class files.

Running clojure.test tests

Clojurephant doesn’t provide support out-of-the-box to run clojure.test tests, but you can very easily enable it by using jovial, which is a JUnit Platform engine. This approach means that your Clojure tests can make use of Gradle’s reporting and filtering features.

dependencies {
  testRuntimeOnly 'dev.clojurephant:jovial:0.4.2'
}

tasks.withType(Test) {
  useJUnitPlatform()
}

Development Source

Its conventional in Clojure/ClojureScript projects to have a set of development-only source code, typically for use in a REPL environment.

The convention plugins create a new SourceSet named dev to house this code. The dev source sets’s dependency "buckets" extend from the test and main ones, avoiding the need to repeat declaring dependencies.

Compile Classpath

  • Clojure/ClojureScript source from the test source set

  • Clojure/ClojureScript source from the main source set

  • Compiled Java classes from the main source set

  • the source set’s compileClasspath configuration dependencies (which include the deps from test and main)

Runtime (REPL) Classpath

  • Clojure/ClojureScript source from the dev source set

  • Clojure/ClojureScript source from the test source set

  • Clojure/ClojureScript source from the main source set

  • Compiled Java classes from the main source set

  • the source set’s compileClasspath configuration dependencies (which include the deps from test and main)

  • sources and javadoc JARs of all dependencies (where available) — this can be used by editor’s like CIDER to help with navigate to source or documentation

  • nrepl configuration dependencies (the nREPL server and any "jacked-in" dependencies)

REPL Task

Creates a ClojureNRepl task (named clojureRepl) to provide an nREPL server using the dev runtime classpath.