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.
Merge pull request #50 from lucidsoftware/support-generating-semantic…
…db-files-separately Support not bundling SemanticDB files in the output JAR
- Loading branch information
Showing
13 changed files
with
222 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
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
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 @@ | ||
class A |
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 @@ | ||
class B |
Oops, something went wrong.