saveourtool / diktat

Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
https://diktat.saveourtool.com
MIT License
524 stars 39 forks source link

Cannot invoke "java.io.File.toPath()" because the return value of "org.apache.maven.project.MavenProject.getBasedir()" is null #1893

Closed jottinger closed 6 months ago

jottinger commented 9 months ago

Describe the bug

Installed diktat 2.0 into a multimodule maven project as per the github page. Copied the diktat plugin settings from the multimodule example and changed the version to be 2.0.0 explicitly.

Expected behavior

mvn diktat:check runs and generates data about the project.

Observed behavior

Plugin fails with Cannot invoke "java.io.File.toPath()" because the return value of "org.apache.maven.project.MavenProject.getBasedir()" is null

Steps to Reproduce

I have a multimodule project with kotlin already configured. I went to the top-level project (the parent) and installed diktat, and ran mvn diktat:check - and got the error described above.

I did nothing but install diktat and run mvn diktat:check.

Environment information

orchestr7 commented 9 months ago

@jottinger hey once again! Have you tried to run it with the same layout as we have in examples? I am checking our multi-module example and everything works well...

May be you did not add diktat-analysis.yml configuration or aware of some huge differences between example and your project layout? This will help us a lot :)

jottinger commented 9 months ago

I added a diktat-analysis.yml to the project, yes, although the "see how we do it here" didn't point that out clearly. (Always assume your users are idiots!) I have four modules; all follow the same conventions for kotlin; all mirror pretty tightly (as far as I can see) the multi-module example you have.

jottinger commented 9 months ago

I THOUGHT it might have been because one of the projects has no actual kotlin to check - src/main/kotlin and src/test/kotlin exist, but were empty (it's a placeholder project for transitive dependencies). So I added files in those trees just to give it something to look for; same problem, and it doesn't really seem related to the error anyway.