Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(diktat-maven-plugin): Maven projects with non local parent POM #1924

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

agebhar1
Copy link
Contributor

In 1 support for mulimodule Maven projects are introduced. But fails for Maven projects with non local parent POM like Spring Boot projects:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  …
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.2.4</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
  …
</project>

Invoke mvn diktat:{check|fix} fails with:

[ERROR] Failed to execute goal com.saveourtool.diktat:diktat-maven-plugin:2.0.0:fix (default-cli) on project …: Execution default-cli of goal com.saveourtool.diktat:diktat-maven-plugin:2.0.0:fix failed: Cannot invoke "java.io.File.toPath()" because the return value of "org.apache.maven.project.MavenProject.getBasedir()" is null -> [Help 1]

Fixes #1893.

In [1] support for mulimodule Maven projects are introduced. But fails for
Maven projects with non local parent POM like Spring Boot projects:

```
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  …
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.2.4</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
  …
</project>
```

Invoke `mvn diktat:{check|fix}` fails with:
```
[ERROR] Failed to execute goal com.saveourtool.diktat:diktat-maven-plugin:2.0.0:fix (default-cli) on project …: Execution default-cli of goal com.saveourtool.diktat:diktat-maven-plugin:2.0.0:fix failed: Cannot invoke "java.io.File.toPath()" because the return value of "org.apache.maven.project.MavenProject.getBasedir()" is null -> [Help 1]
```

Fixes saveourtool#1893.

[1]: saveourtool@3c572f1
Copy link

codecov bot commented Mar 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 76.62%. Comparing base (8d61ddf) to head (9ebfbac).

Files Patch % Lines
.../saveourtool/diktat/plugin/maven/DiktatBaseMojo.kt 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1924      +/-   ##
============================================
- Coverage     76.67%   76.62%   -0.05%     
  Complexity     2492     2492              
============================================
  Files           134      134              
  Lines          7914     7919       +5     
  Branches       2240     2240              
============================================
  Hits           6068     6068              
- Misses          841      846       +5     
  Partials       1005     1005              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@orchestr7 orchestr7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you! @nulls pls review also

@orchestr7
Copy link
Member

I also think we need to make the release with this change

@agebhar1
Copy link
Contributor Author

Awesome, thank you! @nulls pls review also

With pleasure!

@nulls nulls merged commit 56d1632 into saveourtool:master Mar 25, 2024
14 of 15 checks passed
@nulls nulls added bug Something isn't working plugins Plugins for build systems to allow them to run diktat labels Mar 25, 2024
@agebhar1 agebhar1 deleted the feature/gh-1893 branch March 25, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugins Plugins for build systems to allow them to run diktat
Projects
None yet
3 participants