Skip to content

Commit 866673b

Browse files
committed
Replace palantir's Gradle plugins with plain Gradle
The build no longer applies anything from palantir's Gradle tooling. What it used to get from there is now written out in two buildSrc convention plugins, or comes from the plain upstream plugins: - open-java-format.error-prone-conventions runs Error Prone 2.50.0 through net.ltgt.errorprone and net.ltgt.nullaway, with NullAway and Picnic's error-prone-support, in place of baseline-error-prone, baseline-null-away, suppressible-error-prone and gradle-guide, which applied suppressible-error-prone itself. The checks vfs-s3 makes build-breaking are listed there, commented out until the code is fixed. - open-java-format.java-conventions sets what gradle-baseline-java did: the Java 21 toolchain, tests on -PjavaRuntime, the JUnit wiring, the javac flags and Checkstyle. The IntelliJ Platform plugin defaults javac to --release, which javac refuses alongside the --add-exports of jdk.compiler; baseline hid that, and the IDEA plugin's build now unsets it. - Checkstyle's configuration moves from .baseline/checkstyle to Gradle's default config/checkstyle and runs on Checkstyle 14.3.0, without JavadocStyle, which Checkstyle 13.9.0 removed. custom-suppressions.xml still suppresses every check, as upstream. - The released dev.openjavaformat.java-format 2.98.0.5 formats the repository instead of com.palantir.java-format, which needed Spotless on the classpath once baseline no longer brought it. - The version comes from git describe, the same command gradle-git-version ran. failure-reports, idea-language-injector and jakarta-package-alignment go without replacement, and so do the configuration files of palantir's bots: bulldozer, changelog, excavator and revapi.
1 parent b48a838 commit 866673b

21 files changed

Lines changed: 186 additions & 172 deletions

File tree

‎.bulldozer.yml‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎.changelog.yml‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.excavator.yml‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎.palantir/revapi.yml‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎build.gradle‎

Lines changed: 17 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,38 @@ buildscript {
44
gradlePluginPortal()
55
}
66

7-
87
dependencies {
9-
classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.7.0'
108
classpath 'com.gradle.publish:plugin-publish-plugin:2.2.1'
11-
classpath 'com.palantir.baseline-error-prone:gradle-baseline-error-prone:0.7.0'
12-
classpath 'com.palantir.baseline:gradle-baseline-java:7.9.0'
13-
classpath 'com.palantir.gradle.failure-reports:gradle-failure-reports:1.21.0'
14-
classpath 'com.palantir.gradle.gitversion:gradle-git-version:5.1.0'
15-
classpath 'com.palantir.gradle.guide:gradle-guide:1.27.0'
16-
classpath 'com.palantir.gradle.idea-configuration:gradle-idea-configuration:0.11.0'
17-
classpath 'com.palantir.gradle.idea-language-injector:gradle-idea-language-injector:0.5.0'
18-
classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.98.0'
19-
classpath 'com.palantir.suppressible-error-prone:gradle-suppressible-error-prone:2.33.0'
9+
// The released open-java-format formats this repository, not the one being built here.
10+
classpath 'dev.openjavaformat:gradle-open-java-format:2.98.0.5'
2011
classpath 'me.champeau.jmh:jmh-gradle-plugin:0.7.3'
2112
}
2213
}
2314

24-
apply plugin: 'com.palantir.failure-reports'
25-
apply plugin: 'com.palantir.git-version'
26-
apply plugin: 'com.palantir.gradle-guide'
27-
apply plugin: 'com.palantir.idea-language-injector'
28-
// Not the `com.palantir.baseline` aggregate: it also applies baseline-format (Spotless) and
29-
// baseline-class-uniqueness, and both are incompatible with the configuration cache at their
30-
// latest versions — Spotless fails serialising its Groovy extension, checkClassUniqueness casts
31-
// a ResolvingFileCollection to Configuration. The rest of what baseline gives us is applied
32-
// per project below, so error-prone and the JUnit wiring survive.
33-
apply plugin: 'com.palantir.baseline-error-prone-root'
34-
apply plugin: 'com.palantir.baseline-java-versions'
3515
// Maven Central releases: buildSrc/src/main/groovy/open-java-format.release-conventions.gradle.
3616
apply plugin: 'open-java-format.release-conventions'
3717

