Scaladoc (2.11.6) fails on throws tag with “unable

2020-08-11 10:43发布

问题:

When attempting to publish the jars for my project via sbt "++2.11.6 publishLocal" or sbt +publishLocal, I encounter Scaladoc issues when publishing for Scala 2.11.6. It appears that I have invalid links caused by the @throws tag. I am not sure why I have invalid links nor why the error only occurs for Scala 2.11.6 while not for Scala 2.10.5 during my cross-publishing. I can't find any indication that the @throws tag is not supported on Scala 2.11; so, I'm assuming it is an issue with my Scaladoc, but I don't know what I am missing at this point. Can anyone give me some insight into this issue?

  /**
   * Attempts to load the JDI, asserting that it can be and is loaded.
   *
   * @throws AssertionError If failed to load the JDI
   */
  @throws(classOf[AssertionError])
  protected def assertJdiLoaded(): Unit =
    assert(jdiLoader.tryLoadJdi(),
      """
        |Unable to load Java Debugger Interface! This is part of tools.jar
        |provided by OpenJDK/Oracle JDK and is the core of the debugger! Please
        |make sure that JAVA_HOME has been set and that tools.jar is available
        |on the classpath!
      """.stripMargin.replace("\n", " "))

The snippet above (one of the reported problems) is part of the file from my project here: https://github.com/rcsenkbeil/scala-debugger/blob/master/scala-debugger-api/src/main/scala/org/senkbeil/debugger/Debugger.scala#L22

The actual series of Scaladoc compilation errors is as follows:

[info] Loading project definition from /home/senkwich/projects/scala-debugger/project
[info] Set current project to scala-debugger (in build file:/home/senkwich/projects/scala-debugger/)
[info] Setting version to 2.11.6
[info] Reapplying settings...
[info] Set current project to scala-debugger (in build file:/home/senkwich/projects/scala-debugger/)
[info] Wrote /home/senkwich/projects/scala-debugger/scala-debugger-api/target/scala-2.11/scala-debugger-api_2.11-1.0.0.pom
[info] :: delivering :: org.senkbeil#scala-debugger-api_2.11;1.0.0 :: 1.0.0 :: release :: Sat Jul 18 00:59:01 CDT 2015
[info]  delivering ivy file to /home/senkwich/projects/scala-debugger/scala-debugger-api/target/scala-2.11/ivy-1.0.0.xml
[info] Main Scala API documentation to /home/senkwich/projects/scala-debugger/scala-debugger-api/target/scala-2.11/api...
model contains 35 documentable templates
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:170: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:192: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:158: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:138: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:126: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:106: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:94: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/VirtualMachineWrapper.scala:73: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/ValueWrapper.scala:112: Could not find any member to link for "IllegalArgumentException".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/ValueWrapper.scala:87: Could not find any member to link for "IllegalArgumentException".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/ValueWrapper.scala:54: Could not find any member to link for "IllegalArgumentException".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/wrappers/ValueWrapper.scala:33: Could not find any member to link for "Throwable".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/jdi/JDILoader.scala:206: Could not find any member to link for "ClassNotFoundException".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/breakpoints/BreakpointBundle.scala:138: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/breakpoints/BreakpointBundle.scala:156: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/breakpoints/BreakpointBundle.scala:110: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/breakpoints/BreakpointBundle.scala:92: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/breakpoints/BreakpointBundle.scala:72: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] /home/senkwich/projects/scala-debugger/scala-debugger-api/src/main/scala/org/senkbeil/debugger/Debugger.scala:19: Could not find any member to link for "AssertionError".
[error]   /**
[error]   ^
[error] 19 errors found
[error] (scalaDebuggerApi/compile:doc) Scaladoc generation failed
[error] Total time: 17 s, completed Jul 18, 2015 12:59:17 AM

回答1:

Based on discussion here, I have decided to suppress the errors for now by adding the Scaladoc option -no-link-warnings.

scalacOptions in (Compile, doc) ++= Seq(
  "-no-link-warnings" // Suppresses problems with Scaladoc @throws links
)


回答2:

Note that if you don't need scaladoc-s at all, you can make them empty:

sources in (Compile,doc) := Seq.empty

And not publish at all:

publishArtifact in packageDoc := false