Skip to content

Commit

Permalink
Modularize failureaccess.
Browse files Browse the repository at this point in the history
This is the next piece of #7094, which is progress toward [modularization](#2970).

I've modified this CL somewhat from the original version so that I can deploy a new version of `failureaccess` without needing to make any updates to `guava-parent` first. `failureaccess` does still use `guava-parent` (and I've bumped it to use the newest released version) for its configuration for Sonatype, Javadoc, etc. But I've inlined all the configuration that I need for the modularization.

I did note a few differences from the original version:
- This version includes `LICENSE` under `META-INF`, both in the main jar and in the sources jars.
- This version uses a different configuration for Javadoc, I assume because my recent changes there didn't make it into 33.4.0.

I also notice that _neither_ version contains `module-info.java` in its source jar. We could presumably fix that in the future if anyone is interested.

(And while this isn't strictly related, I do notice that we could consider also releasing a modularized version of `listenablefuture` someday.)

I have tested with:

```
$ JAVA_HOME=$HOME/.m2/jdks/jdk-17.0.13+11 ./mvnw clean install -Psonatype-oss-release -Dmaven.test.redirectTestOutputToFile=true -Dsurefire.printSummary=false -Drelease -f futures/failureaccess
```

(Some of those flags aren't necessary, but I found it easiest to copy what our release script does for "normal" releases.)

I would use `deploy` instead of `install` for the real thing.

Relates-To: elide-dev/jpms#1
Signed-off-by: Sam Gammon <[email protected]>
RELNOTES=Changed the `failureaccess` jar to be a modular jar.
PiperOrigin-RevId: 726100871
  • Loading branch information
sgammon authored and Google Java Core Libraries committed Feb 12, 2025
1 parent 89a6d25 commit 287c701
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 5 deletions.
65 changes: 60 additions & 5 deletions futures/failureaccess/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.google.guava</groupId>
<artifactId>guava-parent</artifactId>
<version>26.0-android</version>
<version>33.4.0-android</version>
</parent>
<artifactId>failureaccess</artifactId>
<version>1.0.2</version>
<packaging>bundle</packaging>
<version>1.0.3</version>
<packaging>jar</packaging>
<name>Guava InternalFutureFailureAccess and InternalFutures</name>
<description>
Contains
Expand All @@ -22,14 +22,67 @@
</description>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>8</release>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
<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>
</configuration>
</execution>
<execution>
<id>compile-java9</id>
<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. -->
<compilerArgs>
<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-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Automatic-Module-Name>com.google.common.util.concurrent.internal</Automatic-Module-Name>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<excludes>
<exclude>/module-info.class</exclude>
<exclude>META-INF/versions/9/com/google/common/util/concurrent/internal/*.class</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
Expand All @@ -55,7 +108,9 @@
</executions>
<configuration>
<instructions>
<Export-Package>com.google.common.util.concurrent.internal</Export-Package>
<!-- Silence a warning that claims that META-INF/versions/9/... is the "wrong directory" for our classes. -->
<_fixupmessages>^Classes found in the wrong directory: .*</_fixupmessages>
<Export-Package>com.google.common.util.concurrent.internal,!META-INF.*</Export-Package>
<Bundle-DocURL>https://github.com/google/guava/</Bundle-DocURL>
</instructions>
</configuration>
Expand Down
18 changes: 18 additions & 0 deletions futures/failureaccess/src/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2024 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.
*/

/** Guava: {@code Future} Internals. */
module com.google.common.util.concurrent.internal {
exports com.google.common.util.concurrent.internal;
}

0 comments on commit 287c701

Please sign in to comment.