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

[feature] project view 2000 #143

Merged
merged 47 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b6624d1
project view parser major refactor
abrams27 Jan 4, 2022
0f7e558
bazel_path section
abrams27 Jan 13, 2022
852988c
i love java 11
abrams27 Feb 3, 2022
61aa70b
style
abrams27 Feb 3, 2022
ee16b86
buildifier
abrams27 Feb 3, 2022
8a9c8b3
style v2
abrams27 Feb 3, 2022
b533512
debugger_address section
abrams27 Feb 4, 2022
d7aee20
i love java 11 more
abrams27 Feb 4, 2022
e41b98d
debugger_address section part 2
abrams27 Feb 7, 2022
4399fb3
splitter tests update
abrams27 Feb 7, 2022
7267553
splitter test fix
abrams27 Feb 7, 2022
04b1a02
java_path section
abrams27 Feb 7, 2022
bddcfe9
comments
abrams27 Feb 7, 2022
951a15b
project view usages
abrams27 Feb 7, 2022
0409866
scala.md fix
abrams27 Feb 8, 2022
4d39f7a
e2e test resources fix
abrams27 Feb 8, 2022
c1bc876
e2e test resources fix part 2
abrams27 Feb 8, 2022
b7e43ef
[e2e] cleaning environment before installation
abrams27 Feb 8, 2022
f358556
tests update
abrams27 Feb 8, 2022
3adc394
new mechanism usage
abrams27 Feb 8, 2022
c16ddab
fix
abrams27 Feb 8, 2022
37946a2
visibility and toString() impl
abrams27 Feb 8, 2022
c2bba8c
little test change
abrams27 Feb 8, 2022
ae91fee
style
abrams27 Feb 8, 2022
a378c39
another little test fix
abrams27 Feb 8, 2022
5385eed
targets visibility update
abrams27 Feb 9, 2022
db6e49c
i really love tests
abrams27 Feb 9, 2022
930b520
try > java exceptions
abrams27 Feb 9, 2022
563da63
builidier
abrams27 Feb 9, 2022
bc2bb24
visibility update
abrams27 Feb 9, 2022
54047c0
more visibility update
abrams27 Feb 10, 2022
c4180d9
format
abrams27 Feb 10, 2022
d7537f1
java docs
abrams27 Feb 10, 2022
a6561bc
compareByName -> hasName
abrams27 Feb 10, 2022
758b04c
instanceOf -> getInstance
abrams27 Feb 10, 2022
7b48ee9
split -> getRawSectionsForFileContent
abrams27 Feb 10, 2022
c09119d
anoter -> another_
abrams27 Feb 10, 2022
ce73db0
list -> stream
abrams27 Feb 10, 2022
d03410b
commons in ci
abrams27 Feb 10, 2022
736ae2b
getInstance -> createInstance
abrams27 Feb 10, 2022
b8d8f6b
readme update
abrams27 Feb 10, 2022
372e681
format
abrams27 Feb 10, 2022
f343b91
Update CHANGELOG.md
abrams27 Feb 10, 2022
09d9b0b
Update CHANGELOG.md
abrams27 Feb 10, 2022
daca08b
targets validation out
abrams27 Feb 10, 2022
1a4669d
bazel in install update
abrams27 Feb 10, 2022
9990ee3
even more tests
abrams27 Feb 11, 2022
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
25 changes: 18 additions & 7 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,27 @@ on:
branches: [ dev, master ]

jobs:
commons-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Run tests
run: bazel test //commons/...

bazelrunner-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Run tests
run: bazel test //bazelrunner/...
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Run tests
run: bazel test //bazelrunner/...

projectview-test:
runs-on: ubuntu-latest
Expand Down
16 changes: 9 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@
<!-- Keep a Changelog guide -> https://keepachangelog.com -->

