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

Force to build on JDK 11+ #23550

Merged
merged 1 commit into from
Jan 29, 2023
Merged

Conversation

zhfeng
Copy link
Contributor

@zhfeng zhfeng commented Jan 13, 2023

It sould be helpful to fix #19990 and #20935

Changes proposed in this pull request:

  • Force to use JDK 11 above to build shardingsphere
  • We still run all the e2e tests on JDK 8 to make sure there is no compatitable issues.
  • Update antlr4 to 4.10+ #19990 which needs to run antlr-maven-plugin to generate the parser classes. The antlr Tool are only for JDK 11 after upgrading to 4.10.1. So if upgrading antlr, it will force user to build shardingsphere with JDK 11

It seems that we need to support JDK 8 for a long time. There is no such plan to drop it, see the relevant discussion https://lists.apache.org/thread/kgtfx5vnw73o61lkvdshyfvjfvvzk3js

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

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

  • I checked CI.
Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli) on project shardingsphere: Execution default-cli of goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed : Plugin org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:0 at specified path /usr/lib/jvm/temurin- 11-jdk-amd64/../lib/tools.jar -> [Help 1]
  • It looks like tools.jar is being called somewhere, which is a unique built-in JAR on JDK 8.

@zhfeng
Copy link
Contributor Author

zhfeng commented Jan 13, 2023

Yeah, I'm taking a look at it.

@zhfeng
Copy link
Contributor Author

zhfeng commented Jan 13, 2023

unfortunately it seem that cobertura-maven-plugin is not compatible with JDK 11 yet. see

@linghengqian
Copy link
Member

linghengqian commented Jan 13, 2023

@codecov-commenter
Copy link

Codecov Report

Merging #23550 (66b761a) into master (f6ad3b2) will increase coverage by 0.47%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master   #23550      +/-   ##
============================================
+ Coverage     49.75%   50.22%   +0.47%     
+ Complexity     2510     1610     -900     
============================================
  Files          4110     3228     -882     
  Lines         58609    53626    -4983     
  Branches      10134     9764     -370     
============================================
- Hits          29158    26934    -2224     
+ Misses        26930    24324    -2606     
+ Partials       2521     2368     -153     
Impacted Files Coverage Δ
...trics/prometheus/collector/BuildInfoCollector.java 58.33% <0.00%> (-16.67%) ⬇️
...e/schema/loader/common/AbstractDataTypeLoader.java 71.42% <0.00%> (-14.29%) ⬇️
...ere/datetime/database/DatabaseDatetimeService.java 57.14% <0.00%> (-14.29%) ⬇️
...ipeline/mysql/ingest/MySQLPositionInitializer.java 54.54% <0.00%> (-13.64%) ⬇️
...pe/MGRMySQLDatabaseDiscoveryProviderAlgorithm.java 53.73% <0.00%> (-13.44%) ⬇️
...stgresql/ingest/PostgreSQLPositionInitializer.java 56.36% <0.00%> (-12.73%) ⬇️
...andler/supporter/ShadowRuleStatementSupporter.java 44.44% <0.00%> (-11.12%) ⬇️
.../schema/loader/dialect/H2SchemaMetaDataLoader.java 76.74% <0.00%> (-10.47%) ⬇️
...hardingsphere/driver/jdbc/context/JDBCContext.java 60.00% <0.00%> (-10.00%) ⬇️
...rdingsphere/proxy/database/DatabaseServerInfo.java 80.00% <0.00%> (-10.00%) ⬇️
... and 1006 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zhfeng
Copy link
Contributor Author

zhfeng commented Jan 14, 2023

@terrymanu @TeslaCN can you take a review? Thanks!

linghengqian
linghengqian previously approved these changes Jan 14, 2023
Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@terrymanu terrymanu left a comment

Choose a reason for hiding this comment

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

Please hold on, I need some time to double check

@TeslaCN
Copy link
Member

TeslaCN commented Jan 16, 2023

Hi @zhfeng @linghengqian
If we upgrade antlr to 4.10.+, even though ShardingSphere is Java 8 bytecode, but Java 8 runtime still cannot using antlr 4.10+.
Is it possible to build ShardingSphere parser modules with different classifiers?

@TeslaCN
Copy link
Member

TeslaCN commented Jan 16, 2023

Hi @zhfeng @linghengqian If we upgrade antlr to 4.10.+, even though ShardingSphere is Java 8 bytecode, but Java 8 runtime still cannot using antlr 4.10+. Is it possible to build ShardingSphere parser modules with different classifiers?

Sorry, I thought the antlr 4.10.+ was compiled as Java 11 bytecode. It seems that only antlr tools require Java 11. The runtime is still Java 8 bytecode.

