Skip to content

Commit

Permalink
Cleanup JavaPluginInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
comius committed Sep 29, 2023
1 parent 9118a91 commit 70b227d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
4 changes: 0 additions & 4 deletions kotlin/internal/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# 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.#
load("@rules_java//java:defs.bzl", "java_common")

# The Kotlin Toolchain type.
TOOLCHAIN_TYPE = "%s" % Label("//kotlin/internal:kt_toolchain_type")
Expand All @@ -20,9 +19,6 @@ TOOLCHAIN_TYPE = "%s" % Label("//kotlin/internal:kt_toolchain_type")
JAVA_TOOLCHAIN_TYPE = "@bazel_tools//tools/jdk:toolchain_type"
JAVA_RUNTIME_TOOLCHAIN_TYPE = "@bazel_tools//tools/jdk:runtime_toolchain_type"

# Upstream provider for Java plugins
JavaPluginInfo = getattr(java_common, "JavaPluginInfo")

# The name of the Kotlin compiler workspace.
KT_COMPILER_REPO = "com_github_jetbrains_kotlin"

Expand Down
7 changes: 2 additions & 5 deletions kotlin/internal/jvm/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
# 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.
load("@rules_java//java:defs.bzl", "JavaInfo", "java_common")
load("@rules_java//java:defs.bzl", "JavaInfo", "java_common", "JavaPluginInfo")
load(
"//kotlin/internal/jvm:compile.bzl",
"export_only_providers",
_kt_jvm_produce_jar_actions = "kt_jvm_produce_jar_actions",
)
load(
"//kotlin/internal:defs.bzl",
_JavaPluginInfo = "JavaPluginInfo",
_KspPluginInfo = "KspPluginInfo",
_KtCompilerPluginInfo = "KtCompilerPluginInfo",
_KtJvmInfo = "KtJvmInfo",
Expand Down Expand Up @@ -422,15 +421,13 @@ def kt_compiler_plugin_impl(ctx):
]

def kt_ksp_plugin_impl(ctx):
_JavaPluginInfo = getattr(java_common, "JavaPluginInfo")

info = java_common.merge([dep[JavaInfo] for dep in ctx.attr.deps])
classpath = depset(info.runtime_output_jars, transitive = [info.transitive_runtime_jars])

return [
DefaultInfo(files = classpath),
_KspPluginInfo(plugins = [
_JavaPluginInfo(
JavaPluginInfo(
runtime_deps = [
info,
],
Expand Down
13 changes: 6 additions & 7 deletions kotlin/internal/jvm/plugins.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
# 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.
load("@rules_java//java:defs.bzl", "JavaInfo")
load("@rules_java//java:defs.bzl", "JavaInfo", "JavaPluginInfo")
load(
"//kotlin/internal:defs.bzl",
_JavaPluginInfo = "JavaPluginInfo",
_KspPluginInfo = "KspPluginInfo",
)

Expand All @@ -32,8 +31,8 @@ def _targets_to_annotation_processors(targets):
if _KspPluginInfo in targets:
# KSP plugins are handled by the KSP Kotlinc compiler plugin
pass
elif _JavaPluginInfo in t:
p = t[_JavaPluginInfo].plugins
elif JavaPluginInfo in t:
p = t[JavaPluginInfo].plugins
if p.processor_jars:
plugins.append(p)
elif JavaInfo in t:
Expand All @@ -51,13 +50,13 @@ def _targets_to_ksp_annotation_processors(targets):
return depset(plugins)

def _targets_to_annotation_processors_java_plugin_info(targets):
return [t[_JavaPluginInfo] for t in targets if _JavaPluginInfo in t]
return [t[JavaPluginInfo] for t in targets if JavaPluginInfo in t]

def _targets_to_transitive_runtime_jars(targets):
transitive = []
for t in targets:
if _JavaPluginInfo in t:
transitive.append(t[_JavaPluginInfo].plugins.processor_jars)
if JavaPluginInfo in t:
transitive.append(t[JavaPluginInfo].plugins.processor_jars)
elif JavaInfo in t:
transitive.append(t[JavaInfo].plugins.processor_jars)
elif _KspPluginInfo in t:
Expand Down

0 comments on commit 70b227d

Please sign in to comment.