reportonlyreachable still fails on optional
I have a plugin that depends on maven-core:3.8.2. Even with the reportonlyreachable flag set true, https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/Linkage-Checker-Enforcer-Rule-Tutorial#reportonlyreachable-flag the rule fails with
[ERROR] Linkage Checker rule found 3 reachable errors: Class org.fusesource.jansi.Ansi is not found; referenced by 2 class files org.apache.maven.shared.utils.logging.AnsiMessageBuilder (org.apache.maven.shared:maven-shared-utils:3.3.4) org.apache.maven.shared.utils.logging.Style (org.apache.maven.shared:maven-shared-utils:3.3.4) Cause: The valid symbol is in org.fusesource.jansi:jansi:jar:2.2.0 at com.etc:etc-maven-plugin:jar:2.2.0 / org.apache.maven.shared:maven-shared-utils:3.3.4 (compile) / org.fusesource.jansi:jansi:2.2.0 (compile, optional) but it was not selected because the path contains an optional dependency Class org.fusesource.jansi.AnsiConsole is not found; referenced by 1 class file org.apache.maven.shared.utils.logging.MessageUtils (org.apache.maven.shared:maven-shared-utils:3.3.4) Cause: The valid symbol is in org.fusesource.jansi:jansi:jar:2.2.0 at com.etc:etc-maven-plugin:jar:2.2.0 / org.apache.maven.shared:maven-shared-utils:3.3.4 (compile) / org.fusesource.jansi:jansi:2.2.0 (compile, optional) but it was not selected because the path contains an optional dependency Class org.fusesource.jansi.Ansi$Color is not found; referenced by 1 class file org.apache.maven.shared.utils.logging.Style (org.apache.maven.shared:maven-shared-utils:3.3.4) Cause: The valid symbol is in org.fusesource.jansi:jansi:jar:2.2.0 at com.etc:etc-maven-plugin:jar:2.2.0 / org.apache.maven.shared:maven-shared-utils:3.3.4 (compile) / org.fusesource.jansi:jansi:2.2.0 (compile, optional) but it was not selected because the path contains an optional dependency Problematic artifacts in the dependency tree: org.apache.maven.shared:maven-shared-utils:3.3.4 is at: com.etc:etc-maven-plugin:jar:2.2.0 / org.apache.maven.shared:maven-shared-utils:3.3.4 (compile)
<rules>
<LinkageCheckerRule implementation="com.google.cloud.tools.dependencies.enforcer.LinkageCheckerRule">
<level>ERROR</level>
<reportOnlyReachable>true</reportOnlyReachable>
<LinkageCheckerRule>
<rules>
linkage-checker-enforcer-rules:1.5.12
The linkage errors involving optional dependencies are not suppressed by the report-only-reachable flag. If you know these linkage errors are false positives, then you can use an exclusion file to suppress them.
Update: I saw the document of the flag mentioning optional dependencies in the example (org.apache.log.output.jms.JMSQueueTarget and javax.jms.TextMessage) was confusing. I updated the section by removing the sentence. Optional dependencies usually cause the linkage errors but the report-only-reachable does not suppress them.