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

Fixes aggregation of configurations with two different executions ids #35846

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading