Skip to content

Commit

Permalink
Make error_prone_annotations dependency optional
Browse files Browse the repository at this point in the history
Annotations with retention policy are ignored if they cannot be loaded at runtime (at least according to [Stack-Overvflow](https://stackoverflow.com/questions/3567413/why-doesnt-a-missing-annotation-cause-a-classnotfoundexception-at-runtime)). Make the dependency optional to not enforce the presence of error_prone_annotations in a java runtime even if those annotations are not used at all.

This is especially useful for OSGi-runtimes where you cannot exclude error_prone_annotations because the corresponding package is specified as mandatory requirement in the MANIFEST.MF. Marking the Maven dependency as optional will also result in the error-prone package requirement being marked as optional.

At the moment error_prone_annotations does not come with a OSGi compliant Manifest, which makes it harder to include it in OSGi applications like Eclipse.
I already created a PR at error-prone to include the required OSGi headers (see google/error-prone#3903), but not requiring the annotations at all would make it even simpler to use guice within OSGi.

Alternatively the dependency could be marked as optional in the OSGi metadata.

Fixes #1739

COPYBARA_INTEGRATE_REVIEW=#1739 from HannesWell:optionalErrorproneAnnotations 86f9de0
PiperOrigin-RevId: 531531783
  • Loading branch information
HannesWell authored and Guice Team committed May 12, 2023
1 parent 654032a commit f4a66b7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<optional>true</optional>
</dependency>
<!--
| ASM is embedded by default by the JarJar build profile
Expand Down

0 comments on commit f4a66b7

Please sign in to comment.