Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentschoelens committed Sep 11, 2023
1 parent a296ae1 commit 8ac83c7
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ private void executeGoal(PluginExec pluginExec, String goal, Map<String, String>
version(pluginExec.plugin.getVersion()),
pluginExec.plugin.getDependencies()),
goal(goal),
getPluginConfig(pluginExec.plugin, goal, params),
getPluginConfig(pluginExec.plugin, pluginExec.getExecutionId(), goal, params),
executionEnvironment(
project,
session,
Expand All @@ -720,11 +720,13 @@ private boolean isGoalConfigured(Plugin plugin, String goal) {
return false;
}

private Xpp3Dom getPluginConfig(Plugin plugin, String goal, Map<String, String> params) throws MojoExecutionException {
private Xpp3Dom getPluginConfig(Plugin plugin, String executionId, String goal, Map<String, String> params)
throws MojoExecutionException {
Xpp3Dom mergedConfig = null;
if (!plugin.getExecutions().isEmpty()) {
for (PluginExecution exec : plugin.getExecutions()) {
if (exec.getConfiguration() != null && exec.getGoals().contains(goal)) {
if (exec.getConfiguration() != null && exec.getGoals().contains(goal)
&& matchesExecution(executionId, exec.getId())) {
mergedConfig = mergedConfig == null ? (Xpp3Dom) exec.getConfiguration()
: Xpp3Dom.mergeXpp3Dom(mergedConfig, (Xpp3Dom) exec.getConfiguration(), true);
}
Expand Down Expand Up @@ -762,6 +764,27 @@ private Xpp3Dom getPluginConfig(Plugin plugin, String goal, Map<String, String>
return configuration;
}

/**
* Check if the <code>currentExecutionId</code> matches the provided <code>executionId</code>.
* <p>
* This method will return <code>true</code> if
* <ul>
* <li>current execution id is undefined</li>
* <li>execution id is undefined</li>
* <li>both equals (ignoring case)</li>
* </ul>
*
* @param currentExecutionId current execution id (if defined)
* @param executionId execution id to test matching (if defined)
* @return <code>true</code> if executions ids do match.
*/
private static boolean matchesExecution(String currentExecutionId, String executionId) {
if (currentExecutionId == null) {
return true;
}
return executionId == null || currentExecutionId.equalsIgnoreCase(executionId);
}

private MojoDescriptor getMojoDescriptor(Plugin plugin, String goal) throws MojoExecutionException {
try {
return pluginManager.getMojoDescriptor(plugin, goal, pluginRepos, repoSession);
Expand Down

0 comments on commit 8ac83c7

Please sign in to comment.