15
15
load ("@rules_java//java:defs.bzl" , "JavaInfo" , "JavaPluginInfo" , "java_common" )
16
16
load (
17
17
"//kotlin/internal:defs.bzl" ,
18
- "KtCompilerPluginOption" ,
19
- "KtPluginConfiguration" ,
20
18
_KspPluginInfo = "KspPluginInfo" ,
21
19
_KtCompilerPluginInfo = "KtCompilerPluginInfo" ,
22
20
_KtJvmInfo = "KtJvmInfo" ,
30
28
"//kotlin/internal/utils:utils.bzl" ,
31
29
_utils = "utils" ,
32
30
)
31
+ load ("//src/main/starlark/core/plugin:common.bzl" , "plugin_common" )
33
32
load ("//third_party:jarjar.bzl" , "jarjar_action" )
34
33
35
34
# borrowed from skylib to avoid adding that to the release.
@@ -392,37 +391,6 @@ def _reshade_embedded_kotlinc_jars(target, ctx, jars, deps):
392
391
],
393
392
)
394
393
395
- def _resolve_plugin_options (id , string_list_dict , expand_location ):
396
- """
397
- Resolves plugin options from a string dict to a dict of strings.
398
-
399
- Args:
400
- id: the plugin id
401
- string_list_dict: a dict of list[string].
402
- Returns:
403
- a dict of strings
404
- """
405
- options = []
406
- for (k , vs ) in string_list_dict .items ():
407
- for v in vs :
408
- if "=" in k :
409
- fail ("kotlin compiler option keys cannot contain the = symbol" )
410
- value = k + "=" + expand_location (v ) if v else k
411
- options .append (KtCompilerPluginOption (id = id , value = value ))
412
- return options
413
-
414
- # This is naive reference implementation for resolving configurations.
415
- # A more complicated plugin will need to provide its own implementation.
416
- def _resolve_plugin_cfg (info , options , deps , expand_location ):
417
- ji = java_common .merge ([dep [JavaInfo ] for dep in deps if JavaInfo in dep ])
418
- classpath = depset (ji .runtime_output_jars , transitive = [ji .transitive_runtime_jars ])
419
- return KtPluginConfiguration (
420
- id = info .id ,
421
- options = _resolve_plugin_options (info .id , options , expand_location ),
422
- classpath = classpath ,
423
- data = depset (),
424
- )
425
-
426
394
def kt_compiler_plugin_impl (ctx ):
427
395
plugin_id = ctx .attr .id
428
396
@@ -444,7 +412,7 @@ def kt_compiler_plugin_impl(ctx):
444
412
classpath = depset (info .runtime_output_jars , transitive = [info .transitive_runtime_jars ])
445
413
446
414
# TODO(1035): Migrate kt_compiler_plugin.options to string_list_dict
447
- options = _resolve_plugin_options (plugin_id , {k : [v ] for (k , v ) in ctx .attr .options .items ()}, ctx .expand_location )
415
+ options = plugin_common . resolve_plugin_options (plugin_id , {k : [v ] for (k , v ) in ctx .attr .options .items ()}, ctx .expand_location )
448
416
449
417
return [
450
418
DefaultInfo (files = classpath ),
@@ -454,7 +422,8 @@ def kt_compiler_plugin_impl(ctx):
454
422
options = options ,
455
423
stubs = ctx .attr .stubs_phase ,
456
424
compile = ctx .attr .compile_phase ,
457
- resolve_cfg = _resolve_plugin_cfg ,
425
+ resolve_cfg = plugin_common .resolve_cfg ,
426
+ merge_cfgs = plugin_common .merge_cfgs ,
458
427
),
459
428
]
460
429
0 commit comments