Search in sources :

Example 6 with WildcardTargetPattern

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

the class WildcardTargetPatternTest method testRecursiveWildcardPattern.

@Test
public void testRecursiveWildcardPattern() {
    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()).isTrue();
}
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 7 with WildcardTargetPattern

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

the class WildcardTargetPatternTest method testNonWildcardImplicitTargetName.

@Test
public void testNonWildcardImplicitTargetName() {
    TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/foo");
    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 8 with WildcardTargetPattern

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

the class WildcardTargetPatternTest method testNonRecursiveWildcardPattern.

@Test
public void testNonRecursiveWildcardPattern() {
    TargetExpression target = TargetExpression.fromStringSafe("//java/com/google:all");
    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()).isTrue();
}
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 9 with WildcardTargetPattern

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

the class WildcardTargetPatternTest method testRecursiveWildcardPatternAlternativeFormat.

@Test
public void testRecursiveWildcardPatternAlternativeFormat() {
    TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/...:all");
    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()).isTrue();
}
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 10 with WildcardTargetPattern

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

the class BlazeBuildTargetSharder method expandAndShardTargets.

/**
 * Expand wildcard target patterns and partition the resulting target list.
 */
public static ShardedTargetsResult expandAndShardTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspacePathResolver pathResolver, List<TargetExpression> targets) {
    if (!shardingEnabled(projectViewSet)) {
        return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of(targets)), BuildResult.SUCCESS);
    }
    List<WildcardTargetPattern> wildcardIncludes = getWildcardPatterns(targets);
    if (wildcardIncludes.isEmpty()) {
        return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of(targets)), BuildResult.SUCCESS);
    }
    ExpandedTargetsResult expandedTargets = expandWildcardTargets(project, context, workspaceRoot, projectViewSet, pathResolver, targets);
    if (expandedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
        return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of()), expandedTargets.buildResult);
    }
    return new ShardedTargetsResult(shardTargets(expandedTargets.singleTargets, getTargetShardSize(projectViewSet)), expandedTargets.buildResult);
}
Also used : WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) ExpandedTargetsResult(com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult)

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