Search in sources :

Example 1 with WildcardTargetPattern

use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.

the class WildcardTargetPatternTest method testRecursiveWildcardPatternAllTargets.

@Test
public void testRecursiveWildcardPatternAllTargets() {
    TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/...:all-targets");
    WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
    assertThat(wildcardPattern).isNotNull();
    assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google"))).isTrue();
    assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google/foo"))).isTrue();
    assertThat(wildcardPattern.isRecursive()).isTrue();
    assertThat(wildcardPattern.getBasePackage()).isEqualTo(new WorkspacePath("java/com/google"));
    assertThat(wildcardPattern.rulesOnly()).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Example 2 with WildcardTargetPattern

use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.

the class WildcardTargetPatternTest method testNonRecursiveAllTargetsWildcardPattern.

@Test
public void testNonRecursiveAllTargetsWildcardPattern() {
    TargetExpression target = TargetExpression.fromStringSafe("//java/com/google:*");
    WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
    assertThat(wildcardPattern).isNotNull();
    assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google"))).isTrue();
    assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google/foo"))).isFalse();
    assertThat(wildcardPattern.isRecursive()).isFalse();
    assertThat(wildcardPattern.getBasePackage()).isEqualTo(new WorkspacePath("java/com/google"));
    assertThat(wildcardPattern.rulesOnly()).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Example 3 with WildcardTargetPattern

use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.

the class BlazeBuildTargetSharder method doExpandWildcardTargets.

private static ExpandedTargetsResult doExpandWildcardTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspacePathResolver pathResolver, List<TargetExpression> targets) {
    List<WildcardTargetPattern> includes = getWildcardPatterns(targets);
    if (includes.isEmpty()) {
        return new ExpandedTargetsResult(targets, BuildResult.SUCCESS);
    }
    Map<TargetExpression, List<TargetExpression>> expandedTargets = WildcardTargetExpander.expandToNonRecursiveWildcardTargets(project, context, pathResolver, includes);
    if (expandedTargets == null) {
        return new ExpandedTargetsResult(ImmutableList.of(), BuildResult.FATAL_ERROR);
    }
    // replace original recursive targets with expanded list, retaining relative ordering
    List<TargetExpression> fullList = new ArrayList<>();
    for (TargetExpression target : targets) {
        List<TargetExpression> expanded = expandedTargets.get(target);
        if (expanded == null) {
            fullList.add(target);
        } else {
            fullList.addAll(expanded);
        }
    }
    return WildcardTargetExpander.expandToSingleTargets(project, context, workspaceRoot, projectViewSet, fullList);
}
Also used : WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) ArrayList(java.util.ArrayList) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ExpandedTargetsResult(com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult)

Example 4 with WildcardTargetPattern

use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.

the class WildcardTargetPatternTest method testNonWildcardPattern.

@Test
public void testNonWildcardPattern() {
    TargetExpression target = TargetExpression.fromStringSafe("//java/com/google:single_target");
    WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
    assertThat(wildcardPattern).isNull();
}
Also used : WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Example 5 with WildcardTargetPattern

use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.

the class WildcardTargetPatternTest method testRecursiveWildcardPatternAllTargetsAlternativeFormat.

@Test
public void testRecursiveWildcardPatternAllTargetsAlternativeFormat() {
    TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/...:*");
    WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
    assertThat(wildcardPattern).isNotNull();
    assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google"))).isTrue();
    assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google/foo"))).isTrue();
    assertThat(wildcardPattern.isRecursive()).isTrue();
    assertThat(wildcardPattern.getBasePackage()).isEqualTo(new WorkspacePath("java/com/google"));
    assertThat(wildcardPattern.rulesOnly()).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Aggregations

WildcardTargetPattern (com.google.idea.blaze.base.model.primitives.WildcardTargetPattern)12 TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)10 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)8 Test (org.junit.Test)8 ExpandedTargetsResult (com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 FutureUtil (com.google.idea.blaze.base.async.FutureUtil)1 FutureResult (com.google.idea.blaze.base.async.FutureUtil.FutureResult)1 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)1 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)1 FetchExecutor (com.google.idea.blaze.base.prefetch.FetchExecutor)1 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)1