forked from higherkindness/rules_scala
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support not bundling SemanticDB files in the output JAR
- Loading branch information
Jaden Peterson
committed
Aug 19, 2024
1 parent
5eb0406
commit c35b45a
Showing
14 changed files
with
226 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
load("@bazel_skylib//lib:paths.bzl", "paths") | ||
load("@rules_scala_annex//rules:providers.bzl", _ScalaConfiguration = "ScalaConfiguration") | ||
|
||
# | ||
# PHASE: semanticdb | ||
# | ||
# Configures the compiler to output SemanticDB metadata. Note that this phase won't work without the | ||
# SemanticDB compiler plugin being enabled. | ||
# | ||
def phase_semanticdb(ctx, g): | ||
scala_configuration = ctx.attr.scala[_ScalaConfiguration] | ||
|
||
if scala_configuration.semanticdb_bundle: | ||
return struct(outputs = [], scalacopts = []) | ||
|
||
outputs = [] | ||
semanticdb_directory = paths.join("_semanticdb/", ctx.label.name) | ||
semanticdb_target_root = paths.join(paths.dirname(ctx.outputs.jar.path), semanticdb_directory) | ||
|
||
for source in ctx.files.srcs: | ||
if source.extension == "scala": | ||
output_filename = paths.join( | ||
semanticdb_directory, | ||
"META-INF", "semanticdb", | ||
"{}.semanticdb".format(source.path), | ||
) | ||
|
||
outputs.append(ctx.actions.declare_file(output_filename)) | ||
|
||
if scala_configuration.version.startswith("2"): | ||
scalacopts = [ | ||
"-P:semanticdb:failures:error", | ||
"-P:semanticdb:targetroot:{}".format(semanticdb_target_root), | ||
] | ||
else: | ||
scalacopts = [ | ||
"-semanticdb-target:{}".format(semanticdb_target_root), | ||
"-Ysemanticdb", | ||
] | ||
|
||
return struct(outputs = outputs, scalacopts = scalacopts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.