Skip to content

Commit 3105b5c

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 <[email protected]> Signed-off-by: Sam Gammon <[email protected]>
1 parent 453549c commit 3105b5c

File tree

13 files changed

+142
-30
lines changed

13 files changed

+142
-30
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ consult the
7171
## Snapshots and Documentation
7272

7373
Snapshots of Guava built from the `master` branch are available through Maven
74-
using version `HEAD-jre-SNAPSHOT`, or `HEAD-android-SNAPSHOT` for the Android
74+
using version `1.0-HEAD-jre-SNAPSHOT`, or `1.0-HEAD-android-SNAPSHOT` for the Android
7575
flavor.
7676

7777
[Snapshot API Javadoc][guava-snapshot-api-docs] as well as

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

+3-3
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>
@@ -42,7 +42,7 @@
4242
<module.status>integration</module.status>
4343
<variant.jvmEnvironment>android</variant.jvmEnvironment>
4444
<variant.jvmEnvironmentVariantName>android</variant.jvmEnvironmentVariantName>
45-
<otherVariant.version>HEAD-jre-SNAPSHOT</otherVariant.version>
45+
<otherVariant.version>1.0-HEAD-jre-SNAPSHOT</otherVariant.version>
4646
<otherVariant.jvmEnvironment>standard-jvm</otherVariant.jvmEnvironment>
4747
<otherVariant.jvmEnvironmentVariantName>jre</otherVariant.jvmEnvironmentVariantName>
4848
</properties>
@@ -211,7 +211,7 @@
211211
</plugin>
212212
<plugin>
213213
<artifactId>maven-jar-plugin</artifactId>
214-
<version>3.2.0</version>
214+
<version>3.4.0</version>
215215
</plugin>
216216
<plugin>
217217
<artifactId>maven-javadoc-plugin</artifactId>

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-4
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>
@@ -69,9 +69,6 @@
6969
<plugin>
7070
<artifactId>maven-toolchains-plugin</artifactId>
7171
</plugin>
72-
<plugin>
73-
<artifactId>maven-compiler-plugin</artifactId>
74-
</plugin>
7572
<plugin>
7673
<artifactId>maven-source-plugin</artifactId>
7774
<executions>

guava-tests/pom.xml

+22-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>
@@ -133,4 +133,25 @@
133133
</plugin>
134134
</plugins>
135135
</build>
136+
<profiles>
137+
<profile>
138+
<id>jvm11plus</id>
139+
<activation>
140+
<jdk>[11,]</jdk>
141+
</activation>
142+
<build>
143+
<plugins>
144+
<plugin>
145+
<artifactId>maven-compiler-plugin</artifactId>
146+
<configuration>
147+
<compilerArgs combine.self="append" combine.children="append">
148+
<arg>-Xlint:-removal</arg>
149+
<arg>-Xlint:-options</arg>
150+
</compilerArgs>
151+
</configuration>
152+
</plugin>
153+
</plugins>
154+
</build>
155+
</profile>
156+
</profiles>
136157
</project>

guava/pom.xml

