Skip to content

Commit b6d8ea5

Browse files
committed
feat(jpms): add module-info definition for guava
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 <sam@elide.ventures>
1 parent c5846e1 commit b6d8ea5

File tree

12 files changed

+98
-22
lines changed

12 files changed

+98
-22
lines changed

android/guava-bom/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>com.google.guava</groupId>
1010
<artifactId>guava-bom</artifactId>
11-
<version>HEAD-android-SNAPSHOT</version>
11+
<version>1.0-HEAD-android-SNAPSHOT</version>
1212
<packaging>pom</packaging>
1313

1414
<parent>

android/guava-testlib/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.google.guava</groupId>
77
<artifactId>guava-parent</artifactId>
8-
<version>HEAD-android-SNAPSHOT</version>
8+
<version>1.0-HEAD-android-SNAPSHOT</version>
99
</parent>
1010
<artifactId>guava-testlib</artifactId>
1111
<name>Guava Testing Library</name>

android/guava-tests/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.google.guava</groupId>
77
<artifactId>guava-parent</artifactId>
8-
<version>HEAD-android-SNAPSHOT</version>
8+
<version>1.0-HEAD-android-SNAPSHOT</version>
99
</parent>
1010
<artifactId>guava-tests</artifactId>
1111
<name>Guava Unit Tests</name>

android/guava/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.google.guava</groupId>
88
<artifactId>guava-parent</artifactId>
9-
<version>HEAD-android-SNAPSHOT</version>
9+
<version>1.0-HEAD-android-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>guava</artifactId>
1212
<packaging>bundle</packaging>

android/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.google.guava</groupId>
88
<artifactId>guava-parent</artifactId>
9-
<version>HEAD-android-SNAPSHOT</version>
9+
<version>1.0-HEAD-android-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111
<name>Guava Maven Parent</name>
1212
<description>Parent for guava artifacts</description>

guava-bom/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>com.google.guava</groupId>
1010
<artifactId>guava-bom</artifactId>
11-
<version>HEAD-jre-SNAPSHOT</version>
11+
<version>1.0-HEAD-jre-SNAPSHOT</version>
1212
<packaging>pom</packaging>
1313

1414
<parent>

guava-gwt/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.google.guava</groupId>
77
<artifactId>guava-parent</artifactId>
8-
<version>HEAD-jre-SNAPSHOT</version>
8+
<version>1.0-HEAD-jre-SNAPSHOT</version>
99
</parent>
1010
<artifactId>guava-gwt</artifactId>
1111
<name>Guava GWT compatible libs</name>

guava-testlib/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.google.guava</groupId>
77
<artifactId>guava-parent</artifactId>
8-
<version>HEAD-jre-SNAPSHOT</version>
8+
<version>1.0-HEAD-jre-SNAPSHOT</version>
99
</parent>
1010
<artifactId>guava-testlib</artifactId>
1111
<name>Guava Testing Library</name>

guava-tests/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.google.guava</groupId>
77
<artifactId>guava-parent</artifactId>
8-
<version>HEAD-jre-SNAPSHOT</version>
8+
<version>1.0-HEAD-jre-SNAPSHOT</version>
99
</parent>
1010
<artifactId>guava-tests</artifactId>
1111
<name>Guava Unit Tests</name>

guava/pom.xml

