Skip to content
Open
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 @@ -75,17 +75,19 @@ public static String getQueryString(ImportRoots directories, boolean allowManual
}
}

String query = String.format("attr('tags', '^((?!no-ide).)*$', %s)", targets);

if (allowManualTargetsSync) {
return targets.toString();
return query;
}

// exclude 'manual' targets, which shouldn't be built when expanding wildcard target patterns
if (SystemInfo.isWindows) {
// TODO(b/201974254): Windows support for Bazel sync (see
// https://github.com/bazelbuild/intellij/issues/113).
return String.format("attr('tags', '^((?!manual).)*$', %s)", targets);
return String.format("attr('tags', '^((?!manual).)*$', %s)", query);
}
return String.format("attr(\"tags\", \"^((?!manual).)*$\", %s)", targets);
return String.format("attr(\"tags\", \"^((?!manual).)*$\", %s)", query);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,9 @@ private static String queryString(List<TargetExpression> targets, boolean exclud
if (targetList.isEmpty()) {
return targetList;
}
String query = String.format("attr('tags', '^((?!no-ide).)*$', %s)", targetList);
return excludeManualTargets
? String.format("attr('tags', '%s', %s)", MANUAL_EXCLUDE_TAG, targetList)
: targetList;
? String.format("attr('tags', '%s', %s)", MANUAL_EXCLUDE_TAG, query)
: query;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have an integration test for this, or at least an example project.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public void test() {
true,
workspacePathResolver);

String expQueryString = String.format(
"attr('tags', '^((?!no-ide).)*$', %s - %s)",
TargetExpression.allFromPackageRecursive(included),
TargetExpression.allFromPackageRecursive(excluded));

assertThat(queryString).isEqualTo(TargetExpression.allFromPackageRecursive(included) + " - " + TargetExpression.allFromPackageRecursive(excluded));
assertThat(queryString).isEqualTo(expQueryString);
}
}