Applies the Gradle built-in
java-base plugin to get basic support for the JVM ecosystem.
The high-level features provided by
java-base for each SourceSet.
Each source set will have a Java compilation task
compile<Name>Java task (
compileJava for the
main source set).
Multiple dependency "buckets" are created for each source set, to allow scoping them to the places their needed.
Names below are for a source set named
main. Other source sets' configurations will be prefixed by the source set name (e.g.
compileOnlyfor dependencies only needed at compile time, but shouldn’t be pulled in transitively by consumers
implementationfor dependencies your code needs to compile and needed by your consumers
runtimeOnlyfor dependencies your code needs to run, but aren’t necessary at compile time
This is the default project layout for a source set.
settings.gradle build.gradle src/ <source set name>/ java/ resources/
java.srcDirs = ['src/myjava']
resources.srcDirs = ['src/myresources']
Gradle’s JVM toolchain feature allows you to declare a specific JVM version to use for its tasks. This means that Gradle can run on one JVM version and your tasks can run on another. Or you can have different tasks run on different JVMs.
By default, Gradle will try to detect installed JVM versions from your device and if the requested version is not found it will download it for you.
In the simplest case, you declare a JVM version to use for all tasks that fork a JVM. This is supported by the tasks created by the Java plugins and all tasks created by the Clojurephant plugins.
languageVersion = JavaLanguageVersion.of(17)
Adds the ClojureExtension to the project allowing the user to configure builds.
For each ClojureBuild it sets default values and creates the following tasks.
Creates a ClojureCheck task named
main build) or
checkTestClojure), with the following defaults:
Creates a ClojureCompile task named
main build) or
compileTestClojure), with the following defaults:
settings.gradle build.gradle src/ <source set name>/ clojure/ # Adds this to what java-base provides java/ resources/
The build will use this
src/<name>/clojure directory as its source root.
The Clojure source directories will also be registed with the source set’s
allJava, making them discoverable to other Gradle plugins.
For maximum compatibility, if you want to modify your source layout, configure on the source set, rather than the build.
The Clojure classpath will include:
the source set’s
the source set’s compiled Java classes
the source set’s processed resources
Each source set has a concept of its output directories and the tasks needed to populate them. Depending on your use case, you may want the Clojure source to be considered the output, or you may want AOT classes to be considered the output.
clojure-base plugin will include only the AOT classes in the source set output, if you enable any
build.aotNamespaces. Otherwise, it will only include the Clojure sources.
Creates a Configuration named
nrepl with a default
*-base plugins do not create any ClojureNRepl tasks. You’ll either need to apply a convention plugin, or create and configure the REPL task yourself.
|Introduced in Clojurephant v0.7.0-alpha.6.
By default, Clojurephant will only provide an nREPL dependency. If you’d like to inject additional dependencies from the commandline, set the Gradle property
dev.clojurephant.jack-in.nrepl. The value should be comma-separated
group:artifact:version dependencies. These dependencies will be included in the
Configuration conventionally used by the ClojureNRepl task.
$ ./gradlew -Pdev.clojurephant.jack-in.nrepl=nrepl:nrepl:0.9.0,cider:cider-nrepl:0.28.5 clojureRepl --middleware=cider.nrepl/cider-middleware