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

[master] Fix the mixing up of target module when the tool id is repeated #42548

Merged
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class RunBuildToolsTask implements Task {
private final boolean exitWhenFinish;
private ClassLoader toolClassLoader = this.getClass().getClassLoader();
ServiceLoader<CodeGeneratorTool> toolServiceLoader = ServiceLoader.load(CodeGeneratorTool.class, toolClassLoader);
private final Map<String, ToolContext> toolContextMap = new HashMap<>();
private final Map<Tool.Field, ToolContext> toolContextMap = new HashMap<>();

public RunBuildToolsTask(PrintStream out) {
this.outStream = out;
Expand Down Expand Up @@ -117,7 +117,7 @@ public void execute(Project project) {
for (Tool toolEntry : toolEntries) {
// Populate tool context
ToolContext toolContext = ToolContext.from(toolEntry, project.currentPackage(), outStream);
toolContextMap.put(toolEntry.id().value(), toolContext);
toolContextMap.put(toolEntry.id(), toolContext);
}
BuildToolResolution buildToolResolution;
try {
Expand Down Expand Up @@ -147,7 +147,7 @@ public void execute(Project project) {
.toList();
for (Tool toolEntry : resolvedToolEntries) {
String commandName = toolEntry.type().value();
ToolContext toolContext = toolContextMap.get(toolEntry.id().value());
ToolContext toolContext = toolContextMap.get(toolEntry.id());
Optional<CodeGeneratorTool> targetTool = BuildToolUtils.getTargetTool(commandName, toolServiceLoader);
if (targetTool.isEmpty()) {
// If the tool is not found, we skip the execution and report a diagnostic
Expand Down Expand Up @@ -248,7 +248,7 @@ private boolean validateEmptyOptionsToml(String toolId, Tool.Field toolType) thr
return true;
}
this.outStream.printf("WARNING: Validation of tool options of '%s' for '%s' is skipped due to " +
"no tool options found%n", toolType, toolId);
"no tool options found%n", toolType.value(), toolId);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public List<BuildTool> getResolvedTools() {

private void resolveToolDependencies() {
Project currentProject = packageContext.project();
Map<String, ToolContext> toolContextMap = currentProject.getToolContextMap();
Map<PackageManifest.Tool.Field, ToolContext> toolContextMap = currentProject.getToolContextMap();
if (toolContextMap == null || toolContextMap.isEmpty()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class Project {
private BuildOptions buildOptions;
protected ProjectEnvironment projectEnvironment;
private final ProjectKind projectKind;
private Map<String, ToolContext> toolContextMap;
private Map<PackageManifest.Tool.Field, ToolContext> toolContextMap;
private List<CompilerPluginContextIml> compilerPluginContexts;

protected Project(ProjectKind projectKind,
Expand Down Expand Up @@ -106,15 +106,15 @@ public BuildOptions buildOptions() {
*
* @return map of {@code ToolContext}
*/
public Map<String, ToolContext> getToolContextMap() {
public Map<PackageManifest.Tool.Field, ToolContext> getToolContextMap() {
return toolContextMap;
}

/**
* Assigns a map of build tools.
* @param toolContextMap map of {@code ToolContext}
*/
public void setToolContextMap(Map<String, ToolContext> toolContextMap) {
public void setToolContextMap(Map<PackageManifest.Tool.Field, ToolContext> toolContextMap) {
this.toolContextMap = toolContextMap;
}

Expand Down
Loading