Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load JavaInfo and java_common from rules_java #1037

Merged
merged 4 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kotlin/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ bzl_library(
"//kotlin/internal/lint",
"//kotlin/internal/utils",
"//src/main/starlark",
"@rules_java//java:rules",
],
)
3 changes: 0 additions & 3 deletions kotlin/internal/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,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
1 change: 1 addition & 0 deletions kotlin/internal/jvm/associates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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(
"//kotlin/internal:defs.bzl",
_KtJvmInfo = "KtJvmInfo",
Expand Down
1 change: 1 addition & 0 deletions kotlin/internal/jvm/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ load(
# 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(
"//kotlin/internal:defs.bzl",
_KtCompilerPluginInfo = "KtCompilerPluginInfo",
Expand Down
6 changes: 2 additions & 4 deletions kotlin/internal/jvm/impl.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@rules_java//java:defs.bzl", "JavaInfo", "JavaPluginInfo", "java_common")
load(
"//kotlin/internal:defs.bzl",
_JavaPluginInfo = "JavaPluginInfo",
_KspPluginInfo = "KspPluginInfo",
_KtCompilerPluginInfo = "KtCompilerPluginInfo",
_KtJvmInfo = "KtJvmInfo",
Expand Down Expand Up @@ -422,15 +422,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
1 change: 1 addition & 0 deletions kotlin/internal/jvm/jvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ kt_jvm_binary(
```
"""

load("@rules_java//java:defs.bzl", "JavaInfo")
load(
"//kotlin/internal:defs.bzl",
_JAVA_RUNTIME_TOOLCHAIN_TYPE = "JAVA_RUNTIME_TOOLCHAIN_TYPE",
Expand Down
12 changes: 6 additions & 6 deletions kotlin/internal/jvm/plugins.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +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", "JavaPluginInfo")
load(
"//kotlin/internal:defs.bzl",
_JavaPluginInfo = "JavaPluginInfo",
_KspPluginInfo = "KspPluginInfo",
)

Expand All @@ -31,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 @@ -50,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
1 change: 1 addition & 0 deletions kotlin/internal/lint/ktlint_test.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_java//java:defs.bzl", "java_common")
load("//kotlin/internal/utils:windows.bzl", "create_windows_native_launcher_script")
load(":editorconfig.bzl", "get_editorconfig", "is_android_rules_enabled", "is_experimental_rules_enabled")
load(":ktlint_config.bzl", "KtlintConfigInfo")
Expand Down
1 change: 1 addition & 0 deletions kotlin/internal/toolchains.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@rules_java//java:defs.bzl", "JavaInfo", "java_common")
load(
"//kotlin/internal:defs.bzl",
_KT_COMPILER_REPO = "KT_COMPILER_REPO",
Expand Down
1 change: 1 addition & 0 deletions kotlin/internal/utils/generate_jvm_service.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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")

def _generate_jvm_service_impl(ctx):
"""
Expand Down
1 change: 1 addition & 0 deletions third_party/jarjar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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")

def jarjar_action(actions, rules, input, output, jarjar):
actions.run(
Expand Down