|
| 1 | +import net.ltgt.gradle.errorprone.errorprone |
| 2 | + |
| 3 | +plugins { |
| 4 | + id("com.diffplug.spotless") version "7.0.1" |
| 5 | + id("com.palantir.consistent-versions") version "2.31.0" |
| 6 | + id("com.palantir.git-version") version "3.1.0" |
| 7 | + id("io.github.gradle-nexus.publish-plugin") version "1.3.0" |
| 8 | + id("net.ltgt.errorprone") version "4.1.0" apply false |
| 9 | + id("org.inferred.processors") version "3.7.0" apply false |
| 10 | +} |
| 11 | + |
| 12 | +val gitVersion: groovy.lang.Closure<String> by extra |
| 13 | +version = gitVersion() |
| 14 | + |
| 15 | +allprojects { |
| 16 | + apply(plugin = "com.diffplug.spotless") |
| 17 | + |
| 18 | + repositories { |
| 19 | + mavenCentral() |
| 20 | + } |
| 21 | + |
| 22 | + tasks.withType<Test> { |
| 23 | + useJUnitPlatform() |
| 24 | + |
| 25 | + maxHeapSize = "1G" |
| 26 | + |
| 27 | + testLogging { |
| 28 | + events("passed") |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + plugins.withType<JavaLibraryPlugin> { |
| 33 | + apply(plugin = "net.ltgt.errorprone") |
| 34 | + apply(plugin = "org.inferred.processors") |
| 35 | + |
| 36 | + dependencies { |
| 37 | + "errorprone"("com.google.errorprone:error_prone_core") |
| 38 | + "errorprone"("com.jakewharton.nopen:nopen-checker") |
| 39 | + "compileOnly"("com.jakewharton.nopen:nopen-annotations") |
| 40 | + } |
| 41 | + |
| 42 | + spotless { |
| 43 | + java { |
| 44 | + palantirJavaFormat() |
| 45 | + licenseHeaderFile("${rootProject.projectDir}/.spotless/java-license-header.txt") |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + tasks.withType<JavaCompile> { |
| 50 | + options.errorprone.disable("UnusedVariable") |
| 51 | + options.compilerArgs.add("--enable-preview") |
| 52 | + |
| 53 | + // Needed to make sure that the barista-annotations emits to the correct directory |
| 54 | + options.generatedSourceOutputDirectory = projectDir.resolve("generated_src") |
| 55 | + } |
| 56 | + |
| 57 | + tasks.withType<Javadoc> { |
| 58 | + (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:-missing") |
| 59 | + } |
| 60 | + |
| 61 | + the<JavaPluginExtension>().toolchain.languageVersion = JavaLanguageVersion.of(17) |
| 62 | + |
| 63 | + tasks["check"].dependsOn("spotlessCheck") |
| 64 | + } |
| 65 | + |
| 66 | + spotless { |
| 67 | + kotlinGradle { |
| 68 | + ktlint() |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + tasks.register("format").get().dependsOn("spotlessApply") |
| 73 | +} |
| 74 | + |
| 75 | +fun booleanEnv(envVar: String): Boolean? = System.getenv(envVar)?.toBoolean() |
| 76 | + |
| 77 | +fun String.runCommand(): String { |
| 78 | + val proc = |
| 79 | + ProcessBuilder(*split(" ").toTypedArray()) |
| 80 | + .redirectOutput(ProcessBuilder.Redirect.PIPE) |
| 81 | + .redirectError(ProcessBuilder.Redirect.INHERIT) |
| 82 | + .start() |
| 83 | + proc.waitFor(10, TimeUnit.SECONDS) |
| 84 | + return proc.inputStream.bufferedReader().readText() |
| 85 | +} |
0 commit comments