Skip to content

Commit

Permalink
feat(jpms): add module-info definition for guava
Browse files Browse the repository at this point in the history
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#2970

Relates-To: elide-dev/jpms#1
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Mar 9, 2024
1 parent 3990b38 commit fcfee74
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 22 deletions.
2 changes: 1 addition & 1 deletion android/guava-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.google.guava</groupId>
<artifactId>guava-bom</artifactId>
<version>HEAD-android-SNAPSHOT</version>
<version>1.0-HEAD-android-SNAPSHOT</version>
<packaging>pom</packaging>

<parent>
Expand Down
2 changes: 1 addition & 1 deletion android/guava-testlib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-android-SNAPSHOT</version>
<version>1.0-HEAD-android-SNAPSHOT</version>
</parent>
<artifactId>guava-testlib</artifactId>
<name>Guava Testing Library</name>
Expand Down
2 changes: 1 addition & 1 deletion android/guava-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-android-SNAPSHOT</version>
<version>1.0-HEAD-android-SNAPSHOT</version>
</parent>
<artifactId>guava-tests</artifactId>
<name>Guava Unit Tests</name>
Expand Down
2 changes: 1 addition & 1 deletion android/guava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-android-SNAPSHOT</version>
<version>1.0-HEAD-android-SNAPSHOT</version>
</parent>
<artifactId>guava</artifactId>
<packaging>bundle</packaging>
Expand Down
2 changes: 1 addition & 1 deletion android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-android-SNAPSHOT</version>
<version>1.0-HEAD-android-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Guava Maven Parent</name>
<description>Parent for guava artifacts</description>
Expand Down
2 changes: 1 addition & 1 deletion guava-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.google.guava</groupId>
<artifactId>guava-bom</artifactId>
<version>HEAD-jre-SNAPSHOT</version>
<version>1.0-HEAD-jre-SNAPSHOT</version>
<packaging>pom</packaging>

<parent>
Expand Down
2 changes: 1 addition & 1 deletion guava-gwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-jre-SNAPSHOT</version>
<version>1.0-HEAD-jre-SNAPSHOT</version>
</parent>
<artifactId>guava-gwt</artifactId>
<name>Guava GWT compatible libs</name>
Expand Down
2 changes: 1 addition & 1 deletion guava-testlib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-jre-SNAPSHOT</version>
<version>1.0-HEAD-jre-SNAPSHOT</version>
</parent>
<artifactId>guava-testlib</artifactId>
<name>Guava Testing Library</name>
Expand Down
2 changes: 1 addition & 1 deletion guava-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-jre-SNAPSHOT</version>
<version>1.0-HEAD-jre-SNAPSHOT</version>
</parent>
<artifactId>guava-tests</artifactId>
<name>Guava Unit Tests</name>
Expand Down
44 changes: 42 additions & 2 deletions guava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-jre-SNAPSHOT</version>
<version>1.0-HEAD-jre-SNAPSHOT</version>
</parent>
<artifactId>guava</artifactId>
<packaging>bundle</packaging>
Expand Down Expand Up @@ -64,9 +64,11 @@
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>com.google.common</Automatic-Module-Name>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<!-- Exclude root `module-info.class` -->
<excludes>/module-info.class</excludes>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -102,6 +104,44 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>compile-java-9</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src</compileSourceRoot>
</compileSourceRoots>

<!--
JPMS needs access to the module sources to complete a modular Java build. We also need to override the
base compile settings (in the root `pom.xml`) to enable MRJAR output.
-->
<compilerArgs combine.self="override" combine.children="append">
<arg>-sourcepath</arg>
<arg>${project.basedir}/src</arg>
<arg>--add-reads=com.google.common=ALL-UNNAMED</arg>
<!-- https://errorprone.info/docs/installation#maven -->
<arg>-XDcompilePolicy=simple</arg>
</compilerArgs>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
Expand Down
44 changes: 44 additions & 0 deletions guava/src/module-info.java
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 3 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>HEAD-jre-SNAPSHOT</version>
<version>1.0-HEAD-jre-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Guava Maven Parent</name>
<description>Parent for guava artifacts</description>
Expand Down Expand Up @@ -125,21 +125,13 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.12.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<parameters>true</parameters>
<compilerArgs>
<!--
Make includes/excludes fully work:
https://issues.apache.org/jira/browse/MCOMPILER-174
(Compare what guava-gwt has to do for maven-javadoc-plugin.)
-->
<arg>-sourcepath</arg>
<arg>doesnotexist</arg>
<compilerArgs combine.children="override">
<!-- https://errorprone.info/docs/installation#maven -->
<arg>-XDcompilePolicy=simple</arg>
<!-- -Xplugin:ErrorProne is set conditionally by a profile. -->
Expand Down

0 comments on commit fcfee74

Please sign in to comment.