3818
// GitHub Actions sets GITHUB_REF_TYPE=tag on a tag build; otherwise derive the
39-
// version from git history (needs a full clone: actions/checkout fetch-depth: 0).
19+
// version from git history (needs a full clone: actions/checkout fetch-depth: 0):
20+
// the nearest tag, the commits since it and the hash, `.dirty` with uncommitted changes.
4021
//
4122
// Read through providers rather than System.env: the configuration cache tracks a provider as an input
4223
// and invalidates when it changes, while a plain System.env read is invisible to it — a cached
4324
// configuration then keeps handing out the version of whichever environment happened to fill it.
4425
def refType = providers.environmentVariable('GITHUB_REF_TYPE')
4526
def refName = providers.environmentVariable('GITHUB_REF_NAME')
46-
version refType.getOrElse('') == 'tag' ? refName.get() : gitVersion()
27+
def gitDescribe = providers.exec {
28+
commandLine 'git', 'describe', '--tags', '--always', '--first-parent', '--abbrev=7', '--dirty=.dirty'
29+
}.standardOutput.asText.map { it.trim() }
30+
version refType.getOrElse('') == 'tag' ? refName.get() : gitDescribe.get()
4731

4832
// The GraalVM image is built by its own per-platform CI job, never as a side effect of
4933
// `./gradlew build`: an aggregate build must not require a GraalVM toolchain on a machine that
5034
// only wants the jars. Pass -PnativeImage=true to wire it back into the lifecycle tasks — that is
5135
// what .github/workflows/ci.yml's `native` jobs do.
5236
ext.nativeImageRequested = Boolean.parseBoolean(providers.gradleProperty('nativeImage').getOrElse('false'))
5337