pom.xml Outdated
@@ -944,7 +944,7 @@
<version>${maven.version.range}</version>
</requireMavenVersion>
<requireJavaVersion>
<version>${java.version}</version>
<version>11</version>
Copy link
Member

Choose a reason for hiding this comment

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

Could we just keep the origin version here, otherwise we have to add -Denforcer.skip=true to do any other operations with Java 8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we can. But It cuould confuse people that building with Java 8 will fail after upgrading antlr to 4.10.1. Anyway, we need to add a NOTE in README to mention that Building from source of shardingsphere must use JDK 11 above. @terrymanu WDYT?

Copy link
Member

@terrymanu terrymanu Jan 16, 2023

Choose a reason for hiding this comment

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

The compile should in JDK 11 (release for JDK 8) only.
I prefer to create compile java version and release java version properties to separate the different versions.

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

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

  • I think the problem that CI had were solved. You can try to rebase the branch.

@zhfeng
Copy link
Contributor Author

zhfeng commented Jan 22, 2023

Thanks @linghengqian and I will take care of the conflicts after the Chinese New Year holiday.

pom.xml Outdated
@@ -944,7 +945,7 @@
<version>${maven.version.range}</version>
</requireMavenVersion>
<requireJavaVersion>
<version>${java.version}</version>
<version>${compile.java.version}</version>
Copy link
Member

Choose a reason for hiding this comment

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

Hi @zhfeng
I prefer to set 8 as requireJavaVersion. Java 11 is required only when compiling parser modules.
Sometimes we just need to compile a part of modules (such as protocol, agent), build an image, do some tests, which could be done using Java 8. Adding -Denforcer.skip=true is not elegant.
And the error of compiling antlr 4.10+ with Java 8 is clear enough for developers.
We could clarify Java requirement in Wiki and docs.

Copy link
Member

Choose a reason for hiding this comment

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

Or is it possible to add maven-enforcer-plugin with Java 11 requirement to those modules require Java 11? The other modules keep using Java 8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think it makes sense and I will investigate.

@zhfeng zhfeng force-pushed the force_to_build_on_jdk11 branch from cbf02c3 to 8e30fe0 Compare January 28, 2023 06:27
@zhfeng
Copy link
Contributor Author

zhfeng commented Jan 28, 2023

Hi guys,

I just update to run CI build on JDK 11 but test it on JDK 8. <requireJavaVersion> is still with <java.version>. After upgrading to antlr 4.10+, the CI should work because it uses JDK 11 but if you build sharding-sphere from source with JDK 8 the following modules which use antlr4-maven-plugin will fail.

  • shardingsphere-distsql-parser
  • shardingsphere-db-discovery-distsql-parser
  • shardingsphere-encrypt-distsql-parser
  • shardingsphere-readwrite-splitting-distsql-parser
  • shardingsphere-shadow-distsql-parser
  • shardingsphere-sharding-distsql-parser
  • shardingsphere-mask-distsql-parser
  • shardingsphere-authority-distsql-parser
  • shardingsphere-data-pipeline-distsql-parser
  • shardingsphere-parser-distsql-parser
  • shardingsphere-sql-federation-optimizer
  • shardingsphere-sql-translator-distsql-parser
  • shardingsphere-traffic-distsql-parser
  • shardingsphere-transaction-distsql-parser
  • shardingsphere-sql-parser-mysql
  • shardingsphere-sql-parser-opengauss
  • shardingsphere-sql-parser-oracle
  • shardingsphere-sql-parser-postgresql
  • shardingsphere-sql-parser-sql92
  • shardingsphere-sql-parser-sqlserver

@zhfeng
Copy link
Contributor Author

zhfeng commented Jan 28, 2023

@TeslaCN @terrymanu can you take a review of these changes? I agree to clarify JDK requirement on wiki and docs. Only the modules which uses antlr-maven-plugin will be impact. If the community is happy to accept this PR, I'm going to prepare for the antlr 4.10+ upgrade which could be

  • Upgarde <antlr4.version> to 4.10.1
  • Run antlr-maven-plugin only in jdk11+ profile
  • In jdk8 profile, try to add the antlr generation directoy as source codes directory. if not, fail the building with the message Please use JDK 11 to re-build artifact to generate the anltr codes

any thought?

Copy link
Member

@TeslaCN TeslaCN left a comment

Choose a reason for hiding this comment

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

LGTM

@TeslaCN TeslaCN requested a review from terrymanu January 29, 2023 01:17
@terrymanu terrymanu added this to the 5.3.2 milestone Jan 29, 2023
@terrymanu
Copy link
Member

@zhfeng LGTM, thank you!

@terrymanu terrymanu merged commit 41a417e into apache:master Jan 29, 2023
@darren-wang
Copy link

@zhfeng hi, I'm new to sharding's source code, could you have a look at question #31379 thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update antlr4 to 4.10+
6 participants