From bf0885dd39323183d3be8f8841514d2913446c10 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 12:43:34 -0800 Subject: [PATCH] feat(jpms): add `module-info` definition for guava MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - feat(jpms): add `module-info.java` to `failureaccess` - feat(jpms): add `module-info.java` to `testlib` - fix: necessary fixes to get testsuite running on modular java - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google/guava#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon --- README.md | 4 +- android/guava-bom/pom.xml | 2 +- android/guava-testlib/pom.xml | 2 +- android/guava-tests/pom.xml | 2 +- android/guava/pom.xml | 4 +- android/pom.xml | 22 ++++++-- futures/failureaccess/pom.xml | 45 ++++++++++++++-- futures/failureaccess/src/module-info.java | 20 ++++++++ guava-bom/pom.xml | 2 +- guava-gwt/pom.xml | 29 ++++++----- guava-testlib/pom.xml | 41 ++++++++++++++- guava-testlib/src/module-info.java | 30 +++++++++++ guava-tests/pom.xml | 2 +- guava/module.json | 8 +-- guava/pom.xml | 50 ++++++++++++++---- guava/src/module-info.java | 41 +++++++++++++++ integration-tests/gradle/build.gradle.kts | 4 +- pom.xml | 60 +++++++++++++++++----- 18 files changed, 310 insertions(+), 58 deletions(-) create mode 100644 futures/failureaccess/src/module-info.java create mode 100644 guava-testlib/src/module-info.java create mode 100644 guava/src/module-info.java diff --git a/README.md b/README.md index a182a6b4f509..ec4473051c1f 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ consult the ## Snapshots and Documentation Snapshots of Guava built from the `master` branch are available through Maven -using version `HEAD-jre-SNAPSHOT`, or `HEAD-android-SNAPSHOT` for the Android +using version `1.0-HEAD-jre-SNAPSHOT`, or `1.0-HEAD-android-SNAPSHOT` for the Android flavor. [Snapshot API Javadoc][guava-snapshot-api-docs] as well as @@ -108,7 +108,7 @@ flavor. options open in case of surprises (like, say, a serious security problem). 3. Guava has one dependency that is needed for linkage at runtime: - `com.google.guava:failureaccess:1.0.2`. It also has + `com.google.guava:failureaccess:1.0.3`. It also has [some annotation-only dependencies][guava-deps], which we discuss in more detail at that link. diff --git a/android/guava-bom/pom.xml b/android/guava-bom/pom.xml index 8fde93d1a75a..e6a5d9f132ac 100644 --- a/android/guava-bom/pom.xml +++ b/android/guava-bom/pom.xml @@ -8,7 +8,7 @@ com.google.guava guava-bom - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT pom diff --git a/android/guava-testlib/pom.xml b/android/guava-testlib/pom.xml index b1575bc06144..4f1ea6d336a6 100644 --- a/android/guava-testlib/pom.xml +++ b/android/guava-testlib/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT guava-testlib Guava Testing Library diff --git a/android/guava-tests/pom.xml b/android/guava-tests/pom.xml index a0170657f827..4886c1f1f605 100644 --- a/android/guava-tests/pom.xml +++ b/android/guava-tests/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT guava-tests Guava Unit Tests diff --git a/android/guava/pom.xml b/android/guava/pom.xml index b39871f4495e..f75c96a3932d 100644 --- a/android/guava/pom.xml +++ b/android/guava/pom.xml @@ -6,7 +6,7 @@ com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT guava bundle @@ -21,7 +21,7 @@ com.google.guava failureaccess - 1.0.2 + 1.0.3 com.google.guava diff --git a/android/pom.xml b/android/pom.xml index 32fcdf0e7b4c..65a79abfca72 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.google.guava guava-parent - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT pom Guava Maven Parent Parent for guava artifacts @@ -42,9 +42,11 @@ integration android android - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT standard-jvm jre + https://oss.sonatype.org/content/repositories/snapshots/ + https://oss.sonatype.org/service/local/staging/deploy/maven2/ GitHub Issues @@ -86,6 +88,7 @@ guava-bom guava-testlib guava-tests + ../futures/failureaccess @@ -211,7 +214,20 @@ maven-jar-plugin - 3.2.0 + 3.4.0 + + + + /module-info.class + + META-INF/versions/9/com/**/*.class + + + + true + + + maven-javadoc-plugin diff --git a/futures/failureaccess/pom.xml b/futures/failureaccess/pom.xml index 8886a4b2f7de..46d5ae73b1c9 100644 --- a/futures/failureaccess/pom.xml +++ b/futures/failureaccess/pom.xml @@ -5,11 +5,12 @@ com.google.guava guava-parent - 26.0-android + 1.0-HEAD-jre-SNAPSHOT + ../../pom.xml failureaccess - 1.0.2 - bundle + 1.0.3 + jar Guava InternalFutureFailureAccess and InternalFutures Contains @@ -22,14 +23,47 @@ + + maven-compiler-plugin + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + -Xlint:-removal,-options + + + + + compile-java9 + + compile + + + 9 + true + + + + maven-jar-plugin + ${project.build.outputDirectory}/META-INF/MANIFEST.MF - com.google.common.util.concurrent.internal + true + + /module-info.class + META-INF/versions/9/com/google/common/util/concurrent/internal/*.class + @@ -55,7 +89,8 @@ - com.google.common.util.concurrent.internal + <_fixupmessages>^Classes found in the wrong directory: .* + com.google.common.util.concurrent.internal,!META-INF.* https://github.com/google/guava/ diff --git a/futures/failureaccess/src/module-info.java b/futures/failureaccess/src/module-info.java new file mode 100644 index 000000000000..71ea64d24570 --- /dev/null +++ b/futures/failureaccess/src/module-info.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +/** + * Guava: Future Internals. + */ +module com.google.common.util.concurrent.internal { + exports com.google.common.util.concurrent.internal; +} diff --git a/guava-bom/pom.xml b/guava-bom/pom.xml index 8c5ea2ec035f..af7c956adbaa 100644 --- a/guava-bom/pom.xml +++ b/guava-bom/pom.xml @@ -8,7 +8,7 @@ com.google.guava guava-bom - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT pom diff --git a/guava-gwt/pom.xml b/guava-gwt/pom.xml index 54273437840d..4d4d197a29de 100644 --- a/guava-gwt/pom.xml +++ b/guava-gwt/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava-gwt Guava GWT compatible libs @@ -45,7 +45,7 @@ com.google.guava failureaccess - 1.0.2 + 1.0.3 com.google.guava @@ -134,15 +134,20 @@ maven-compiler-plugin - - - - - - **/ForceGuavaCompilation* - **/DummyJavadocClass* - - + + + default-compile + + + + + + **/ForceGuavaCompilation* + **/DummyJavadocClass* + + + + maven-jar-plugin @@ -262,7 +267,7 @@ com.google.guava failureaccess - 1.0.2 + 1.0.3 sources diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index 65061deb809c..15ba63601a6b 100644 --- a/guava-testlib/pom.xml +++ b/guava-testlib/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava-testlib Guava Testing Library @@ -71,6 +71,45 @@ maven-compiler-plugin + + + default-compile + + + -XDignore.symbol.file + + + + + compile-java9 + compile + + compile + + + 9 + + ${project.basedir}/src + + + + + -sourcepath + ${project.basedir}/src + --add-reads=com.google.common=ALL-UNNAMED + --add-reads=com.google.common.testlib=ALL-UNNAMED + + -XDcompilePolicy=simple + -Xlint:-removal + -Xlint:-options + + true + + + maven-source-plugin diff --git a/guava-testlib/src/module-info.java b/guava-testlib/src/module-info.java new file mode 100644 index 000000000000..f0384d9911cf --- /dev/null +++ b/guava-testlib/src/module-info.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +/** + * Guava Testlib + */ +open module com.google.common.testlib { + requires java.logging; + requires com.google.common; + requires com.google.common.util.concurrent.internal; + + exports com.google.common.collect.testing; + exports com.google.common.collect.testing.features; + exports com.google.common.collect.testing.google; + exports com.google.common.collect.testing.testers; + exports com.google.common.escape.testing; + exports com.google.common.testing; + exports com.google.common.util.concurrent.testing; +} diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index f387806880c3..595d4c3fc436 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -5,7 +5,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava-tests Guava Unit Tests diff --git a/guava/module.json b/guava/module.json index e7116c882a7e..e621749cfe0d 100644 --- a/guava/module.json +++ b/guava/module.json @@ -30,7 +30,7 @@ "group": "com.google.guava", "module": "failureaccess", "version": { - "requires": "1.0.2" + "requires": "1.0.3" } }, { @@ -96,7 +96,7 @@ "group": "com.google.guava", "module": "failureaccess", "version": { - "requires": "1.0.2" + "requires": "1.0.3" } }, { @@ -162,7 +162,7 @@ "group": "com.google.guava", "module": "failureaccess", "version": { - "requires": "1.0.2" + "requires": "1.0.3" } }, { @@ -228,7 +228,7 @@ "group": "com.google.guava", "module": "failureaccess", "version": { - "requires": "1.0.2" + "requires": "1.0.3" } }, { diff --git a/guava/pom.xml b/guava/pom.xml index d47241bee8a1..524bdcfefb23 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -6,7 +6,7 @@ com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT guava bundle @@ -21,7 +21,7 @@ com.google.guava failureaccess - 1.0.2 + 1.0.3 com.google.guava @@ -62,19 +62,12 @@ maven-jar-plugin - - - - com.google.common - - - true org.apache.felix maven-bundle-plugin - 5.1.8 + 5.1.9 bundle-manifest @@ -89,6 +82,7 @@ !com.google.common.base.internal, !com.google.common.util.concurrent.internal, + !META-INF.*, com.google.common.* @@ -103,6 +97,42 @@ maven-compiler-plugin + + + default-compile + + + -XDignore.symbol.file + + + + + compile-java9 + compile + + compile + + + 9 + + ${project.basedir}/src + + + + + -sourcepath + ${project.basedir}/src + --add-reads=com.google.common=ALL-UNNAMED + + -XDcompilePolicy=simple + + true + + + maven-source-plugin diff --git a/guava/src/module-info.java b/guava/src/module-info.java new file mode 100644 index 000000000000..36a6123c2095 --- /dev/null +++ b/guava/src/module-info.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2008 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Google Guava + */ +module com.google.common { + requires static jdk.unsupported; + requires java.logging; + requires com.google.common.util.concurrent.internal; + + exports com.google.common.annotations; + exports com.google.common.base; + exports com.google.common.cache; + exports com.google.common.collect; + exports com.google.common.escape; + exports com.google.common.eventbus; + exports com.google.common.graph; + exports com.google.common.hash; + exports com.google.common.html; + exports com.google.common.io; + exports com.google.common.math; + exports com.google.common.net; + exports com.google.common.primitives; + exports com.google.common.reflect; + exports com.google.common.util.concurrent; + exports com.google.common.xml; +} diff --git a/integration-tests/gradle/build.gradle.kts b/integration-tests/gradle/build.gradle.kts index 9f7ff73a8959..4b633a7f340e 100644 --- a/integration-tests/gradle/build.gradle.kts +++ b/integration-tests/gradle/build.gradle.kts @@ -7,7 +7,7 @@ val guavaVersionJre = val expectedReducedRuntimeClasspathAndroidVersion = setOf( "guava-${guavaVersionJre.replace("jre", "android")}.jar", - "failureaccess-1.0.2.jar", + "failureaccess-1.0.3.jar", "j2objc-annotations-3.0.0.jar", "jspecify-1.0.0.jar", "error_prone_annotations-2.36.0.jar", @@ -16,7 +16,7 @@ val expectedReducedRuntimeClasspathAndroidVersion = val expectedReducedRuntimeClasspathJreVersion = setOf( "guava-$guavaVersionJre.jar", - "failureaccess-1.0.2.jar", + "failureaccess-1.0.3.jar", "j2objc-annotations-3.0.0.jar", "jspecify-1.0.0.jar", "error_prone_annotations-2.36.0.jar", diff --git a/pom.xml b/pom.xml index 46623678d3be..faf44101b251 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.google.guava guava-parent - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT pom Guava Maven Parent Parent for guava artifacts @@ -42,7 +42,7 @@ integration standard-jvm jre - HEAD-android-SNAPSHOT + 1.0-HEAD-android-SNAPSHOT android android @@ -87,6 +87,7 @@ guava-gwt guava-testlib guava-tests + futures/failureaccess @@ -146,15 +147,7 @@ 1.8 UTF-8 true - - - -sourcepath - doesnotexist + -XDcompilePolicy=simple --should-stop=ifError=FLOW @@ -182,6 +175,7 @@ -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + -Xlint:-removal,-options @@ -193,6 +187,35 @@ true + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + + -sourcepath + doesnotexist + + + + + default-testCompile + + + -Xlint:-removal + + + + maven-dependency-plugin @@ -212,7 +235,20 @@ maven-jar-plugin - 3.2.0 + 3.4.0 + + + + /module-info.class + + META-INF/versions/9/com/**/*.class + + + + true + + + maven-javadoc-plugin