fix: bazel http_archive: added support for case where there's a single url
@@ -16,6 +16,9 @@ public class Pipelines {
private static final String CQUERY_COMMAND = "cquery";
private static final String OUTPUT_FLAG = "--output";
private final EnumMap<WorkspaceRule, Pipeline> availablePipelines = new EnumMap<>(WorkspaceRule.class);
+ private static final String HTTP_ARCHIVE_XPATH_TO_URL_LIST = "/query/rule[@class='http_archive']/list[@name='urls']/string";
+ private static final String HTTP_ARCHIVE_XPATH_TO_SINGLE_URL = "/query/rule[@class='http_archive']/string[@name='url']";
+ private static final String HTTP_ARCHIVE_XPATH_EVERY_URL = HTTP_ARCHIVE_XPATH_TO_URL_LIST + "|" + HTTP_ARCHIVE_XPATH_TO_SINGLE_URL;
public Pipelines(
BazelCommandExecutor bazelCommandExecutor,
@@ -73,10 +76,11 @@ public class Pipelines {
.parseFilterLines("^@.*//.*$")
.parseReplaceInEachLine("^@", "")
.parseReplaceInEachLine("//.*", "")
+ // TODO dedup here
.parseReplaceInEachLine("^", "//external:")
.executeBazelOnEachLine(Arrays.asList(QUERY_COMMAND, "kind(.*, ${input.item})", OUTPUT_FLAG, "xml"), true)
// Puts all URLs from the urls list into the stream for the next step
- .parseValuesFromXml("/query/rule[@class='http_archive']/list[@name='urls']/string", "value")
+ .parseValuesFromXml(HTTP_ARCHIVE_XPATH_EVERY_URL, "value")
.transformGithubUrl()
.build();
availablePipelines.put(WorkspaceRule.HTTP_ARCHIVE, httpArchiveGithubUrlPipeline);
