Skip to content

Commit e3bab2c

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 - 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#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <sam@elide.dev>
1 parent 453549c commit e3bab2c

File tree

18 files changed

+310
-58
lines changed

18 files changed

+310
-58
lines changed

README.md

+2-2
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
@@ -108,7 +108,7 @@ flavor.
108108
options open in case of surprises (like, say, a serious security problem).
109109

110110
3. Guava has one dependency that is needed for linkage at runtime:
111-
`com.google.guava:failureaccess:1.0.2`. It also has
111+
`com.google.guava:failureaccess:1.0.3`. It also has
112112
[some annotation-only dependencies][guava-deps], which we discuss in more
113113
detail at that link.
114114

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

+2-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-android-SNAPSHOT</version>
9+
<version>1.0-HEAD-android-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>guava</artifactId>
1212
<packaging>bundle</packaging>
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>com.google.guava</groupId>
2323
<artifactId>failureaccess</artifactId>
24-
<version>1.0.2</version>
24+
<version>1.0.3</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>com.google.guava</groupId>

android/pom.xml

+19-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,9 +42,11 @@
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>
48+
<publishing.repository.snapshots>https://oss.sonatype.org/content/repositories/snapshots/</publishing.repository.snapshots>
49+
<publishing.repository.releases>https://oss.sonatype.org/service/local/staging/deploy/maven2/</publishing.repository.releases>
4850
</properties>
4951
<issueManagement>
5052
<system>GitHub Issues</system>
@@ -86,6 +88,7 @@
8688
<module>guava-bom</module>
8789
<module>guava-testlib</module>
8890
<module>guava-tests</module>
91+
<module>../futures/failureaccess</module>
8992
</modules>
9093
<build>
9194
<!-- Handle where Guava deviates from Maven defaults -->
@@ -211,7 +214,20 @@
211214
</plugin>
212215
<plugin>
213216
<artifactId>maven-jar-plugin</artifactId>
214-
<version>3.2.0</version>
217+
<version>3.4.0</version>
218+
<configuration>
219+
<excludes>
220+
<!-- The root module (where applicable) is withheld because it is provided at `META-INF/versions/9/`. -->
221+
<exclude>/module-info.class</exclude>
222+
<!-- Avoid duplicating compiled classes within the `META-INF/versions/9/` root. -->
223+
<exclude>META-INF/versions/9/com/**/*.class</exclude>
224+
</excludes>
225+
<archive>
226+
<manifestEntries>
227+
<Multi-Release>true</Multi-Release>
228+
</manifestEntries>
229+
</archive>
230+
</configuration>
215231
</plugin>
216232
<plugin>
217233
<artifactId>maven-javadoc-plugin</artifactId>

futures/failureaccess/pom.xml

+40-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
<parent>
66
<groupId>com.google.guava</groupId>
77
<artifactId>guava-parent</artifactId>
8-
<version>26.0-android</version>
8+
<version>1.0-HEAD-jre-SNAPSHOT</version>
9+
<relativePath>../../pom.xml</relativePath>
910
</parent>
1011
<artifactId>failureaccess</artifactId>
11-
<version>1.0.2</version>
12-
<packaging>bundle</packaging>
12+
<version>1.0.3</version>
13+
<packaging>jar</packaging>
1314
<name>Guava InternalFutureFailureAccess and InternalFutures</name>
1415
<description>
1516
Contains
@@ -22,14 +23,47 @@
2223
</description>
2324
<build>
2425
<plugins>
26+
<plugin>
27+
<artifactId>maven-compiler-plugin</artifactId>
28+
<executions>
29+
<execution>
30+
<id>default-compile</id>
31+
<configuration>
32+
<source>1.8</source>
33+
<target>1.8</target>
34+
<excludes>
35+
<exclude>module-info.java</exclude>
36+
</excludes>
37+
<compilerArgs>
38+
<arg>-Xlint:-removal,-options</arg>
39+
</compilerArgs>
40+
</configuration>
41+
</execution>
42+
<execution>
43+
<id>compile-java9</id>
44+
<goals>
45+
<goal>compile</goal>
46+
</goals>
47+
<configuration>
48+
<release>9</release>
49+
<multiReleaseOutput>true</multiReleaseOutput>
50+
</configuration>
51+
</execution>
52+
</executions>
53+
</plugin>
2554
<plugin>
2655
<artifactId>maven-jar-plugin</artifactId>
2756
<configuration>
2857
<archive>
58+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
2959
<manifestEntries>
30-
<Automatic-Module-Name>com.google.common.util.concurrent.internal</Automatic-Module-Name>
60+
<Multi-Release>true</Multi-Release>
3161
</manifestEntries>
3262
</archive>
63+
<excludes>
64+
<exclude>/module-info.class</exclude>
65+
<exclude>META-INF/versions/9/com/google/common/util/concurrent/internal/*.class</exclude>
66+
</excludes>
3367
</configuration>
3468
</plugin>
3569
<plugin>
@@ -55,7 +89,8 @@
5589
</executions>
5690
<configuration>
5791
<instructions>
58-
<Export-Package>com.google.common.util.concurrent.internal</Export-Package>
92+
<_fixupmessages>^Classes found in the wrong directory: .*</_fixupmessages>
93+
<Export-Package>com.google.common.util.concurrent.internal,!META-INF.*</Export-Package>
5994
<Bundle-DocURL>https://github.com/google/guava/</Bundle-DocURL>
6095
</instructions>
6196
</configuration>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (C) 2024 The Guava Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
/**
16+
* Guava: Future Internals.
17+
*/
18+
module com.google.common.util.concurrent.internal {
19+
exports com.google.common.util.concurrent.internal;
20+
}

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

