Skip to content

Commit

Permalink
fix: fix null pointer exception in case mojo runs multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
qoomon committed Feb 11, 2023
1 parent 50c2c07 commit 464877a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
[![Maven Central](https://img.shields.io/maven-central/v/me.qoomon/maven-git-versioning-extension.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22me.qoomon%22%20AND%20a%3A%22maven-git-versioning-extension%22)

# Changelog

## 9.6.2

##### Fixes
- fix null pointer exception in case mojo runs multiple times


## 9.6.1

##### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ create or update `${rootProjectDir}/.mvn/extensions.xml` file
<extension>
<groupId>me.qoomon</groupId>
<artifactId>maven-git-versioning-extension</artifactId>
<version>9.6.1</version>
<version>9.6.2</version>
</extension>

</extensions>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>me.qoomon</groupId>
<artifactId>maven-git-versioning-extension</artifactId>
<version>9.6.1</version>
<version>9.6.2</version>
<packaging>maven-plugin</packaging>

<name>Maven Git Versioning Extension</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ public class GitVersioningMojo extends AbstractMojo {

@Override
public synchronized void execute() {
getLog().debug("mojo run");

File gitVersionedPomFile = new File(project.getBasedir(), GitVersioningModelProcessor.GIT_VERSIONING_POM_NAME);
project.setPomFile(gitVersionedPomFile);

getLog().debug("remove version build plugin");
project.getModel().getBuild().getPlugins().remove(asPlugin());
project.getOriginalModel().getBuild().getPlugins().remove(asPlugin());
if(project.getModel().getBuild() != null){
project.getModel().getBuild().getPlugins().remove(asPlugin());
}
if(project.getOriginalModel().getBuild() != null) {
project.getOriginalModel().getBuild().getPlugins().remove(asPlugin());
}
}

static Plugin asPlugin() {
Expand Down

0 comments on commit 464877a

Please sign in to comment.