Skip to content

Commit

Permalink
[release] 1.0.0-RC1 (#79)
Browse files Browse the repository at this point in the history
* Change project structure (#12)

* [1 - Initial code refactor] basic classes extraction (#13)

* proces lock is a semaphore

* process start methods moved to the new class

* Build.Query moved to class

* targets options moved to the class

* action graph parser moved to the class

* getMnemonics moved to the class

* packages rearrangement

* scala sbt server moved to the class

* java sbt server moved to the class

* buildClientLogger + methods bodies moved uder calls

* brackets in ifs

* rebase

* proper enterprise package structure

* BUILD files in subpackages

* packages without java prefix

* logger todo

* imports are sorted

* Configure CI. (#16)

* Configure CI.

* Change job name.

* Add ls.

* Update java.ci.yml

* Update java.ci.yml

* Update java.ci.yml

* Fix test.sh

* Comment out tests.

* Update java.ci.yml

* Update test.sh

* Revert comment

* Uncomment one test

* Uncomment more tests

* Comment test

* Uniform commenting

* Uncomment one test

* Uncomment one test

* Uncomment one test

* Uncomment one test

* Uncomment one test

* Uncomment one test

* Uncomment one test

* Update BazelBspServerTest.java

* Add master

* Uncomment tests

* Increase time limit of tests

* Increase time limit of tests

* Remove master

* Increase time limit of tests

* Increase time limit of one test

* Decrease total time

* Add master

* Refactor pt 2 (#18)

- Introduced `BazelRunner` class which is fully responsible for starting processes, awaiting them and gathering results
- Moved synchronized `get<BazelData>` methods to `BazelDataResolver`. They are no longer required to be synchronized, as all the required data is fetched in the constructor of `BazelBspServer`
- Removed checked exceptions in many places and the need for try-to-rethrow
- Removed `Either`s in many places where they were no longer needed
- Corrected several minor issues (`setBackendPort` appending to a constant, `convertExitCode` not using enum names)

* Add a CI job for formatting (#20)

Add a CI job for formatting

* Test refactor (#19)

* data moved to the separete class

* runner extraction + additional methods extraction

* workspace field is now in data class + constructor argument removal

* timeouts moved to the data class

* methods refactor

* .test.sh update

* logger

* test logs

* one more log

* minor reformat

* lombok dep removal

* code reformat

* buildifier

* fix

* [configuration] Optional argument on server startup (#15)

* [configuration] Optional argument on server startup

Add a optional parameters when starting a server to specify the target
that should be built.

* BEP Server refactor (#21)

* Separating interface implementations and general dependency structure refactor (#24)

* Extracted ScalaBuildServer implementation

* Extracted JavaBuildServer implementation, both classes now implement proper interfaces

* Extracted BuildServer endpoints, very tentatively (previous problems with it)

* Extracted BuildServer implementation more properly

* Tidied up initialized/finished methods + other smaller

* Extracted several things to ParsingUtils and Constants

* Extracted BazelBspServerLifetime and BazelBspRequestHelpers, Java- and ScalaBuildServer classes now not dependent on BazelBspServer

* Added server config, Bazel runner and Bazel data dependencies to the server implementation

* Adjusted BazelData dependencies

* Extracted ServerBuildManager

* Hotfix of the cyclical dependency, to improve iteratively

* Moved part of the BSP integration in Server to the BazelBspServer constructor

* Added further parts to the constructor integration

* Removed cyclical dependency between BuildManager and BuildServerImpl

* Started removing cyclical dependency between BazelBspServer and BepServer: BazelData passed in the constructor

* Resolved cyclical dependency between BuildManager and BepServer

* Cleaned up in BazelBspServer

* Simplified the constructor, moved away logic

* General cleanup

* Extracted suppliers from interface methods in BuildServerImpl

* Added build server implementations as fields

* Prepared for interface and service separation

* Separated BuildServer logic from interface implementation

* Separated logic from interface implementation for Scala and Java BuildServers

* Extracted BEP package

* Created new packages and grouped the files + small style improvements

* Minor style corrections

* Renamed Server.java, imported io.grpc.Server

* Corrections after review

* Naming and packaging changes

* Formatting fix

* Formatting fix

* bazel runner refactor (#23)

* package update

* BazelRunner logs + minor change

* ExitCodeMapper

* runBazelCommandBes update

* BazelRunnerUpdate v2

* BazelTestRunner

* BazelCleanRunner

* BazelRunRunner

* BazelBuildRunner

* BazelInfoRunner

* BazelActionGraphQueryRunner

* BazelQueryRunner

* renames

* bazel runner builder

* packages update

* QueryResolver update

* code reformat

* buldifier

* targets fix

* format fix

* format fix

* format fix v2

* format fix v3

* format fix v4

* rebase

* review fix

* reformat

* test fix

* query kind param

* reformat

* review fix

* reformat

* packages rename

* runner lists creation update

* refactor

* common -> commons

* resolver -> resolvers

* service -> services

* util -> utils

* Packages rearrange + Utils refactor (#30)

* local services setter update

* .../impl -> .../bsp/impl

* .../services -> .../bsp/services

* ClasspathParser

* StderrDiagnosticsParser

* cleanup

* BazelBspServerTestData rollback

* .../resolvers -> .../bsp/resolvers

* reformat

* ActionGraphParser moved to resolvers

* ParsingUtils update

* reformat

* flag fix

* review fix

* setLocalService rollback

* reviw fix

* getRuleType rollback

* rename

* [Post BazelBuilder refactor part 1] TargetsResolver update (#33)

* BuildClientLogger does NOT throw an exception

* BuildClientLogger moved to bep package

* TargetsUtils now maps targets to uris

* .../resolvers/targets package

* Scala/JavaBuildServerService constructor update

* TargetsResolver constructor update

* TargetsResolver builder

* TargetsResolver refactor

* targets package removal

* reformat

* review fixes

* unused import + targetsResolver constructor visibility

* [Post BazelBuilder refactor part 2] TargetsRuleResolver (#34)

* ActionGraphParser getInputs more optimal implementation

* typo in tests

* TargetsResolver -> TargetsLanguageOptionsResolver

* TargetsRulesResolver

* reformat

* TargetsRulesResolver -> TargetRulesResolver

* Solving problems with Scala- and Java-specific endpoints (#32)

* Added an aggregate build server implementation file for passing to the launcher

* Renamed the hub class

* Moved the hub class to server/bsp

* buildTargetScalaTestClasses implementation  (#35)

* method signature update

* poc

* logic implementation

* getSrcsPaths signature rollback

* reformat

* Apply suggestions from code review

Co-authored-by: Magdalena Augustyńska <32980499+magda-aug@users.noreply.github.com>

* rules filter update

* main_class is the only source + constants update

* targets resolver is created only once in constructor

* reformat

* hasGivenName

* test

* test fix

* reformat

* success typo

Co-authored-by: Magdalena Augustyńska <32980499+magda-aug@users.noreply.github.com>

* Implement buildTargetScalaMainClasses (#36)

* Init

* Fix resolving target options

* Fix variable name

* Change access

* Fix formatting

* Fix formatting

* Read arguments

* Upgrade bsp-testkit

* Add empty test

* Fix formatting

* Move constants

* Fix

* Add more data to test

* Add package name

* Move targetRulesResolver to constructor

* return Completable Future instead of null

* Extract method

* Extract isAttributeSpecifiedAndHasGivenName

* Call buildServerImpl

* Pass compiler options and args to test

* Fix tests

* Fix tests

* Add more args to test

* Read also jvm flags

* Move to constants

* Read only jvm flags

* fix formatting

* unify naming

* use helper method

* remove duplicate methods

* Add more test cases

* revert

* Add test case

* target without args test case

* increase timeout

* add test case without jvm flags

* increase timeout

* increase timeout

* buildClient is now used in the bazel runner (#41)

* buildClient is now used in bazel runner

* format

* bazel runner doesnt throw an exception anymore

* javacoptions and scalacoptions tests (#37)

* scalacopts test

* javacopts test

* reformat

* buildifier

* java_binary import

* test fix

* testkit vestion bump + test fix

* more descriptive targets names

* scalac classDirectory and classpath test update

* .bazelversion file

* __main__/bazel-out/darwin-fastbuild/ removal

* workspaceReload implementation (#38)

* bazel builder sync

* workspaceReload PoC

* bazel sync -> bazel fetch

* reformat

* dev branch import fix (#46)

* executeBazelCommand -> executeBazelBesCommand

* bazel call

* bazel args checker removal

* bazel info update

* log update

* log config

* log level update

* config fix

* log fix

* fix

* log

* more logging

* XDXD

* LOL2

* bazel runner update

* reformat

* initializer clean up

* reformat

* exit code to constant

* date in logger

* bazelProcess moved to the bazel package

* refomat

* Prohibit wildcard imports using error-prone (#45)

So apparently error-prone is built into Bazel and provides a check for wildcard imports.
http://errorprone.info/docs/installation

* script for building and running server (#47)

* filtering blank strings from build progress logs (#50)

* filtering blank strings

* trim rollback

* isBlank -> isEmpty

* additional trim

* Fix build calls and outgroup groups interpretation (#49)

* Add builder without mnemonics for build command

* Change valid parts of classpath parsing

* Switch bazel build calls to use withArguments

* Action graph parser v2 (#42)

* scalacopts test

* javacopts test

* reformat

* buildifier

* scalac classDirectory and classpath test update

* Parse action graph v2 for bazel versions over 4.0.0

* Fix test

* Add tests for different bazel versions

* Comparison of semantic versions

* Format

* Get semantic version out of `bazel info release` command

* Extract action graph v1 tests

* Action graph parser method reorder

* Explicitly get semantic version parts

* Remove redundant return

* Refactor action graph parsers

* Remove logs for creation of test clients

* Refactor semantic version comparator

* Remove comment from .bazelignore

* Cleanup semantic version

* Streamify depset expansion to artifacts

* Remove default visibility from new concat method for strings

* Fix depset expansion when common nodes are traversed

* semantic version comparator is now static

* Improve readability of action graph parser

* Change test logging

* Remove wildcard imports

Co-authored-by: Abrams27 <abramowiczmarcin99@gmail.com>

* >=info logs are separate now (#51)

* separate logs

* new logging levels

* appending logs

* Get jdk info (#43)

* scalacopts test

* javacopts test

* reformat

* buildifier

* scalac classDirectory and classpath test update

* Parse action graph v2 for bazel versions over 4.0.0

* Fix test

* Add tests for different bazel versions

* Comparison of semantic versions

* Format

* Get semantic version out of `bazel info release` command

* Extract action graph v1 tests

* Action graph parser method reorder

* Explicitly get semantic version parts

* Remove redundant return

* Refactor action graph parsers

* Remove logs for creation of test clients

* Refactor semantic version comparator

* Remove comment from .bazelignore

* Cleanup semantic version

* Streamify depset expansion to artifacts

* Remove default visibility from new concat method for strings

* Fix depset expansion when common nodes are traversed

* semantic version comparator is now static

* Improve readability of action graph parser

* Change test logging

* Remove wildcard imports

* Get java home from default settings

* Get java version from aspect

* Get java version through aspect

* Refactor jvm build target data fetching

* Refactor jvm build target logic

* Map java home to uri

* Add java projects tests

* Remove ignored files

* Format

* Remove action graph logs

* Add new project directories to tests script

* Update BSP dependency

Co-authored-by: Abrams27 <abramowiczmarcin99@gmail.com>

* Refactor build manager into several build managers

commit 3fc3f66
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Thu Apr 15 15:39:50 2021 +0000

    Add no build flag to aspects

commit 3364cd1
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Thu Apr 15 12:29:16 2021 +0000

    Add manager for aspects

commit 935c5fc
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Wed Apr 14 12:00:30 2021 +0000

    Update refactor according to new changes

commit 936ac94
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Mon Mar 22 18:05:17 2021 +0000

    Refactor BazelBspServerBuildManager into several different services

commit 4dd0b01
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Fri Feb 26 15:46:40 2021 +0000

    Get semantic version out of `bazel info release` command

commit c594dc1
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Tue Feb 16 16:43:52 2021 +0000

    Fix test

commit f931ccd
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Mon Feb 15 17:17:08 2021 +0000

    Parse action graph v2 for bazel versions over 4.0.0

commit 5f8f55f
Author: Abrams27 <abramowiczmarcin99@gmail.com>
Date:   Sat Feb 6 21:53:54 2021 +0100

    scalac classDirectory and classpath test update

commit a2088c5
Author: Abrams27 <abramowiczmarcin99@gmail.com>
Date:   Sat Jan 30 23:21:16 2021 +0100

    buildifier

commit 9dbb63c
Author: Abrams27 <abramowiczmarcin99@gmail.com>
Date:   Sat Jan 30 23:20:21 2021 +0100

    reformat

commit 57f6fa6
Author: Abrams27 <abramowiczmarcin99@gmail.com>
Date:   Sat Jan 30 23:13:22 2021 +0100

    javacopts test

commit 26abd73
Author: Abrams27 <abramowiczmarcin99@gmail.com>
Date:   Sat Jan 30 22:38:32 2021 +0100

    scalacopts test

commit c0591d0
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Tue Mar 23 19:47:12 2021 +0000

    Add builder without mnemonics for build command

* Add lazy variables

Squashed commits of the following:

commit 3c83a38
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Fri Apr 16 12:10:26 2021 +0000

    Lazy vals recalculated on workspace reload

commit 5ff6d62
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Thu Apr 15 23:15:28 2021 +0000

    Add lazy vals for complicated calculations

* add Apache 2 license and badges

* Entire repository import test (#53)

* testkit version bump

* test

* todo

* style

* style v2

* ci fix 1

* ci fix

* variable update + gitignore update

* Add cpp support to packages:

commit c8c38f8
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Fri May 14 10:14:44 2021 +0000

    Add cpp folder to tests

commit 686b657
Merge: b0b06a3 5032915
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Thu May 13 22:44:35 2021 +0000

    Merge branch 'dev' into cpp-extension

commit b0b06a3
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Thu May 13 15:30:35 2021 +0000

    Add cpp dependency

commit b7cd44d
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Wed Apr 14 11:12:29 2021 +0000

    Add more options to cpp target example

commit 483d9fd
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Tue Apr 13 22:14:00 2021 +0000

    Tests for cpp

commit 73bc827
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Thu Apr 8 18:11:36 2021 +0000

    Updated cpp options command call

commit dfa21f4
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Wed Mar 17 19:01:18 2021 +0000

    Add cpp extension method service

commit 9fa25dd
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Tue Mar 16 18:48:17 2021 +0000

    Add cpp build target

* Remove java 11 methods

* Squashed commit of the following:

commit a9bac73
Author: Andre Rocha <andrefmrocha@live.com.pt>
Date:   Tue May 25 22:32:53 2021 +0000

    Add bazel-sonatype dependency

* Update scala repository checksums

* ProjectView files parser implementation (#55)

* ProjectView files parser implementation

* code reformat

* buildifier

* ci tests

* character variable extraction

* reading test config from file

* java docs

* parse default method

* google format

* google format v2

* PoC: First, very very very basic projectview usage (#57)

* reading file

* projecview provider

* projectview provider usage

* logic

* deps

* fix

* buildifier

* google format

* config removal

* google format v2

* test fix

* google format v3

* kind moved to utils

* config rollback

* fix

* Guarantee deps are built before finishing import. (#56)

* Guarantee deps are built before finishing import.

Dependencies must be fully build in order to guarantee the dependencies are all present for indexing.

* Increase tests timeout

* Refactor BazelBspCompilationManager for more readability

* Refactor targets union to TargetsUtils

* [Projectview] import support (#58)

* DirectoriesSectionParserTest tests rename

* TargetsSectionParserTest tests rename

* ProjectViewParserImplTest tests rename

* ProjectViewSectionSplitterTest tests rename

* import test

* splitter test update

* ProjectImportParser

* merge

* parser + test adjustment

* buildifier

* format

* format v2

* format v3

* format v4

* format v5

* format v6

* format v7

* format v8

* Update README.md

* Update README.md

* [fix] projectview - tab symbol parsing  (#66)

* tabs fix + test

* tests update

* google style

* google style v2

* [fix] Semantic version - more generic support (#68)

* tests

* homebrew version test

* impl fix

* google style

* [fix] 'Loading: 0 packages loaded' message prohibition (#71)

[fix] 'Loading: 0 packages loaded' message prohibition

* [fix] java 8 feature fix (#73)

* installation process simplification (#76)

* depdendencies update

* install script update

* instalation location

* Update README.md

* Update README.md

* Update README.md

* version bump

* RC1 version

Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
Co-authored-by: Magdalena Augustyńska <32980499+magda-aug@users.noreply.github.com>
Co-authored-by: ex0ns <ex0ns@users.noreply.github.com>
Co-authored-by: Gerard Drozdz <gerardd@interia.pl>
Co-authored-by: André Rocha <andre.rocha@jetbrains.com>
Co-authored-by: Andre Rocha <andrefmrocha@live.com.pt>
Co-authored-by: Justin Kaeser <justin.kaeser@jetbrains.com>
  • Loading branch information
8 people committed Aug 6, 2021
1 parent 7317a13 commit 16b10ce
Show file tree
Hide file tree
Showing 204 changed files with 8,157 additions and 1,969 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-resources
5 changes: 4 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java8
build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java8
build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java8
build --javacopt="-Xep:WildcardImport:ERROR"
test --javacopt="-Xep:WildcardImport:ERROR"
run --javacopt="-Xep:WildcardImport:ERROR"
24 changes: 24 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Format

on:
pull_request:
branches: [ dev, master ]

jobs:
google-java-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: "11"
- uses: axel-op/googlejavaformat-action@v3
with:
skipCommit: true
- run: git diff --exit-code
buildifier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: agluszak/bazel-buildifier-action@v0.3
- run: git diff --exit-code
19 changes: 19 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Integration test

on:
push:
branches: [ dev, master ]
pull_request:
branches: [ dev, master ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Run test
run: ./test.sh
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Unit tests

on:
push:
branches: [ dev, master ]
pull_request:
branches: [ dev, master ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Run tests
run: bazel test //...
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/.bazelbsp/bazelbsp.log
/.bazelbsp/bazelbsp.trace.json
/.bsp/bazelbsp.json
/.bazelbsp/
/.bsp/
/.idea/
/.ijwb/
/bazel-*
/sample-repo/.bazelbsp/bazelbsp.trace.json
/sample-repo/.bazelbsp/bazelbsp.log
/sample-repo/bazel-*
.DS_Store
test-resources/.bazelbsp/
test-resources/.bsp/
194 changes: 194 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@

Apache License
Version 2.0, January 2004
https://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

Copyright 2020-2021 JetBrains s.r.o.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

57 changes: 46 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[![JetBrains team project](http://jb.gg/badges/team.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![Integration test](https://github.com/JetBrains/bazel-bsp/actions/workflows/integration-test.yml/badge.svg)](https://github.com/JetBrains/bazel-bsp/actions/workflows/integration-test.yml)

# Bazel BSP
An implementation of the [Build Server Protocol](https://github.com/build-server-protocol/build-server-protocol) for Bazel.


## Status
Below is a list of languages supported over Bazel BSP and their implementation status.
- Language: name of the Language
Expand All @@ -10,29 +14,60 @@ Below is a list of languages supported over Bazel BSP and their implementation s
- Test: Ability to test
- Prerequisites: Any prerequisites needed to properly run the server to its full capabilities

| Language | Import | Compilation | Run | Test | Prerequisites | Notes |
| - | - | - | - | - | - | - |
| Scala ||||| [Toolchain Registration](docs/scala.md) | N/A |
| Java ||||| N/A | Compilation does not offer diagnostics |
| Kotlin ||||| [Version](docs/kotlin.md) | KotlinJS support is minimal and not advised without further setting changes. Java source files in a kotlin rule will not possess diagnostics. |
| Language | Import | Compilation | Run | Test | Diagnostics | Prerequisites | Notes |
| - | - | - | - | - | - | - | - |
| Scala |||||| [Toolchain Registration](docs/scala.md) | N/A |
| Java |||||| N/A | N/A |
| Kotlin |||||| Requires [this version](https://github.com/agluszak/rules_kotlin/tree/diagnostics-updated) of rules_kotlin | KotlinJS support is minimal and not advised without further setting changes. Java source files in a kotlin rule will not possess diagnostics. |


## Installation
1. Please make sure to have followed the prerequisites guide before proceeding.
2. Have [coursier](https://get-coursier.io/docs/cli-installation) installed
3. Run
`coursier launch -r sonatype:snapshots org.jetbrains.bsp:bazel-bsp:0.1.0-SNAPSHOT -M org.jetbrains.bsp.bazel.Install`
4. Add bsp generated folders to your `gitignore`: `.bsp` and `.bazelbsp`
### Easy way (coursier)
1. Have [coursier](https://get-coursier.io/docs/cli-installation) installed
2. Run in the directory where Bazel BSP should be installed:
```
cs launch org.jetbrains.bsp:bazel-bsp:1.0.0-RC1 -M org.jetbrains.bsp.bazel.install.Install
```
3. Add bsp generated folders to your `.gitignore`: `.bsp` and `.bazelbsp`

### More difficult way (from sources)
Might be useful during development
#### Using install script
1. Be inside this project
2. Run `./install.sh` if you want to install Bazel BSP in this project or `./install.sh <path to the directory>` if you want to install it in a different directory

#### Using coursier
1. Have [coursier](https://get-coursier.io/docs/cli-installation) installed
2. Be inside this project
3. Change project version - `maven_coordinates` attribute in the `src/main/java/org/jetbrains/bsp/bazel/BUILD` file
4. Publish a new version:
```
bazel run --stamp --define "maven_repo=file://$HOME/.m2/repository" //src/main/java/org/jetbrains/bsp/bazel:bsp.publish
```
7. Enter directory where Bazel BSP should be installed
8. Install your version:
```
cs launch -r m2Local org.jetbrains.bsp:bazel-bsp:<your version> -M org.jetbrains.bsp.bazel.install.Install
```


## 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`.

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.


## Extending
In order to extend BSP server to other languages, make sure it can be supported with the current state of the [BSP Protocol](https://github.com/build-server-protocol/build-server-protocol/tree/master/docs). Also, make sure there's a [client](https://build-server-protocol.github.io/docs/implementations.html#build-clients), that will be able to support those changes.

The file `BazelBspServer.java`, holds the implementation of the server itself. For any JVM-language, the only needed changes would be for its specific Compiler Options Request (see, for example the [Scala Options Request](https://github.com/build-server-protocol/build-server-protocol/blob/master/docs/extensions/scala.md#scalac-options-request)). If that language does not have its own Options Request, it may be possible to mimic the behavior with current Java or Scala specific requests. Furthermore, make sure the `FILE_EXTENSIONS` constant holds all the relevant extensions for the given language, as well as the `KNOWN_SOURCE_ROOTS` holds all known patterns for the given language, and, finally, the `SUPPORTED_LANGUAGES` should hold the LSP compliant name of the language. Anything else, should just work out of the box.
For any JVM-language, the only needed changes would be for its specific Compiler Options Request (see, for example the [Scala Options Request](https://github.com/build-server-protocol/build-server-protocol/blob/master/docs/extensions/scala.md#scalac-options-request)). If that language does not have its own Options Request, it may be possible to mimic the behavior with current Java or Scala specific requests. Furthermore, make sure the `FILE_EXTENSIONS` constant holds all the relevant extensions for the given language, as well as the `KNOWN_SOURCE_ROOTS` holds all known patterns for the given language, and, finally, the `SUPPORTED_LANGUAGES` should hold the LSP compliant name of the language. Anything else, should just work out of the box.

Any non-JVM language, will also need to look into the `buildTarget/dependencySources` request, since that request only searches for transitive dependencies in the form of jars.

To support Compilation Diagnostics for the given language, they must be supported in the bazel side. Find the rules' implementation for the language [here](https://github.com/bazelbuild/). Let the [diagnostics proto definition](https://github.com/bazelbuild/rules_scala/blob/master/src/protobuf/io/bazel/rules_scala/diagnostics.proto) live inside its repository and make it so that the compiler writes the diagnostics to the given file. **Make sure the file is an output of the `ctx.actions.run()` for the compilation action**. The current state also dictates that the file must have the keyword `diagnostics` in the name. In `BepServer.java`, the mnemonic of the compilation action of the language must be added to the `SUPPORTED_ACTIONS` constant.

Compilation Diagnostics should receive native support from bazel, accompany the state of that [here](https://github.com/bazelbuild/bazel/pull/11766).


## Contributing
This project follows [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). You can download a formatter plugin for Intellij [here](https://plugins.jetbrains.com/plugin/8527-google-java-format).
Loading

0 comments on commit 16b10ce

Please sign in to comment.