diktat icon indicating copy to clipboard operation
diktat copied to clipboard

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

Open jottinger opened this issue 1 year ago • 3 comments

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

  • diktat version: 2.0
  • build tool (maven/gradle): maven 3.9.6
  • how is diktat run (CLI, plugin, etc.): cli, mvnw; also, IDEA (using the maven wrapper, so 3.9.6)
  • kotlin version: 1.9.21
  • operating system: MacOS
  • link to a project (if your project is public): I'm sorry, it's not public.

jottinger avatar Dec 22 '23 19:12 jottinger

@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 :)

orchestr7 avatar Dec 22 '23 20:12 orchestr7

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 avatar Dec 23 '23 13:12 jottinger

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.

jottinger avatar Dec 23 '23 13:12 jottinger