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

[AMORO-2113] Apply spotless-maven-plugin in trino module #2131

Merged
merged 13 commits into from
Oct 20, 2023

Conversation

HuangFru
Copy link
Contributor

@HuangFru HuangFru commented Oct 17, 2023

Why are the changes needed?

Close #2113.

Brief change log

  • Apply spotless-maven-plugin in trino module.
  • Upgrade googleJavaFormat to 1.15.0 only to the Trino module.
  • Skip maven-checkstyle-plugin.
  • mvn spotless:apply -pl trino
  • Skip trino module by default in Maven.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable)

@github-actions github-actions bot added module:mixed-flink Flink moduel for Mixed Format module:mixed-trino trino module for Mixed Format type:build labels Oct 17, 2023
@HuangFru HuangFru closed this Oct 17, 2023
@HuangFru HuangFru reopened this Oct 17, 2023
@github-actions github-actions bot added module:ams-dashboard Ams dashboard module and removed module:mixed-flink Flink moduel for Mixed Format labels Oct 17, 2023
@codecov
Copy link

codecov bot commented Oct 17, 2023

@github-actions github-actions bot removed the module:ams-dashboard Ams dashboard module label Oct 17, 2023
@HuangFru
Copy link
Contributor Author

Upgrade googleJavaFormat to 1.15.0 in the Trino module due to:
截屏2023-10-17 14 34 19

This version must run with JDK11+, so do not validate in the Trino module and only check it in Trino CI.

@zhongqishang
Copy link
Contributor

@HuangFru @shidayang
After the trino module turns on spotless and executes install / package together with other modules, the follow error will be reported.

You are running Spotless on JVM 8, which limits you to google-java-format 1.7.
Upgrade your JVM or try google-java-format alternatives:
- Version 1.7 requires JVM 8+
- Version 1.15.0 requires JVM 11+

I think we need to change the README.md#building script?

@HuangFru
Copy link
Contributor Author

@HuangFru @shidayang After the trino module turns on spotless and executes install / package together with other modules, the follow error will be reported.

You are running Spotless on JVM 8, which limits you to google-java-format 1.7.
Upgrade your JVM or try google-java-format alternatives:
- Version 1.7 requires JVM 8+
- Version 1.15.0 requires JVM 11+

I think we need to change the README.md#building script?

This is a problem. 'mvn validate' must be divided into 'mvn validate -pl '!trino' with jdk8 and 'mvn validate' with jdk17. Maybe applying spotless to the Trino module is not a good idea.

@shidayang
Copy link
Contributor

@HuangFru @shidayang After the trino module turns on spotless and executes install / package together with other modules, the follow error will be reported.

You are running Spotless on JVM 8, which limits you to google-java-format 1.7.
Upgrade your JVM or try google-java-format alternatives:
- Version 1.7 requires JVM 8+
- Version 1.15.0 requires JVM 11+

I think we need to change the README.md#building script?

This is a problem. 'mvn validate' must be divided into 'mvn validate -pl '!trino' with jdk8 and 'mvn validate' with jdk17. Maybe applying spotless to the Trino module is not a good idea.

It's really inconvenient that the Spotless plugin cannot use the Toolchain plugin. This PR cannot be merged until this issue is resolved.

@shidayang shidayang closed this Oct 17, 2023
@HuangFru HuangFru reopened this Oct 18, 2023
@github-actions github-actions bot added the type:docs Improvements or additions to documentation label Oct 18, 2023
@HuangFru HuangFru marked this pull request as draft October 18, 2023 11:19
@HuangFru HuangFru marked this pull request as ready for review October 19, 2023 07:23
@HuangFru
Copy link
Contributor Author

@shidayang @zhongqishang
The Trino module will now be skipped by default. If you need to build the Trino module, you'll need to apply the profile separately. Although Spotless and Toolchains still cannot be used together, other modules and the Trino module have better isolation. The maven command reduces the use of some '-pl' parameters.

