dev.clojurephant.clojurescript-base
Java Support
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).
Dependencies
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. testRuntimeOnly
).
-
compileOnly
for dependencies only needed at compile time, but shouldn’t be pulled in transitively by consumers -
implementation
for dependencies your code needs to compile and needed by your consumers -
runtimeOnly
for dependencies your code needs to run, but aren’t necessary at compile time
Project Layout
This is the default project layout for a source set.
settings.gradle build.gradle src/ <source set name>/ java/ resources/
Creating a SourceSet
sourceSets {
myStuff {
java.srcDirs = ['src/myjava']
resources.srcDirs = ['src/myresources']
}
}
dependencies {
implementation 'org.slf4j:slf4j-api:1.7.0'
runtimeOnly 'ch.qos.logback:logback-classic:1.2.11'
}
JVM Toolchain
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.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
ClojureScript Extension
Adds the ClojureScriptExtension to the project allowing the user to configure builds.
ClojureScript Builds
For each ClojureScriptBuild it sets default values and creates the following tasks.
Compile Task
Creates a ClojureCompile task named compileClojureScript
(for main
build) or compile<Name>Clojure
(e.g. compileTestClojureScript
), with the following defaults:
-
task.destinationDir
isbuild.outputDir
-
task.source
isbuild.sourceRoots
-
task.classpath
isbuild.sourceRoots
plusbuild.classpath
-
task.options
isbuild.compiler
Build per Source Set
For each SourceSet, the clojurescript-base
plugin will create a ClojureScriptBuild. In addition to the defaults above, the following will be configured:
Source Roots
settings.gradle build.gradle src/ <source set name>/ clojurescript/ # Adds this to what java-base provides java/ resources/
The build will use this src/<name>/clojurescript
directory as its source root.
The ClojureScript source directories will also be registed with the source set’s allSource
and 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. build.gradle
|
Classpath
The ClojureScript classpath will include:
-
the source set’s
compileClasspath
configuration dependencies -
the source set’s processed resources
SourceSet Output
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 ClojureScript source to be considered the output, or you may want compiled JavaScript to be considered the output.
The clojurescript-base
plugin will include only the compiled JavaScript in the source set output, if you enable any build.aotNamespaces
. Otherwise, it will only include the ClojureScript sources.
nREPL Configuration
Creates a Configuration named nrepl
with a default nrepl:nrepl:0.9.0
dependency.
The *-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.
|
nREPL Jack-In Dependencies
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 nrepl
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