+17-12
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>
@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>com.google.guava</groupId>
4747
<artifactId>failureaccess</artifactId>
48-
<version>1.0.2</version>
48+
<version>1.0.3</version>
4949
</dependency>
5050
<dependency>
5151
<groupId>com.google.guava</groupId>
@@ -134,15 +134,20 @@
134134
</plugin>
135135
<plugin>
136136
<artifactId>maven-compiler-plugin</artifactId>
137-
<configuration>
138-
<excludes>
139-
<!-- Yes, we want to exclude ForceGuavaCompilation 4 times: -->
140-
<!-- (And we might as well exclude DummyJavadocClass 3 times (though it would be harmless to include).) -->
141-
<!-- 1. Don't compile it (since that requires a *non-test* dep on gwt-user. -->
142-
<exclude>**/ForceGuavaCompilation*</exclude>
143-
<exclude>**/DummyJavadocClass*</exclude>
144-
</excludes>
145-
</configuration>
137+
<executions>
138+
<execution>
139+
<id>default-compile</id>
140+
<configuration>
141+
<excludes>
142+
<!-- Yes, we want to exclude ForceGuavaCompilation 4 times: -->
143+
<!-- (And we might as well exclude DummyJavadocClass 3 times (though it would be harmless to include).) -->
144+
<!-- 1. Don't compile it (since that requires a *non-test* dep on gwt-user. -->
145+
<exclude>**/ForceGuavaCompilation*</exclude>
146+
<exclude>**/DummyJavadocClass*</exclude>
147+
</excludes>
148+
</configuration>
149+
</execution>
150+
</executions>
146151
</plugin>
147152
<plugin>
148153
<artifactId>maven-jar-plugin</artifactId>
@@ -262,7 +267,7 @@
262267
<dependency>
263268
<groupId>com.google.guava</groupId>
264269
<artifactId>failureaccess</artifactId>
265-
<version>1.0.2</version>
270+
<version>1.0.3</version>
266271
<classifier>sources</classifier>
267272
</dependency>
268273
<dependency>

guava-testlib/pom.xml

+40-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>
@@ -71,6 +71,45 @@
7171
</plugin>
7272
<plugin>
7373
<artifactId>maven-compiler-plugin</artifactId>
74+
<executions>
75+
<execution>
76+
<id>default-compile</id>
77+
<configuration>
78+
<compilerArgs combine.children="append" combine.self="append">
79+
<arg>-XDignore.symbol.file</arg>
80+
</compilerArgs>
81+
</configuration>
82+
</execution>
83+
<execution>
84+
<id>compile-java9</id>
85+
<phase>compile</phase>
86+
<goals>
87+
<goal>compile</goal>
88+
</goals>
89+
<configuration>
90+
<release>9</release>
91+
<compileSourceRoots>
92+
<compileSourceRoot>${project.basedir}/src</compileSourceRoot>
93+
</compileSourceRoots>
94+
95+
<!--
96+
JPMS needs access to the module sources to complete a modular Java build. We also need to override
97+
the base compiler settings (in the root `pom.xml`) to enable MRJAR output.
98+
-->
99+
<compilerArgs combine.self="override" combine.children="append">
100+
<arg>-sourcepath</arg>
101+
<arg>${project.basedir}/src</arg>
102+
<arg>--add-reads=com.google.common=ALL-UNNAMED</arg>
103+
<arg>--add-reads=com.google.common.testlib=ALL-UNNAMED</arg>
104+
<!-- https://errorprone.info/docs/installation#maven -->
105+
<arg>-XDcompilePolicy=simple</arg>
106+
<arg>-Xlint:-removal</arg>
107+
<arg>-Xlint:-options</arg>
108+
</compilerArgs>
109+
<multiReleaseOutput>true</multiReleaseOutput>
110+
</configuration>
111+
</execution>
112+
</executions>
74113
</plugin>
75114
<plugin>
76115
<artifactId>maven-source-plugin</artifactId>

guava-testlib/src/module-info.java

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2024 The Guava Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
/**
16+
* Guava Testlib
17+
*/
18+
open module com.google.common.testlib {
19+
requires java.logging;
20+
requires com.google.common;
21+
requires com.google.common.util.concurrent.internal;
22+
23+
exports com.google.common.collect.testing;
24+
exports com.google.common.collect.testing.features;
25+
exports com.google.common.collect.testing.google;
26+
exports com.google.common.collect.testing.testers;
27+
exports com.google.common.escape.testing;
28+
exports com.google.common.testing;
29+
exports com.google.common.util.concurrent.testing;
30+
}

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>

0 commit comments

Comments
 (0)