Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable the Spotless plugin for Java 21 #12992

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions pinot-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@
<artifactId>protobuf-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually keep the plugin management inside the root pom, and then we can simply use it here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is fine. Basically he moved this from pluginManagement to plugin. Given there is no child project that inherits its pom, I think this is the right move.

Copy link
Collaborator Author

@yashmayya yashmayya Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I assumed that #11670 introduced the pluginManagement in this POM for the JDK 21 build profile (i.e., to avoid running this plugin's goal with Java 21)? Also we're overriding the plugin configuration here (for the separate excludes I presume), so it's not like we can simply define it here without the configuration right?

Edit: We're still leveraging the plugin management from the parent POM since we aren't redefining the plugin version or executions here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is that we should be able to put the excludes in the root pom where there is another configuration for this plug-in, then we keep a single configuration for this plug-in for easier management

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I've made that change. Not sure why it was like that earlier - perhaps to avoid adding child module specific excludes in the parent POM? Looks like it was added in https://github.com/apache/pinot/pull/8427/files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is that we should be able to put the excludes in the root pom where there is another configuration for this plug-in, then we keep a single configuration for this plug-in for easier management

I think that is a bad practice. This is the project that knows which files should be ignored. In case other projects want to do the same we don't want to merge that information.

The pom project should specify the plugin version and the common configuration. Configuration specific to each sub-project should be configured by each sub-project

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I've reverted the last commit to keep things as they were previously.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gortiz Does it work if we only keep the excludes config here? Keeping separate excludes per module definitely make sense, but replicating other fields can add management overhead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://maven.apache.org/pom.html#plugins, that should work and it is supported behavior. I've pushed a commit making this change and also verified locally that it works as expected.

<java>
<includes>
<include>src/main/java/**/*.java</include>
<include>src/test/java/**/*.java</include>
</includes>
<excludes>
<exclude>src/main/java/org/apache/pinot/common/request/*.java</exclude>
<exclude>src/main/java/org/apache/pinot/common/response/ProcessingException.java</exclude>
</excludes>
<importOrder>
<order>,\#</order>
</importOrder>
<removeUnusedImports/>
</java>
</configuration>
</plugin>

<!-- Following plugins and their configurations are used to generate the custom Calcite's SQL parser -->
<!-- Copy the templates present in the codegen directory to ${project.build.directory}/codegen -->
<plugin>
Expand Down Expand Up @@ -129,31 +150,6 @@
</executions>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<java>
<includes>
<include>src/main/java/**/*.java</include>
<include>src/test/java/**/*.java</include>
</includes>
<excludes>
<exclude>src/main/java/org/apache/pinot/common/request/*.java</exclude>
<exclude>src/main/java/org/apache/pinot/common/response/ProcessingException.java</exclude>
</excludes>
<importOrder>
<order>,\#</order>
</importOrder>
<removeUnusedImports/>
</java>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
Expand Down
19 changes: 4 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,6 @@
</properties>

<profiles>
<profile>
<id>not-java-21</id>
<activation>
<jdk>!21</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>github-actions</id>
<activation>
Expand Down Expand Up @@ -1625,7 +1611,6 @@
<version>2.43.0</version>
<executions>
<execution>
<phase>verify</phase>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't required because spotless:check is already bound to Maven's verify phase by default (see https://github.com/diffplug/spotless/blob/main/plugin-maven/README.md#binding-to-maven-phase).

<goals>
<goal>check</goal>
</goals>
Expand Down Expand Up @@ -2080,6 +2065,10 @@
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7.1</version>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
Expand Down
Loading