## [Unreleased]
### Changed
### Features 🎉
- New, better project view! Now you can configure installer as well! | [#143](https://github.com/JetBrains/bazel-bsp/pull/143)

### Changes 🔄
- Improved heuristics for guessing source roots. It looks directory structures such as `src/java` or `main/java`. | [#126](https://github.com/JetBrains/bazel-bsp/pull/126)

### Fixed
### Fixes 🛠️
- Now the project is built using bazel version `3.7.2`, as the rules currently used are no longer supported by bazel. | [141](https://github.com/JetBrains/bazel-bsp/pull/141)


## [1.0.1] - 24.09.2021
### Added
### Features 🎉
- [This](CHANGELOG.md) changelog. | [#97](https://github.com/JetBrains/bazel-bsp/pull/97)

### Changed
### Changes 🔄
- Implementation of e2e tests. Have been moved to the `e2e` module and are now based on execution scenarios. | [#83](https://github.com/JetBrains/bazel-bsp/pull/83)
- Github actions e2e tests execution - e2e tests are executed in parallel. | [#84](https://github.com/JetBrains/bazel-bsp/pull/84)
- Project structure - now it is multi module project. | [#87](https://github.com/JetBrains/bazel-bsp/pull/87)
- Github actions unit tests execution - each module has a separate job. | [#89](https://github.com/JetBrains/bazel-bsp/pull/89)
- Created [document](docs/BUMPVERSION.md) with release tips. | [#91](https://github.com/JetBrains/bazel-bsp/pull/91)

### Removed
### Removed ✂️
- Old implementation of e2e tests. | [#86](https://github.com/JetBrains/bazel-bsp/pull/86)

### Fixed
### Fixes 🛠️
- Warnings generated by the [WORKSPACE file](WORKSPACE). | [#81](https://github.com/JetBrains/bazel-bsp/pull/81)
- Semantic versioning parser - now it can parse every valid version. | [#93](https://github.com/JetBrains/bazel-bsp/pull/93)
- `exports` attribute propagation to the BSP | [#98](https://github.com/JetBrains/bazel-bsp/pull/98)
- Now all `scala_junit_test` based rules (including `scala_specs2_junit_test`) are included in the BSP tests, unfortunately without test classes. | [#101](https://github.com/JetBrains/bazel-bsp/pull/101)

## [1.0.0] - 23.08.2021
### Added
- Everything...


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ cs launch -r m2Local org.jetbrains.bsp:bazel-bsp:<your version> -M org.jetbrains


## Project Views
In order to work on huge monorepos you might want to specify directories and targets to work on. To address this issue, Bazel BSP supports part of the [Project Views](https://ij.bazel.build/docs/project-views.html) introduced by Google. Currently you can use following rules: `directories`, `targets` and `import`.
In order to work on huge monorepos you might want to specify directories and targets to work on. To address this issue, Bazel BSP supports (partly) the [Project Views](https://ij.bazel.build/docs/project-views.html) introduced by Google.

Simply create a `projectview.bazelproject` file, specify rules inside and run the server. If no such files will be found, by default entire project will be loaded.
Check [project view readme](projectview/README.md) for more info.


## Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ java_library(
deps = [
"@maven//:ch_epfl_scala_bsp4j",
"@maven//:com_google_guava_guava",
"@maven//:io_vavr_vavr",
abrams27 marked this conversation as resolved.
Show resolved Hide resolved
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jetbrains.bsp.bazel.commons;

import com.google.common.io.CharSource;
import com.google.common.io.Files;
import io.vavr.control.Try;
import java.nio.charset.Charset;
import java.nio.file.Path;

public final class BetterFiles {

public static Try<String> tryReadFileContent(Path filePath) {
return Try.success(filePath)
.map(Path::toFile)
.map(file -> Files.asCharSource(file, Charset.defaultCharset()))
.mapTry(CharSource::read);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ public class Constants {

public static final String SCALA_TEST_MAIN_CLASSES_ATTRIBUTE_NAME = "main_class";

public static final String DEFAULT_PROJECT_VIEW_FILE = "projectview.bazelproject";
public static final String PROJECT_VIEW_FILE_PATH = "projectview.bazelproject";
public static final String DEFAULT_PROJECT_VIEW_FILE_PATH =
".bazelbsp/default-projectview.bazelproject";
abrams27 marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 14 additions & 0 deletions commons/src/test/java/org/jetbrains/bsp/bazel/commons/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_java//java:defs.bzl", "java_test")

java_test(
name = "BetterFilesTest",
size = "small",
srcs = ["BetterFilesTest.java"],
runtime_deps = [
"@maven//:junit_junit",
],
deps = [
"//commons/src/main/java/org/jetbrains/bsp/bazel/commons",
"@maven//:io_vavr_vavr",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.jetbrains.bsp.bazel.commons;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Paths;
import org.junit.Test;

public class BetterFilesTest {

@Test
public void shouldReturnFailureForNotExistingFile() {
// given
var filePath = Paths.get("file/doesnt/exist");

// when
var fileContent = BetterFiles.tryReadFileContent(filePath);

// then
assertTrue(fileContent.isFailure());
}

@Test
public void shouldParseExistingFile() throws IOException {
// given
var file = File.createTempFile("test", "file");
file.deleteOnExit();
var filePath = file.toPath();

var fileWriter = new FileWriter(file);

fileWriter.write("test content");
fileWriter.close();

// when
var fileContent = BetterFiles.tryReadFileContent(filePath);

// then
assertTrue(fileContent.isSuccess());
assertEquals("test content", fileContent.get());
}
}
2 changes: 2 additions & 0 deletions docs/BUMPVERSION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Bump Version

If you want to bump version (for example, before a release) you should do this in the following places:

- `central-sync/VERSION`
- `maven_coordinates` in `server/src/main/java/org/jetbrains/bsp/bazel/BUILD`
- `VERSION` in `commons/src/main/java/org/jetbrains/bsp/bazel/commons/Constants.java`
Expand Down
8 changes: 6 additions & 2 deletions docs/kotlin.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# BSP Kotlin
In order to fully have the experience to use BSP over kotlin, make sure that you're using at least version `0da862aaa11db26f6a113dcec5f6828bfd186ac9` of `rules_kotlin`. This will ensure

In order to fully have the experience to use BSP over kotlin, make sure that you're using at least
version `0da862aaa11db26f6a113dcec5f6828bfd186ac9` of `rules_kotlin`. This will ensure
that compilation diagnostics are being delivered to you.

```
rules_kotlin_version = "0da862aaa11db26f6a113dcec5f6828bfd186ac9"
rules_kotlin_sha = "6fda2451b9aaf78a8399e6e5d13c31c8ddc558e87de209a7cfd5ddc777ac7877"
Expand All @@ -15,4 +18,5 @@ kotlin_repositories() # if you want the default
kt_register_toolchains() # to use the default toolchain
```

This changes have not been merged yet and progress can be accompanied [here](https://github.com/bazelbuild/rules_kotlin/pull/359).
This changes have not been merged yet and progress can be
accompanied [here](https://github.com/bazelbuild/rules_kotlin/pull/359).
8 changes: 7 additions & 1 deletion docs/scala.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Toolchain Registration for Scala

In order to fully use Bazel BSP for Scala projects make sure to use at least version
``d8bce245a96ca9ab721324bc8daa984aa13fa0f7`` of `rules_scala`:
`d8bce245a96ca9ab721324bc8daa984aa13fa0f7` of `rules_scala`:

```
http_archive(
name = "io_bazel_rules_scala",
Expand All @@ -13,7 +15,9 @@ bazel_version(name = "bazel_version")
```

Make sure that your registered toolchain has Compilation Diagnostics enabled:

- At a BUILD file:

```
load("@io_bazel_rules_scala//scala:scala_toolchain.bzl", "scala_toolchain")

Expand All @@ -30,7 +34,9 @@ toolchain(
visibility = ["//visibility:public"],
)
```

- At the WORKSPACE file:

```
register_toolchains(
"<label_to_build_file>:diagnostics_reporter_toolchain"
Expand Down
9 changes: 7 additions & 2 deletions e2e/runTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ fi
bsp_path="$(bazel info bazel-bin)/server/src/main/java/org/jetbrains/bsp/bazel/bsp-install"
echo "Building done."

echo "Installing BSP..."
echo "Cleaning project directory..."
if [ "$#" -eq 2 ]; then
cd "$TEST_PROJECT_PATH" || exit
fi
$bsp_path
rm -r .bsp/ > /dev/null 2>&1
abrams27 marked this conversation as resolved.
Show resolved Hide resolved
rm -r .bazelbsp/ > /dev/null 2>&1
echo "Cleaning project directory done!"

echo "Installing BSP..."
$bsp_path || exit
echo "Installing done."
echo "Environment has been prepared!"
echo -e "-----------------------------------\n"
Expand Down
6 changes: 5 additions & 1 deletion install/src/main/java/org/jetbrains/bsp/bazel/install/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ load("@rules_java//java:defs.bzl", "java_library")
java_library(
name = "install",
srcs = glob(["*.java"]),
resources = ["aspects.bzl"],
resources = [
"aspects.bzl",
"default-projectview.bazelproject",
],
visibility = ["//install:__subpackages__"],
deps = [
"//commons",
"//projectview:parser",
"@maven//:ch_epfl_scala_bsp4j",
"@maven//:com_google_code_gson_gson",
"@maven//:com_google_guava_guava",
Expand Down
Loading