Repository navigation
Compile the Gradle plugin as Java: convert its last Groovy class and leave src/main/groovy - #263
Merged
Merged
Conversation
It was the only Groovy source in the repository, written when the IDEA plugin edited the .ipr through idea.project.ipr.withXml, which hands over a groovy.util.Node. The tasks have read and written the .idea files themselves since palantir#1306, and the class stays on groovy.util.Node, as XmlUtils does. A Node keeps the map of attributes it is created with, and the class puts values in it afterwards, so a new child gets a LinkedHashMap rather than Map.of. The class is package-private: only the tasks next to it and its test call it. The same conversion as palantir#1855, still a draft upstream. Part of #261.
compileJava runs before compileGroovy, so Java that calls a Groovy class compiles only from the Groovy source directory: the tasks that call ConfigureJavaFormatterXml, PalantirJavaFormatIdeaPlugin, which registers them, and PalantirJavaFormatPlugin, which applies it, lived there, and XmlUtils next to its callers. With the Groovy class gone they move to src/main/java, and the groovy plugin goes. compileGroovy is no JavaCompile task, so Error Prone and NullAway skipped these files until now. The groovy.xml classes stay: they come with gradleApi(), and replacing them is #262. Part of #261.
Error Prone flags rootProject == rootProject.getRootProject() in PalantirJavaFormatIdeaPlugin now that it compiles it, and it flagged the same check in the two other root-project plugins already. Project does not override equals, so the check does not change.
Picnic's StaticImport suggested it for Preconditions.checkState and checkNotNull, Collectors, Collections.singletonList, Comparator.reverseOrder, Objects.requireNonNull and Pattern.MULTILINE, in the main and test sources of gradle-open-java-format. The module compiles without a StaticImport note now.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #261. Independent of the other open pull requests; based on
21.X.X.Seven classes of the Gradle plugin lived in
gradle-open-java-format/src/main/groovybecause ofConfigureJavaFormatterXml.groovy, the only Groovy source in the repository: Java that calls a Groovy class compiles only jointly with it, andcompileGroovyis noJavaCompiletask, so Error Prone and NullAway skipped the six Java files among them. #261 has how it came to this.Commits
ConfigureJavaFormatterXmlto Java, in place and still ongroovy.util.Node: the same conversion as Convert ConfigureJavaFormatterXml from Groovy to Java palantir/palantir-java-format#1855, a draft upstream, without its revapi part. A new child gets aLinkedHashMapof attributes, since aNodekeeps the map it is created with and the class puts values in it afterwards, whichMap.ofwould refuse. The class is package-private now.src/main/javaand dropapply plugin: 'groovy'. Renames only, sogit log --followgoes on past them.ReferenceEquality, the one finding Error Prone has for the moved files:rootProject == rootProject.getRootProject()inPalantirJavaFormatIdeaPlugin. The two other root-project plugins had the same line, flagged already; all three compare withequalsnow, whichProjectdoes not override. NullAway finds nothing.StaticImportacross the module, main and test sources:Preconditions.checkStateandcheckNotNull,Collectors,Collections.singletonList,Comparator.reverseOrder,Objects.requireNonNullandPattern.MULTILINE.What stays
.idea. The XML is still read and written with Groovy'sXmlParserandXmlNodePrinter, which come withgradleApi(); replacing them changes the text of the files and is Edit the .idea XML files with the JDK's DOM instead of Groovy's XmlParser #262.@SuppressWarnings("unchecked")inConfigureJavaFormatterXml:Node.attributes()is a rawMap, and javac prints its "uses unchecked or unsafe operations" note for the file, as it does for files ofopen-java-format.ConstantNamingandInjectOnConstructorOfAbstractClassinSpotlessInterop,AnnotateFormatMethodinGradleTestProject.Tests
./gradlew :gradle-open-java-format:checkpasses on JDK 21: 141 tests, checkstyle, forbidden-apis andvalidatePlugins.ConfigureJavaFormatterXmlTestandPalantirJavaFormatIdeaPluginTestpass on the first two commits on their own. The jar has the seven classes, andjavadocJarandsourcesJarbuild.PalantirJavaFormatPluginTest,PalantirJavaFormatSpotlessPluginTestandFormatDiffTestneed the native image and are left to CI'snativejobs. The root build applies the published 21.0.2 plugin, so no other module builds with this one.