+47-3
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>bundle</packaging>
@@ -65,16 +65,18 @@
6565
<configuration>
6666
<archive>
6767
<manifestEntries>
68-
<Automatic-Module-Name>com.google.common</Automatic-Module-Name>
68+
<Multi-Release>true</Multi-Release>
6969
</manifestEntries>
7070
</archive>
71+
<!-- Exclude root `module-info.class` -->
72+
<excludes>/module-info.class</excludes>
7173
</configuration>
7274
</plugin>
7375
<plugin>
7476
<extensions>true</extensions>
7577
<groupId>org.apache.felix</groupId>
7678
<artifactId>maven-bundle-plugin</artifactId>
77-
<version>5.1.8</version>
79+
<version>5.1.9</version>
7880
<executions>
7981
<execution>
8082
<id>bundle-manifest</id>
@@ -89,6 +91,7 @@
8991
<Export-Package>
9092
!com.google.common.base.internal,
9193
!com.google.common.util.concurrent.internal,
94+
!META-INF.*,
9295
com.google.common.*
9396
</Export-Package>
9497
<Import-Package>
@@ -103,6 +106,47 @@
103106
</plugin>
104107
<plugin>
105108
<artifactId>maven-compiler-plugin</artifactId>
109+
<executions>
110+
<execution>
111+
<id>default-compile</id>
112+
<configuration>
113+
<source>1.8</source>
114+
<target>1.8</target>
115+
<excludes>
116+
<exclude>module-info.java</exclude>
117+
</excludes>
118+
<compilerArgs combine.children="append" combine.self="append">
119+
<arg>-XDignore.symbol.file</arg>
120+
</compilerArgs>
121+
</configuration>
122+
</execution>
123+
<execution>
124+
<id>compile-java-9</id>
125+
<phase>compile</phase>
126+
<goals>
127+
<goal>compile</goal>
128+
</goals>
129+
<configuration>
130+
<release>9</release>
131+
<compileSourceRoots>
132+
<compileSourceRoot>${project.basedir}/src</compileSourceRoot>
133+
</compileSourceRoots>
134+
135+
<!--
136+
JPMS needs access to the module sources to complete a modular Java build. We also need to override the
137+
base compile settings (in the root `pom.xml`) to enable MRJAR output.
138+
-->
139+
<compilerArgs combine.self="override" combine.children="append">
140+
<arg>-sourcepath</arg>
141+
<arg>${project.basedir}/src</arg>
142+
<arg>--add-reads=com.google.common=ALL-UNNAMED</arg>
143+
<!-- https://errorprone.info/docs/installation#maven -->
144+
<arg>-XDcompilePolicy=simple</arg>
145+
</compilerArgs>
146+
<multiReleaseOutput>true</multiReleaseOutput>
147+
</configuration>
148+
</execution>
149+
</executions>
106150
</plugin>
107151
<plugin>
108152
<artifactId>maven-source-plugin</artifactId>

guava/src/module-info.java

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

pom.xml

+21-12
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>
@@ -42,7 +42,7 @@
4242
<module.status>integration</module.status>
4343
<variant.jvmEnvironment>standard-jvm</variant.jvmEnvironment>
4444
<variant.jvmEnvironmentVariantName>jre</variant.jvmEnvironmentVariantName>
45-
<otherVariant.version>HEAD-android-SNAPSHOT</otherVariant.version>
45+
<otherVariant.version>1.0-HEAD-android-SNAPSHOT</otherVariant.version>
4646
<otherVariant.jvmEnvironment>android</otherVariant.jvmEnvironment>
4747
<otherVariant.jvmEnvironmentVariantName>android</otherVariant.jvmEnvironmentVariantName>
4848
</properties>
@@ -146,15 +146,7 @@
146146
<target>1.8</target>
147147
<encoding>UTF-8</encoding>
148148
<parameters>true</parameters>
149-
<compilerArgs>
150-
<!--
151-
Make includes/excludes fully work:
152-
https://issues.apache.org/jira/browse/MCOMPILER-174
153-
154-
(Compare what guava-gwt has to do for maven-javadoc-plugin.)
155-
-->
156-
<arg>-sourcepath</arg>
157-
<arg>doesnotexist</arg>
149+
<compilerArgs combine.children="override">
158150
<!-- https://errorprone.info/docs/installation#maven -->
159151
<arg>-XDcompilePolicy=simple</arg>
160152
<arg>--should-stop=ifError=FLOW</arg>
@@ -182,6 +174,7 @@
182174
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
183175
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
184176
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
177+
<arg>-Xlint:-removal,-options</arg>
185178
</compilerArgs>
186179
<annotationProcessorPaths>
187180
<path>
@@ -193,6 +186,22 @@
193186
<!-- Fork because we need args like add-exports. (But see the TODO above about .mvn/jvm.config.) -->
194187
<fork>true</fork>
195188
</configuration>
189+
<executions>
190+
<execution>
191+
<id>default-compile</id>
192+
<configuration>
193+
<compilerArgs>
194+
<!--
195+
Make includes/excludes fully work:
196+
https://issues.apache.org/jira/browse/MCOMPILER-174
197+
(Compare what guava-gwt has to do for maven-javadoc-plugin.)
198+
-->
199+
<arg>-sourcepath</arg>
200+
<arg>doesnotexist</arg>
201+
</compilerArgs>
202+
</configuration>
203+
</execution>
204+
</executions>
196205
</plugin>
197206
<plugin>
198207
<artifactId>maven-dependency-plugin</artifactId>
@@ -212,7 +221,7 @@
212221
</plugin>
213222
<plugin>
214223
<artifactId>maven-jar-plugin</artifactId>
215-
<version>3.2.0</version>
224+
<version>3.4.0</version>
216225
</plugin>
217226
<plugin>
218227
<artifactId>maven-javadoc-plugin</artifactId>

0 commit comments

Comments
 (0)