Skip to content

Commit

Permalink
Handle NullPointerException error when surefire not explicitly declar…
Browse files Browse the repository at this point in the history
…ed in pom.xml & Use surefire fallback version 3.0.0-M5
  • Loading branch information
ShawnLi-25 committed Dec 5, 2020
1 parent b1c09a6 commit 96c622b
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
this.surefire = this.lookupPlugin("org.apache.maven.plugins:maven-surefire-plugin");

if (this.surefire == null) {
Logger.getGlobal().log(Level.SEVERE, "Make sure surefire is in your pom.xml");
Logger.getGlobal().log(Level.SEVERE, "Surefire is not explicitly declared in your pom.xml;"
+ " we will use version 3.0.0-M5, but you may want to change that.");
this.surefire = getSureFirePlugin();
}

Properties localProperties = this.mavenProject.getProperties();
Expand All @@ -199,4 +201,12 @@ private Plugin lookupPlugin(String paramString) {
}
return null;
}

private Plugin getSureFirePlugin() {
Plugin surefire = new Plugin();
surefire.setGroupId("org.apache.maven.plugins");
surefire.setArtifactId("maven-surefire-plugin");
surefire.setVersion("3.0.0-M5");
return surefire;
}
}

0 comments on commit 96c622b

Please sign in to comment.