Skip to content

Commit

Permalink
Merge pull request #42548 from gayaldassanayake/fix-same-id-issue-master
Browse files Browse the repository at this point in the history
[master] Fix the mixing up of target module when the tool id is repeated
  • Loading branch information
azinneera authored Apr 16, 2024
2 parents e76d71b + 00768e5 commit 7024961
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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

0 comments on commit 7024961

Please sign in to comment.