From 9ffd7f7d139b17764fadea14cbf07835a33f0c80 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 - 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 Signed-off-by: Sam Gammon --- README.md | 2 +- android/guava-bom/pom.xml | 2 +- android/guava-testlib/pom.xml | 2 +- android/guava-tests/pom.xml | 2 +- android/guava/pom.xml | 2 +- android/pom.xml | 6 ++--- guava-bom/pom.xml | 2 +- guava-gwt/pom.xml | 2 +- guava-testlib/pom.xml | 2 +- guava-tests/pom.xml | 2 +- guava/pom.xml | 50 ++++++++++++++++++++++++++++++++--- guava/src/module-info.java | 44 ++++++++++++++++++++++++++++++ pom.xml | 17 ++++-------- 13 files changed, 108 insertions(+), 27 deletions(-) create mode 100644 guava/src/module-info.java diff --git a/README.md b/README.md index a182a6b4f509..1ab42bf3149b 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 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..49627f59860f 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 diff --git a/android/pom.xml b/android/pom.xml index 32fcdf0e7b4c..a7de12be395c 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,7 +42,7 @@ integration android android - HEAD-jre-SNAPSHOT + 1.0-HEAD-jre-SNAPSHOT standard-jvm jre @@ -211,7 +211,7 @@ maven-jar-plugin - 3.2.0 + 3.3.0 maven-javadoc-plugin 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..96da5abe5969 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 diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index 65061deb809c..7d4186391197 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 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/pom.xml b/guava/pom.xml index d47241bee8a1..4731b68347ba 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 @@ -65,16 +65,18 @@ - com.google.common + true + + /module-info.class true org.apache.felix maven-bundle-plugin - 5.1.8 + 5.1.9 bundle-manifest @@ -89,6 +91,7 @@ !com.google.common.base.internal, !com.google.common.util.concurrent.internal, + !META-INF.*, com.google.common.* @@ -103,6 +106,47 @@ maven-compiler-plugin + + + default-compile + + 1.8 + 1.8 + + module-info.java + + + -XDignore.symbol.file + + + + + compile-java-9 + 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..e459eb9d9e8e --- /dev/null +++ b/guava/src/module-info.java @@ -0,0 +1,44 @@ +// GENERATED FILE - DO NOT EDIT + +/* + * 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 java.base; + requires java.logging; + requires jdk.unsupported; + + 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; + exports com.google.thirdparty.publicsuffix; +} diff --git a/pom.xml b/pom.xml index 46623678d3be..9ff993737522 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 @@ -146,15 +146,7 @@ 1.8 UTF-8 true - - - -sourcepath - doesnotexist + -XDcompilePolicy=simple --should-stop=ifError=FLOW @@ -182,6 +174,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 @@ -212,7 +205,7 @@ maven-jar-plugin - 3.2.0 + 3.3.0 maven-javadoc-plugin