TNG / ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
http://archunit.org
Apache License 2.0
3.26k stars 299 forks source link

Build fails (Task :archunit:javadoc) #305

Closed kamer closed 4 years ago

kamer commented 4 years ago

Hello! I have cloned the project to contribute and tried to build following the Contributing Guide. But it fails as below. It's the first time I'm using Gradle so I couldn't do anything aside from Googling it and changing Java versions.

javadoc: error - An exception occurred while building a component: TagInfo
    (java.lang.NullPointerException)
Please file a bug against the javadoc tool via the Java bug reporting page
(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
for duplicates. Include error messages and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
    at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getEnclosingTypeElement(Utils.java:2574)
    at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.CommentHelper.getReferencedClass(CommentHelper.java:371)
    ...
    ... [I removed this part intentionally.]
    ...

1 error

> Task :archunit:javadoc FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':archunit:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/home/kamer/downloads/ArchUnit/archunit/build/tmp/javadoc/javadoc.options'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
34 actionable tasks: 29 executed, 5 up-to-date

Running it with --stacktrace gives some additional info:


> Task :archunit-example:example-plain:compileJava FAILED
/home/kamer/downloads/ArchUnit/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example/plantuml/importer/ProductImport.java:8: error: error while writing ProductImport: /home/kamer/downloads/ArchUnit/archunit-example/example-plain/build/classes/java/main/com/tngtech/archunit/example/plantuml/importer/ProductImport.class
public class ProductImport {
       ^
1 error

> Task :archunit:compileJava FAILED
/home/kamer/downloads/ArchUnit/archunit/src/main/java/com/tngtech/archunit/base/ReflectionUtils.java:23: error: error while writing ReflectionUtils: /home/kamer/downloads/ArchUnit/archunit/build/classes/java/main/com/tngtech/archunit/base/ReflectionUtils.class
public class ReflectionUtils {
       ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
`
hankem commented 4 years ago

First of all, thanks for your interest to contribute to ArchUnit! 😃

Issues

JDK 9 / 10

I can confirm the issues with Java 9 and 10, but note the following message:

Please file a bug against the javadoc tool via the Java bug reporting page

So this is indeed a JDK issue – which has been fixed in newer versions, but I guess that this fix won't be backported to JDK 9 or 10.

JDK 13

Regarding the issues with JDK 13: With openjdk-13.0.2, I'm also getting (tons of errors like)

> Task :archunit:spotbugsMain
The following errors occurred during analysis:
  Error scanning java/lang/Object for referenced classes
    java.lang.IllegalArgumentException: Unsupported class file major version 57
      At org.objectweb.asm.ClassReader.<init>(ClassReader.java:176)
      At org.objectweb.asm.ClassReader.<init>(ClassReader.java:158)
      At org.objectweb.asm.ClassReader.<init>(ClassReader.java:146)
      At edu.umd.cs.findbugs.asm.FBClassReader.<init>(FBClassReader.java:35)
      At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:48)
      At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:34)
      At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)
      At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:75)
      At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)
      At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)
      At edu.umd.cs.findbugs.FindBugs2.buildReferencedClassSet(FindBugs2.java:774)
      At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:220)
      At com.github.spotbugs.internal.spotbugs.SpotBugsExecuter.runSpotbugs(SpotBugsExecuter.java:23)

I believe that we need to update spotbugs in order to support building ArchUnit with JDK ≥13 (the same was needed to support JDK 11 with #119), and that this, in turn, requires the gradle update of #192.

Workaround

So for the time being, you could either

kamer commented 4 years ago

@hankem Thank you for detailed answer. It works fine with JDK11.

hankem commented 4 years ago

It turns out that #306 (Gradle 5.6.4) is not enough to use JDK 13, but that Gradle 6 is required (cf. gradle/gradle#10785).

codecholeric commented 4 years ago

Yes, I've noticed that, too. Our path should be to merge #284, then see how we get to Gradle 6 as quickly as possible. Unfortunately we have accumulated some technical dept with respect to the build :frowning_face: