kordamp / kordamp-gradle-plugins

A collection of Gradle plugins
https://kordamp.org/kordamp-gradle-plugins/
Apache License 2.0
138 stars 25 forks source link

NPE: Cannot get property 'docs' on null object (in 100% Kotlin project) #498

Closed bitspittle closed 2 years ago

bitspittle commented 2 years ago

Hello! I'm trying to set up kordamp (latest version, 0.47.0) on this project which produces a binary:

https://github.com/varabyte/kobweb/blob/main/cli/kobweb/build.gradle.kts

Note that this is a 100% Kotlin project. I'm not sure if that's supported or not at this time.

All I've done is add a reference to kordamp in the plugins block, which results in the following stacktrace when simply syncing gradle:

Type-safe dependency accessors is an incubating feature.
> Task :buildSrc:compileKotlin UP-TO-DATE
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources UP-TO-DATE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:inspectClassesForKotlinIC UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Task :buildSrc:generateSourceRoots UP-TO-DATE
> Task :buildSrc:assemble UP-TO-DATE
> Task :buildSrc:compileTestKotlin NO-SOURCE
> Task :buildSrc:pluginUnderTestMetadata UP-TO-DATE
> Task :buildSrc:compileTestJava NO-SOURCE
> Task :buildSrc:compileTestGroovy NO-SOURCE
> Task :buildSrc:processTestResources NO-SOURCE
> Task :buildSrc:testClasses UP-TO-DATE
> Task :buildSrc:test SKIPPED
> Task :buildSrc:validatePlugins UP-TO-DATE
> Task :buildSrc:check SKIPPED
> Task :buildSrc:build UP-TO-DATE

> Configure project :cli:kobweb
Kordamp Gradle plugins 0.47.0. Consider becoming a patron at https://www.patreon.com/aalmiray

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':cli:kobweb'.
> Cannot get property 'docs' on null object

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':cli:kobweb'.
    ...
    at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:116)
    at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)
    ... 
Caused by: java.lang.NullPointerException: Cannot get property 'docs' on null object
    at org.kordamp.gradle.plugin.base.plugins.Javadoc$AutoLinks.calculateLocalJavadocLink(Javadoc.groovy:361)
    at org.kordamp.gradle.plugin.base.plugins.Javadoc$AutoLinks.access$2(Javadoc.groovy)
    at org.kordamp.gradle.plugin.base.plugins.Javadoc$AutoLinks$_resolveLinks_closure1.doCall(Javadoc.groovy:287)
    ...
    at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:116)
    at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)
    ...
aalmiray commented 2 years ago

Did you apply the java-project or kotlin-project at the root of the build?

bitspittle commented 2 years ago

Ah, I was just java-project -- I copied code from https://jreleaser.org/guide/latest/quick-start/gradle.html and didn't even notice the ID I was using.

That said, I just tried again using kotlin-project and I'm still seeing the same error.

To repro:

$ git clone https://github.com/varabyte/kobweb.git
$ cd kobweb/cli/kobweb
$ vim build.gradle.kts
# or whatever your favorite editor is, and add the "id" line below:

---
plugins {
   ...
   id("org.kordamp.gradle.kotlin-project") version "0.45.0"
}
...
---

$ ../../gradlew tasks

When I do this, I see

$ ../../gradlew tasks
Running /home/d9n/Code/scratch/kobweb/gradlew tasks...                                                                                                    
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details                                                                  
Type-safe dependency accessors is an incubating feature.                                                                                                  

> Task :buildSrc:compileKotlin                                                                                                                            
'compileJava' task (current target is 16) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version
.                                                                                                                                                         

> Configure project :cli:kobweb                                                                                                                           
Kordamp Gradle plugins 0.45.0. Consider becoming a patron at https://www.patreon.com/aalmiray                                                             

FAILURE: Build failed with an exception.                                                                                                                  

* What went wrong:                                                                                                                                        
A problem occurred configuring project ':cli:kobweb'.                                                                                                     
> Cannot get property 'docs' on null object                                                                                                               

* 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 49s           
7 actionable tasks: 7 executed
bitspittle commented 2 years ago

Did you apply the java-project or kotlin-project at the root of the build?

Ah I just noticed you asked about the "root" -- does that mean I'm supposed to apply kordamp at the root build.gradle.kts only? And the issue is that I'm only applying it to a subproject?

aalmiray commented 2 years ago

Correct. Most kordamp plugins should be applied at the root level. If this is too much for you know that you may still use JReleaser's gradle plugin without having to use the kordamp plugins.

bitspittle commented 2 years ago

That sounds fair. Looking over the docs again I see that it does indeed mention setting this on the root. I'm going to close this bug as a user error then.

Thanks for your help!