Created
April 2, 2025 01:12
-
-
Save oscarvarto/57cb5deeadd6f1b734547f9f89ba5c21 to your computer and use it in GitHub Desktop.
Gradle build for a mixed Clojure/Java codebase using lombok and checkerframework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'com.github.ben-manes.versions' version '0.52.0' | |
id 'io.freefair.lombok' version '8.12.1' | |
id 'org.checkerframework' version '0.6.49' | |
id 'com.diffplug.spotless' version "7.0.2" | |
id 'dev.clojurephant.clojure' version '0.8.0-beta.7' | |
id 'application' | |
} | |
group = 'org.example' | |
version = '1.0-SNAPSHOT' | |
repositories { | |
mavenCentral() | |
maven { | |
name = 'clojars' | |
url = 'https://repo.clojars.org' | |
} | |
} | |
lombok { version = "1.18.36" } | |
dependencies { | |
implementation 'org.functionaljava:functionaljava:5.0' | |
implementation 'com.google.guava:guava:33.4.6-jre' | |
implementation 'ch.qos.logback:logback-classic:1.5.18' | |
implementation 'org.slf4j:slf4j-api:2.1.0-alpha1' | |
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3' | |
compileOnly 'org.checkerframework:checker-qual:3.49.1' | |
testCompileOnly 'org.checkerframework:checker-qual:3.49.1' | |
checkerFramework 'org.checkerframework:checker:3.49.1' | |
implementation 'org.checkerframework:checker-util:3.49.1' | |
testImplementation 'org.testng:testng:7.11.0' | |
testImplementation 'org.assertj:assertj-core:4.0.0-M1' | |
// Clojure | |
implementation 'org.clojure:clojure:1.12.0' | |
implementation 'org.clojure:java.data:1.3.113' | |
testRuntimeOnly 'org.ajoberstar:jovial:0.3.0' | |
devImplementation 'org.clojure:tools.namespace:1.5.0' | |
// CIDER | |
devImplementation 'nrepl:nrepl:1.3.1' | |
devImplementation 'cider:cider-nrepl:0.53.2' | |
devImplementation 'org.clojure:tools.namespace:1.3.0' | |
} | |
java { | |
java { | |
toolchain { | |
languageVersion = JavaLanguageVersion.of(21) | |
} | |
} | |
sourceCompatibility = JavaVersion.VERSION_21 | |
targetCompatibility = JavaVersion.VERSION_21 | |
} | |
def patchModuleArg = "--patch-module=jdk.compiler=" + | |
files(sourceSets.main.java.srcDirs, sourceSets.test.java.srcDirs).asPath | |
tasks.withType(JavaCompile).configureEach { | |
options.compilerArgs.addAll([ | |
'--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED', | |
'--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED', | |
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED', | |
'--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED', | |
'--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED', | |
'--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED', | |
'--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED', | |
'--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED', | |
// '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED', | |
patchModuleArg, | |
'-Xmaxerrs', '10000', | |
'-Xmaxwarns', '10000', | |
'-Awarns' | |
]) | |
} | |
// If you need --add-opens at runtime, keep this: | |
tasks.withType(JavaExec).configureEach { | |
jvmArgs += ['--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED'] | |
} | |
spotless { | |
java { | |
eclipse().configFile("${rootProject.projectDir}/eclipse-java-google-style.xml") | |
importOrder('', '\\#') | |
.wildcardsLast(false) | |
.semanticSort() | |
removeUnusedImports() | |
formatAnnotations() | |
} | |
} | |
checkerFramework { | |
checkers = [ | |
'org.checkerframework.checker.nullness.NullnessChecker' | |
] | |
} | |
clojure { | |
builds { | |
main { | |
aotAll() | |
} | |
} | |
} | |
tasks.withType(Test).configureEach { | |
useTestNG() | |
maxHeapSize = '16G' | |
} | |
wrapper { | |
gradleVersion = '8.13' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment