scapegoat
scapegoat copied to clipboard
IntelliJ build fails with java.lang.NoClassDefFoundError: scala/xml/NamespaceBinding
I had to modify the Maven integration steps from the README. I'd added the compilerPlugin under the org.scala-tools maven-scala-plugin, 2.15.2. This works fine from Maven compile commands, but fails IntelliJ Builds.
Error:scalac: Error: scala/xml/NamespaceBinding java.lang.NoClassDefFoundError: scala/xml/NamespaceBinding at com.sksamuel.scapegoat.io.IOUtils$.writeHTMLReport(IOUtils.scala:24)
This seems to be the issue Martin Ford described 23 Feb 2015 (resolved "Won't Fix") and in this other Jetbrains issue. The former's workaround escapes me. The latter's is … self-defeating.
I would assume ideally I'd tell the build's VM to use the scala-xml.jar located within my .IdeaIC2018.2\config\plugins\Scala\lib, checked-in to git for others no matter where there vintage of IntelliJ actually puts the scala plugins.
Could the missing step be added to the README?
Cross-reference (for easier discoverability): this is related to #98.
Another workaround: if you don't actually need / want XML reports, pass the -P:scapegoat:reports:none compiler flag to disable all report generation. This seems to bypass the parts of the code which use Scala XML.
See https://github.com/sksamuel/scapegoat/blob/c7e566629b001e87fc1354f6c194d494d30c1b7f/src/main/scala/com/sksamuel/scapegoat/plugin.scala#L43
Another workaround to get both the reports and still compile in Intellij is to use a dynamic property for Maven.
Add a property to pom.xml
<scapegoat.report>none</scapegoat.report>
Use the property in the scapegoat arg
<configuration>
<args>
<arg>-P:scapegoat:reports:${scapegoat.report}</arg>
</args>
</configuration>
Generate reports via Maven using
-Dscapegoat.report=html clean install
^ The above workaround seems to work with scala-maven-plugin v3.0.2, but doesn't work with v4.0.2.