# Conflicts:
#	trino/src/main/java/com/netease/arctic/trino/keyed/KeyedConnectorMetadata.java
#	trino/src/main/java/com/netease/arctic/trino/unkeyed/IcebergMetadata.java
#	trino/src/main/java/com/netease/arctic/trino/unkeyed/IcebergSplitManager.java
#	trino/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
#	trino/src/main/java/org/apache/hadoop/util/VersionInfo.java
#	trino/src/test/java/com/netease/arctic/trino/iceberg/BaseConnectorTest.java
#	trino/src/test/java/com/netease/arctic/trino/iceberg/TestBaseArcticConnectorTest.java
@zhongqishang
Copy link
Contributor

If we can skip the trino module spotless validate, we can configure <skip>true</skip> by default in trino's pom,
And only add a profile with spotless enabled is enough, such as:

        <profile>
            <id>trino-spotless</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

Then

  • To invoke a build include trino module by toolchains: mvn clean package -DwithTrino -DskipTests -Dspotless.check.skip=true -P toolchain
  • To invoke a build include trino module in Java 17 environment: mvn clean package -DskipTests -P trino-spotless
  • To only build trino and its dependent modules by toolchains: mvn clean package -DwithTrino -DskipTests -Dspotless.check.skip=true -pl 'trino' -am -P toolchain
  • To only build trino and its dependent modules in Java 17 environment: mvn clean package -DskipTests -P trino-spotless -pl 'trino' -am

This can be more concise, WDYT?

@shidayang
Copy link
Contributor

If we can skip the trino module spotless validate, we can configure <skip>true</skip> by default in trino's pom, And only add a profile with spotless enabled is enough, such as:

        <profile>
            <id>trino-spotless</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

Then

  • To invoke a build include trino module by toolchains: mvn clean package -DwithTrino -DskipTests -Dspotless.check.skip=true -P toolchain
  • To invoke a build include trino module in Java 17 environment: mvn clean package -DskipTests -P trino-spotless
  • To only build trino and its dependent modules by toolchains: mvn clean package -DwithTrino -DskipTests -Dspotless.check.skip=true -pl 'trino' -am -P toolchain
  • To only build trino and its dependent modules in Java 17 environment: mvn clean package -DskipTests -P trino-spotless -pl 'trino' -am

This can be more concise, WDYT?

Good idea, I can't agree with you more.

@HuangFru
Copy link
Contributor Author

If we can skip the trino module spotless validate, we can configure <skip>true</skip> by default in trino's pom, And only add a profile with spotless enabled is enough, such as:

        <profile>
            <id>trino-spotless</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

Then

  • To invoke a build include trino module by toolchains: mvn clean package -DwithTrino -DskipTests -Dspotless.check.skip=true -P toolchain
  • To invoke a build include trino module in Java 17 environment: mvn clean package -DskipTests -P trino-spotless
  • To only build trino and its dependent modules by toolchains: mvn clean package -DwithTrino -DskipTests -Dspotless.check.skip=true -pl 'trino' -am -P toolchain
  • To only build trino and its dependent modules in Java 17 environment: mvn clean package -DskipTests -P trino-spotless -pl 'trino' -am

This can be more concise, WDYT?

Make sense! I will make changes, thank you for your suggestions.

pom.xml Outdated Show resolved Hide resolved
trino/pom.xml Outdated Show resolved Hide resolved
@HuangFru
Copy link
Contributor Author

Modified it according to @zhongqishang 's suggestions, PTAL @zhongqishang @shidayang @baiyangtx.

Copy link
Contributor

@zhongqishang zhongqishang left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your work!👍

@shidayang
Copy link
Contributor

LGTM

Copy link
Contributor

@baiyangtx baiyangtx left a comment

Choose a reason for hiding this comment

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

LGTM

@baiyangtx baiyangtx merged commit 7de1560 into apache:master Oct 20, 2023
3 of 4 checks passed
ShawHee pushed a commit to ShawHee/arctic that referenced this pull request Dec 29, 2023
* apply spotless-maven-plugin in trino module.

* Revert "apply spotless-maven-plugin in trino module."

This reverts commit 7415823.

* apply spotless-maven-plugin in trino module.

* revert test code.

* modify ci not apply checkstyle in trino module in hadoop ci.

* add doc to README.md

* skip trino module by default

* modify CI

* remove useless code

* modify CI

* check style

* add a profile to skip trino spotless by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:mixed-trino trino module for Mixed Format type:build type:docs Improvements or additions to documentation type:infra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask]: Apply spotless to Trino Modules
4 participants