54-
// The javac internals the formatter parses with. Was baseline's `moduleJvmArgs`, which is
55-
// dropped because it resolves its extension at execution time and the configuration cache
56-
// forbids that — so the exports are handed to javac and to the test JVMs here instead.
38+
// The javac internals the formatter parses with, handed to javac and to the test JVMs.
5739
def javacInternalExports = [
5840
'jdk.compiler/com.sun.tools.javac.api',
5941
'jdk.compiler/com.sun.tools.javac.code',
@@ -65,18 +47,8 @@ def javacInternalExports = [
6547
]
6648

6749
allprojects {
68-
apply plugin: 'com.palantir.baseline-null-away'
69-
apply plugin: 'com.palantir.baseline-encoding'
70-
apply plugin: 'com.palantir.baseline-immutables'
71-
apply plugin: 'com.palantir.baseline-java-compiler-diagnostics'
72-
apply plugin: 'com.palantir.baseline-java-compiler-heap'
73-
apply plugin: 'com.palantir.baseline-java-properties'
74-
apply plugin: 'com.palantir.baseline-prefer-project-modules'
75-
apply plugin: 'com.palantir.baseline-reproducibility'
76-
apply plugin: 'com.palantir.baseline-test-heap'
77-
apply plugin: com.palantir.baseline.plugins.BaselineTesting
78-
apply plugin: 'com.palantir.java-format'
79-
apply plugin: 'com.palantir.jakarta-package-alignment'
50+
apply plugin: 'dev.openjavaformat.java-format'
51+
8052
// The fork's Maven group (README, "Coordinates"). The Java packages stay com.palantir.javaformat.
8153
group = 'dev.openjavaformat'
8254
version = rootProject.version
@@ -95,8 +67,8 @@ allprojects {
9567
tasks.withType(Javadoc).configureEach {
9668
options.addMultilineStringsOption('-add-exports')
9769
.setValue(javacInternalExports.collect { "${it}=ALL-UNNAMED".toString() })
98-
// baseline used to silence doclint; these sources carry inherited javadoc from
99-
// google-java-format that has never satisfied it (unknown tags, malformed HTML).
70+
// These sources carry inherited javadoc from google-java-format that has never
71+
// satisfied doclint (unknown tags, malformed HTML).
10072
options.addStringOption('Xdoclint:none', '-quiet')
10173
}
10274

@@ -108,33 +80,12 @@ allprojects {
10880

10981
subprojects {
11082
apply plugin: 'java-library'
83+
// Java toolchains, javac and test settings; Error Prone. Both in buildSrc/src/main/groovy.
84+
apply plugin: 'open-java-format.java-conventions'
85+
apply plugin: 'open-java-format.error-prone-conventions'
11186

11287
dependencies {
113-
// Gives a version to the JUnit artifacts that plugins add without one.
88+
// Gives a version to the JUnit artifacts that useJUnitJupiter() adds without one.
11489
testImplementation platform(libs.junit.bom)
11590
}
116-
117-
tasks.withType(Checkstyle).configureEach {
118-
enabled = false
119-
}
120-
121-
tasks.withType(JavaCompile).configureEach {
122-
options.errorprone.disable 'PreconditionsConstantMessage', 'PreferSafeLoggableExceptions', 'PreferSafeLoggingPreconditions'
123-
options.errorprone.disable 'StrictUnusedVariable'
124-
}
125-
126-
// Run `./gradlew test -Drecreate=true` to recreate all the expected
127-
// generated code that we have checked into the repo.
128-
tasks.withType(Test).configureEach {
129-
systemProperty 'recreate', System.getProperty('recreate', 'false')
130-
}
131-
}
132-
133-
// The JDK the tests run on, and with it the javac whose internals the formatter parses with. The code is
134-
// compiled for 21 whatever this says. CI's `jdk` jobs pass -PjavaRuntime=25 and so on.
135-
ext.javaRuntime = providers.gradleProperty('javaRuntime').getOrElse('21')
136-
137-
javaVersions {
138-
libraryTarget = 21
139-
runtime = javaRuntime
14091
}

‎buildSrc/build.gradle‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ repositories {
1111
}
1212

1313
dependencies {
14+
implementation 'net.ltgt.gradle:gradle-errorprone-plugin:5.1.1'
15+
implementation 'net.ltgt.gradle:gradle-nullaway-plugin:3.2.0'
1416
implementation 'org.jreleaser:org.jreleaser.gradle.plugin:1.26.0'
1517
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Error Prone with NullAway and Picnic's error-prone-support checks, on the plain net.ltgt plugins.
2+
plugins {
3+
id 'net.ltgt.errorprone'
4+
id 'net.ltgt.nullaway'
5+
}
6+
7+
dependencies {
8+
errorprone libs.errorprone.core
9+
errorprone libs.nullaway
10+
errorprone libs.errorProneSupport.contrib
11+
}
12+
13+
nullaway {
14+
annotatedPackages.add('com.palantir')
15+
}
16+
17+
tasks.withType(JavaCompile).configureEach {
18+
options.errorprone {
19+
// Annotation processor output (derive4j, Immutables) is not ours to fix.
20+
excludedPaths = '.*/build/generated/.*'
21+
}
22+
}
23+
24+
// Gradle injects services through abstract @Inject getters, which is what this check forbids.
25+
pluginManager.withPlugin('java-gradle-plugin') {
26+
tasks.withType(JavaCompile).configureEach {
27+
options.errorprone.disable('JavaxInjectOnAbstractMethod')
28+
}
29+
}
30+
31+
// The checks vfs-s3 makes build-breaking. Off until the code is fixed, one check at a time:
32+
// JUnitMethodDeclaration 206, StaticImport 84, LexicographicalAnnotationListing 46, JUnitClassModifiers 25,
33+
// RedundantStringConversion 6, AlmostJavadoc 3 findings; the rest have none.
34+
//tasks.withType(JavaCompile).configureEach {
35+
// options.errorprone {
36+
// error('StaticImport')
37+
// error('UnnecessarilyFullyQualified')
38+
// error('EmptyBlockTag')
39+
// error('OperatorPrecedence')
40+
// error('RedundantStringConversion')
41+
// error('PatternMatchingInstanceof')
42+
// error('UnnecessaryParentheses')
43+
// error('LexicographicalAnnotationListing')
44+
// error('JUnitMethodDeclaration')
45+
// error('JUnitClassModifiers')
46+
// error('MissingSummary')
47+
// error('AlmostJavadoc')
48+
// error('BadImport')
49+
// error('JdkObsolete')
50+
// // NonStaticImport (Picnic) is the inverse of StaticImport and would give contradictory advice.
51+
// disable('NonStaticImport')
52+
// }
53+
//}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Java compilation and tests for every module: what palantir/gradle-baseline used to set, in plain Gradle.
2+
plugins {
3+
id 'java'
4+
id 'checkstyle'
5+
}
6+
7+
// The JDK the tests run on, and with it the javac whose internals the formatter parses with. The code is
8+
// compiled for 21 whatever this says. CI's `jdk` jobs pass -PjavaRuntime=25 and so on.
9+
ext.javaRuntime = providers.gradleProperty('javaRuntime').getOrElse('21')
10+
11+
java {
12+
toolchain {
13+
languageVersion = JavaLanguageVersion.of(21)
14+
}
15+
}
16+
17+
configurations.configureEach {
18+
resolutionStrategy.preferProjectModules()
19+
}
20+
21+
tasks.withType(JavaCompile).configureEach {
22+
options.encoding = 'UTF-8'
23+
options.compilerArgs.addAll('-parameters', '-Xmaxwarns', '10000', '-Xmaxerrs', '10000')
24+
}
25+
26+
tasks.withType(Javadoc).configureEach {
27+
options.encoding = 'UTF-8'
28+
options.tags('apiNote', 'implSpec', 'implNote')
29+
}
30+
31+
// The configuration is Gradle's default, config/checkstyle in the root project.
32+
checkstyle {
33+
toolVersion = libs.versions.checkstyle.get()
34+
}
35+
36+
tasks.withType(AbstractArchiveTask).configureEach {
37+
duplicatesStrategy = DuplicatesStrategy.WARN
38+
}
39+
40+
testing {
41+
suites {
42+
test {
43+
useJUnitJupiter()
44+
}
45+
}
46+
}
47+
48+
tasks.withType(Test).configureEach {
49+
javaLauncher = javaToolchains.launcherFor {
50+
languageVersion = JavaLanguageVersion.of(javaRuntime)
51+
}
52+
maxHeapSize = '2g'
53+
jvmArgs '-XX:+HeapDumpOnOutOfMemoryError', '-XX:+CrashOnOutOfMemoryError'
54+
55+
systemProperty 'junit.platform.output.capture.stdout', 'true'
56+
systemProperty 'junit.platform.output.capture.stderr', 'true'
57+
systemProperty 'junit.jupiter.execution.parallel.enabled', 'true'
58+
systemProperty 'junit.jupiter.execution.parallel.config.strategy', 'dynamic'
59+
testLogging.events 'failed'
60+
61+
// Run `./gradlew test -Drecreate=true` to recreate all the expected
62+
// generated code that we have checked into the repo.
63+
def recreate = Boolean.getBoolean('recreate')
64+
systemProperty 'recreate', recreate.toString()
65+
outputs.upToDateWhen { !recreate }
66+
outputs.cacheIf { false }
67+
}

‎buildSrc/src/main/groovy/open-java-format.publishing-conventions.gradle‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Applied by every module with a Maven publication: the POM Maven Central requires, and a local
2-
// `staging` repository that JReleaser signs and uploads from (open-java-format.release-conventions).
31
plugins {
42
id 'maven-publish'
53
}
@@ -61,6 +59,7 @@ publishing {
6159
def cleanStagingDeploy = tasks.register('cleanStagingDeploy', Delete) {
6260
delete stagingDeploy
6361
}
62+
6463
tasks.withType(PublishToMavenRepository).configureEach {
6564
if (name.endsWith('ToStagingRepository')) {
6665
dependsOn cleanStagingDeploy

.baseline/checkstyle/checkstyle-suppressions.xml renamed to config/checkstyle/checkstyle-suppressions.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<!-- Suppress test resources -->
1818
<suppress files="[/\\]src[/\\]test[/\\]resources.*" checks="." />
1919

20-
<!-- JavadocStyle enforces existence of package-info.java package-level Javadoc; we consider this a bug. -->
21-
<suppress files="package-info.java" checks="JavadocStyle" />
22-
2320
<!-- non-code classes -->
2421
<suppress files="\.(bdr|eot|gif|gzip|jar|json|otf|png|svg|ttf|woff|zip)$" checks="FileTabCharacter" />
2522
<suppress files="\.(bdr|eot|gif|gzip|jar|json|otf|png|svg|ttf|woff|zip)$" checks="NewlineAtEndOfFile" />

0 commit comments

Comments
 (0)