+42-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.google.guava</groupId>
88
<artifactId>guava-parent</artifactId>
9-
<version>HEAD-jre-SNAPSHOT</version>
9+
<version>1.0-HEAD-jre-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>guava</artifactId>
1212
<packaging>jar</packaging>
@@ -62,9 +62,11 @@
6262
<configuration>
6363
<archive>
6464
<manifestEntries>
65-
<Automatic-Module-Name>com.google.common</Automatic-Module-Name>
65+
<Multi-Release>true</Multi-Release>
6666
</manifestEntries>
6767
</archive>
68+
<!-- Exclude root `module-info.class` -->
69+
<excludes>/module-info.class</excludes>
6870
</configuration>
6971
</plugin>
7072
<plugin>
@@ -100,6 +102,44 @@
100102
</plugin>
101103
<plugin>
102104
<artifactId>maven-compiler-plugin</artifactId>
105+
<executions>
106+
<execution>
107+
<id>default-compile</id>
108+
<configuration>
109+
<source>1.8</source>
110+
<target>1.8</target>
111+
<excludes>
112+
<exclude>module-info.java</exclude>
113+
</excludes>
114+
</configuration>
115+
</execution>
116+
<execution>
117+
<id>compile-java-9</id>
118+
<phase>compile</phase>
119+
<goals>
120+
<goal>compile</goal>
121+
</goals>
122+
<configuration>
123+
<release>9</release>
124+
<compileSourceRoots>
125+
<compileSourceRoot>${project.basedir}/src</compileSourceRoot>
126+
</compileSourceRoots>
127+
128+
<!--
129+
JPMS needs access to the module sources to complete a modular Java build. We also need to override the
130+
base compile settings (in the root `pom.xml`) to enable MRJAR output.
131+
-->
132+
<compilerArgs combine.self="override" combine.children="append">
133+
<arg>-sourcepath</arg>
134+
<arg>${project.basedir}/src</arg>
135+
<arg>--add-reads=com.google.common=ALL-UNNAMED</arg>
136+
<!-- https://errorprone.info/docs/installation#maven -->
137+
<arg>-XDcompilePolicy=simple</arg>
138+
</compilerArgs>
139+
<multiReleaseOutput>true</multiReleaseOutput>
140+
</configuration>
141+
</execution>
142+
</executions>
103143
</plugin>
104144
<plugin>
105145
<artifactId>maven-source-plugin</artifactId>

guava/src/module-info.java

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// GENERATED FILE - DO NOT EDIT
2+
3+
/*
4+
* Copyright (C) 2008 The Guava Authors
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* Google Guava
21+
*/
22+
module com.google.common {
23+
requires java.base;
24+
requires java.logging;
25+
requires jdk.unsupported;
26+
27+
exports com.google.common.annotations;
28+
exports com.google.common.base;
29+
exports com.google.common.cache;
30+
exports com.google.common.collect;
31+
exports com.google.common.escape;
32+
exports com.google.common.eventbus;
33+
exports com.google.common.graph;
34+
exports com.google.common.hash;
35+
exports com.google.common.html;
36+
exports com.google.common.io;
37+
exports com.google.common.math;
38+
exports com.google.common.net;
39+
exports com.google.common.primitives;
40+
exports com.google.common.reflect;
41+
exports com.google.common.util.concurrent;
42+
exports com.google.common.xml;
43+
exports com.google.thirdparty.publicsuffix;
44+
}

pom.xml

+3-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.google.guava</groupId>
88
<artifactId>guava-parent</artifactId>
9-
<version>HEAD-jre-SNAPSHOT</version>
9+
<version>1.0-HEAD-jre-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111
<name>Guava Maven Parent</name>
1212
<description>Parent for guava artifacts</description>
@@ -125,21 +125,13 @@
125125
<plugins>
126126
<plugin>
127127
<artifactId>maven-compiler-plugin</artifactId>
128-
<version>3.8.1</version>
128+
<version>3.12.1</version>
129129
<configuration>
130130
<source>1.8</source>
131131
<target>1.8</target>
132132
<encoding>UTF-8</encoding>
133133
<parameters>true</parameters>
134-
<compilerArgs>
135-
<!--
136-
Make includes/excludes fully work:
137-
https://issues.apache.org/jira/browse/MCOMPILER-174
138-
139-
(Compare what guava-gwt has to do for maven-javadoc-plugin.)
140-
-->
141-
<arg>-sourcepath</arg>
142-
<arg>doesnotexist</arg>
134+
<compilerArgs combine.children="override">
143135
<!-- https://errorprone.info/docs/installation#maven -->
144136
<arg>-XDcompilePolicy=simple</arg>
145137
<!-- -Xplugin:ErrorProne is set conditionally by a profile. -->

0 commit comments

Comments
 (0)