Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 779fade

Browse files
xuansontrinhSpace Team
authored andcommitted
[breaking change] set the default value targets to empty list (no build/sync anything if not explicitly specified). | #BAZEL-552 Done
Merge-request: BAZEL-MR-425 Merged-by: Xuan Son Trinh <[email protected]>
1 parent 42d4cd0 commit 779fade

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Debugger address (`debugger_address`), java path (`java_path`) and flag for trace log (`produce_trace_log`) are *no
1313
longer* fields in project view files! They can be set *only* using installer flags (check [README](install/README.md)).
1414
- Project view `bazel_path` has been renamed to `bazel_binary` (now it's compatible with https://ij.bazel.build/docs/project-views.html#bazel_binary).
15+
- Project view `targets` has its default value changed from all targets (`//...`) to no targets. | [#BAZEL-552](https://youtrack.jetbrains.com/issue/BAZEL-552).
1516

1617
### Features 🎉
1718
- Enhance support for Kotlin by providing Kotlin target's specific info.

e2e/runTest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ echo "Cleaning project directory done!"
3939

4040
echo "Installing BSP... for $TEST_PROJECT_PATH"
4141
cd "$BUILD_WORKSPACE_DIRECTORY" || exit
42-
bazel run //install:install-server -- -d "$BSP_ROOT" -w "$TEST_PROJECT_PATH" || exit
42+
bazel run //install:install-server -- -d "$BSP_ROOT" -w "$TEST_PROJECT_PATH" -t //... || exit
4343
echo "Installing done."
4444
echo "Environment has been prepared!"
4545
echo -e "-----------------------------------\n"

executioncontext/projectview/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ targets:
5959

6060
##### default:
6161

62-
All targets are included:
62+
No target is included:
6363

6464
```
6565
targets:
66-
//...
6766
```
6867

6968
---

executioncontext/workspacecontext/src/main/java/org/jetbrains/bsp/bazel/workspacecontext/TargetsSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ data class TargetsSpec(
1717
) : ExecutionContextExcludableListEntity<BuildTargetIdentifier>()
1818

1919
private val defaultTargetsSpec = TargetsSpec(
20-
values = listOf(BuildTargetIdentifier("//...")),
20+
values = emptyList(),
2121
excludedValues = emptyList(),
2222
)
2323

executioncontext/workspacecontext/src/test/java/org/jetbrains/bsp/bazel/workspacecontext/TargetsSpecMapperTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TargetsSpecMapperTest {
3333
targetsSpecTry.isSuccess shouldBe true
3434
val targetsSpec = targetsSpecTry.get()
3535

36-
val expectedTargetsSpec = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList())
36+
val expectedTargetsSpec = TargetsSpec(emptyList(), emptyList())
3737
targetsSpec shouldBe expectedTargetsSpec
3838
}
3939

@@ -54,7 +54,7 @@ class TargetsSpecMapperTest {
5454
targetsSpecTry.isSuccess shouldBe true
5555
val targetsSpec = targetsSpecTry.get()
5656

57-
val expectedTargetsSpec = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList())
57+
val expectedTargetsSpec = TargetsSpec(emptyList(), emptyList())
5858
targetsSpec shouldBe expectedTargetsSpec
5959
}
6060

@@ -138,7 +138,7 @@ class TargetsSpecMapperTest {
138138
targetsSpecTry.isSuccess shouldBe true
139139
val targetsSpec = targetsSpecTry.get()
140140

141-
val expectedTargetsSpec = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList())
141+
val expectedTargetsSpec = TargetsSpec(emptyList(), emptyList())
142142
targetsSpec shouldBe expectedTargetsSpec
143143
}
144144

@@ -160,7 +160,7 @@ class TargetsSpecMapperTest {
160160
targetsSpecTry.isSuccess shouldBe true
161161
val targetsSpec = targetsSpecTry.get()
162162

163-
val expectedTargetsSpec = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList())
163+
val expectedTargetsSpec = TargetsSpec(emptyList(), emptyList())
164164
targetsSpec shouldBe expectedTargetsSpec
165165
}
166166

@@ -247,7 +247,7 @@ class TargetsSpecMapperTest {
247247
targetsSpecTry.isSuccess shouldBe true
248248
val targetsSpec = targetsSpecTry.get()
249249

250-
val expectedTargetsSpec = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList())
250+
val expectedTargetsSpec = TargetsSpec(emptyList(), emptyList())
251251
targetsSpec shouldBe expectedTargetsSpec
252252
}
253253

@@ -273,7 +273,7 @@ class TargetsSpecMapperTest {
273273
targetsSpecTry.isSuccess shouldBe true
274274
val targetsSpec = targetsSpecTry.get()
275275

276-
val expectedTargetsSpec = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList())
276+
val expectedTargetsSpec = TargetsSpec(emptyList(), emptyList())
277277
targetsSpec shouldBe expectedTargetsSpec
278278
}
279279

@@ -470,7 +470,7 @@ class TargetsSpecMapperTest {
470470
targetsSpecTry.isSuccess shouldBe true
471471
val targetsSpec = targetsSpecTry.get()
472472

473-
val expectedTargetsSpec = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList())
473+
val expectedTargetsSpec = TargetsSpec(emptyList(), emptyList())
474474
targetsSpec shouldBe expectedTargetsSpec
475475
}
476476
}

executioncontext/workspacecontext/src/test/java/org/jetbrains/bsp/bazel/workspacecontext/WorkspaceContextConstructorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class WorkspaceContextConstructorTest {
120120
val workspaceContext = workspaceContextTry.get()
121121

122122
val expectedWorkspaceContext = WorkspaceContext(
123-
targets = TargetsSpec(listOf(BuildTargetIdentifier("//...")), emptyList()),
123+
targets = TargetsSpec(emptyList(), emptyList()),
124124
buildFlags = BuildFlagsSpec(emptyList()),
125125
// TODO - for now we don't have a framework to change classpath, i'll fix it later
126126
bazelBinary = BazelBinarySpecMapper.default().get(),

server/src/main/java/org/jetbrains/bsp/bazel/server/bsp/managers/BazelBspAspectsManager.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package org.jetbrains.bsp.bazel.server.bsp.managers;
22

33
import io.vavr.collection.Array;
4+
5+
import java.util.HashMap;
6+
import java.util.HashSet;
47
import java.util.List;
58
import java.util.Objects;
69
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
@@ -27,8 +30,10 @@ public BepOutput fetchFilesFromOutputGroups(
2730
TargetsSpec targetSpecs,
2831
String aspect,
2932
List<String> outputGroups) {
30-
var result =
31-
bazelBspCompilationManager.buildTargetsWithBep(
33+
if (targetSpecs.getValues().isEmpty()) return new BepOutput(new HashMap<>(), new HashMap<>(), new HashSet<>());
34+
return
35+
bazelBspCompilationManager
36+
.buildTargetsWithBep(
3237
cancelChecker,
3338
targetSpecs,
3439
Array.of(
@@ -41,7 +46,8 @@ public BepOutput fetchFilesFromOutputGroups(
4146
BazelFlag.buildManualTests(),
4247
BazelFlag.curses(false)
4348
),
44-
null);
45-
return result.bepOutput();
49+
null
50+
)
51+
.bepOutput();
4652
}
4753
}

0 commit comments

Comments
 (0)