Skip to content

Commit

Permalink
Change SemanticdbInfo.plugin_jar from string to File (#1530)
Browse files Browse the repository at this point in the history
* SemanticdbInfo.plugin_jar from string to File

* fix semanticdb example test
  • Loading branch information
crt-31 authored Dec 19, 2023
1 parent 1ddfd88 commit f8274d6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/semanticdb/aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def semanticdb_info_aspect_impl(target, ctx):
output_struct = struct(
target_label = str(target.label),
semanticdb_target_root = target[SemanticdbInfo].target_root,
semanticdb_pluginjar = target[SemanticdbInfo].plugin_jar,
semanticdb_pluginjar = "" if target[SemanticdbInfo].plugin_jar.path == None else target[SemanticdbInfo].plugin_jar.path,
)

json_output_file = ctx.actions.declare_file("%s_semanticdb_info.json" % target.label.name)
Expand Down
6 changes: 3 additions & 3 deletions scala/private/phases/phase_semanticdb.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def phase_semanticdb(ctx, p):
scalacopts = []
semanticdb_deps = []
output_files = []
plugin_jar_path = ""
plugin_jar = None

target_output_path = paths.dirname(ctx.outputs.jar.path)

Expand All @@ -45,7 +45,7 @@ def phase_semanticdb(ctx, p):
if len(semanticdb_deps) != 1:
fail("more than one semanticdb plugin jar was specified in scala_toolchain. Expect a single semanticdb plugin jar")

plugin_jar_path = semanticdb_deps[0][JavaInfo].java_outputs[0].class_jar.path
plugin_jar = semanticdb_deps[0][JavaInfo].java_outputs[0].class_jar

scalacopts += [
#note: Xplugin parameter handled in scalacworker,
Expand All @@ -65,7 +65,7 @@ def phase_semanticdb(ctx, p):
semanticdb_enabled = True,
target_root = None if toolchain.semanticdb_bundle_in_jar else semanticdb_target_root,
is_bundled_in_jar = toolchain.semanticdb_bundle_in_jar,
plugin_jar = plugin_jar_path,
plugin_jar = plugin_jar,
)

return struct(
Expand Down
2 changes: 1 addition & 1 deletion scala/semanticdb_provider.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ SemanticdbInfo = provider(
"semanticdb_enabled": "boolean",
"target_root": "directory containing the semanticdb files (relative to execroot).",
"is_bundled_in_jar": "boolean: whether the semanticdb files are bundled inside the jar",
"plugin_jar": "path to semanticdb plugin jar (relative to execroot)",
"plugin_jar": "semanticdb plugin jar file",
},
)
2 changes: 1 addition & 1 deletion test/semanticdb/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def semanticdb_vars_script_impl(ctx):
"%TARGETROOT%": "" if semanticdb_info.target_root == None else semanticdb_info.target_root,
"%ENABLED%": "1" if semanticdb_info.semanticdb_enabled else "0",
"%ISBUNDLED%": "1" if semanticdb_info.is_bundled_in_jar else "0",
"%PLUGINPATH%": semanticdb_info.plugin_jar,
"%PLUGINPATH%": "" if semanticdb_info.plugin_jar == None else semanticdb_info.plugin_jar.path,
},
)
return [
Expand Down

0 comments on commit f8274d6

Please sign in to comment.