Skip to content

Commit

Permalink
Avoid very unlikely NPE
Browse files Browse the repository at this point in the history
I was able to reproduce the NPE initially
when adding the test for
#10421.
The way I got around it in that test was to
make sure the compile phase was invoked
  • Loading branch information
geoand committed Jul 3, 2020
1 parent 037850f commit 5fea82b
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,21 +407,25 @@ private void triggerCompile() throws MojoExecutionException {
*/
private void handleResources() throws MojoExecutionException {
List<Resource> resources = project.getResources();
if (!resources.isEmpty()) {
Plugin resourcesPlugin = project.getPlugin(ORG_APACHE_MAVEN_PLUGINS + ":" + MAVEN_RESOURCES_PLUGIN);
MojoExecutor.executeMojo(
MojoExecutor.plugin(
MojoExecutor.groupId(ORG_APACHE_MAVEN_PLUGINS),
MojoExecutor.artifactId(MAVEN_RESOURCES_PLUGIN),
MojoExecutor.version(resourcesPlugin.getVersion()),
resourcesPlugin.getDependencies()),
MojoExecutor.goal("resources"),
getPluginConfig(resourcesPlugin),
MojoExecutor.executionEnvironment(
project,
session,
pluginManager));
if (resources.isEmpty()) {
return;
}
Plugin resourcesPlugin = project.getPlugin(ORG_APACHE_MAVEN_PLUGINS + ":" + MAVEN_RESOURCES_PLUGIN);
if (resourcesPlugin == null) {
return;
}
MojoExecutor.executeMojo(
MojoExecutor.plugin(
MojoExecutor.groupId(ORG_APACHE_MAVEN_PLUGINS),
MojoExecutor.artifactId(MAVEN_RESOURCES_PLUGIN),
MojoExecutor.version(resourcesPlugin.getVersion()),
resourcesPlugin.getDependencies()),
MojoExecutor.goal("resources"),
getPluginConfig(resourcesPlugin),
MojoExecutor.executionEnvironment(
project,
session,
pluginManager));
}

private void executeCompileGoal(Plugin plugin, String groupId, String artifactId) throws MojoExecutionException {
Expand Down

0 comments on commit 5fea82b

Please sign in to comment.