Skip to content

Commit 274ac9c

Browse files
authored
Pull java_stub_template.txt as an http_file (#1270)
* Pull java_stub_template.txt as an http_file * Fix
1 parent 096170f commit 274ac9c

File tree

8 files changed

+433
-11
lines changed

8 files changed

+433
-11
lines changed

docs/kotlin.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ Define java compiler options for `kt_jvm_*` rules with java sources.
3737
<pre>
3838
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary")
3939

40-
kt_jvm_binary(<a href="#kt_jvm_binary-name">name</a>, <a href="#kt_jvm_binary-deps">deps</a>, <a href="#kt_jvm_binary-srcs">srcs</a>, <a href="#kt_jvm_binary-data">data</a>, <a href="#kt_jvm_binary-resources">resources</a>, <a href="#kt_jvm_binary-associates">associates</a>, <a href="#kt_jvm_binary-javac_opts">javac_opts</a>, <a href="#kt_jvm_binary-jvm_flags">jvm_flags</a>, <a href="#kt_jvm_binary-kotlinc_opts">kotlinc_opts</a>,
41-
<a href="#kt_jvm_binary-main_class">main_class</a>, <a href="#kt_jvm_binary-module_name">module_name</a>, <a href="#kt_jvm_binary-plugins">plugins</a>, <a href="#kt_jvm_binary-resource_jars">resource_jars</a>, <a href="#kt_jvm_binary-resource_strip_prefix">resource_strip_prefix</a>, <a href="#kt_jvm_binary-runtime_deps">runtime_deps</a>)
40+
kt_jvm_binary(<a href="#kt_jvm_binary-name">name</a>, <a href="#kt_jvm_binary-deps">deps</a>, <a href="#kt_jvm_binary-srcs">srcs</a>, <a href="#kt_jvm_binary-data">data</a>, <a href="#kt_jvm_binary-resources">resources</a>, <a href="#kt_jvm_binary-associates">associates</a>, <a href="#kt_jvm_binary-java_stub_template">java_stub_template</a>, <a href="#kt_jvm_binary-javac_opts">javac_opts</a>,
41+
<a href="#kt_jvm_binary-jvm_flags">jvm_flags</a>, <a href="#kt_jvm_binary-kotlinc_opts">kotlinc_opts</a>, <a href="#kt_jvm_binary-main_class">main_class</a>, <a href="#kt_jvm_binary-module_name">module_name</a>, <a href="#kt_jvm_binary-plugins">plugins</a>, <a href="#kt_jvm_binary-resource_jars">resource_jars</a>,
42+
<a href="#kt_jvm_binary-resource_strip_prefix">resource_strip_prefix</a>, <a href="#kt_jvm_binary-runtime_deps">runtime_deps</a>)
4243
</pre>
4344

4445
Builds a Java archive ("jar file"), plus a wrapper shell script with the same name as the rule. The wrapper
@@ -59,6 +60,7 @@ It is appropriate for building workspace utilities. `java_binary` should be pref
5960
| <a id="kt_jvm_binary-data"></a>data | The list of files needed by this rule at runtime. See general comments about `data` at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
6061
| <a id="kt_jvm_binary-resources"></a>resources | A list of files that should be include in a Java jar. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
6162
| <a id="kt_jvm_binary-associates"></a>associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
63+
| <a id="kt_jvm_binary-java_stub_template"></a>java_stub_template | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `"@rules_kotlin//third_party:java_stub_template.txt"` |
6264
| <a id="kt_jvm_binary-javac_opts"></a>javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
6365
| <a id="kt_jvm_binary-jvm_flags"></a>jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet support make variable substitution. | List of strings | optional | `[]` |
6466
| <a id="kt_jvm_binary-kotlinc_opts"></a>kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
@@ -136,8 +138,8 @@ kt_jvm_import(
136138
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
137139

138140
kt_jvm_library(<a href="#kt_jvm_library-name">name</a>, <a href="#kt_jvm_library-deps">deps</a>, <a href="#kt_jvm_library-srcs">srcs</a>, <a href="#kt_jvm_library-data">data</a>, <a href="#kt_jvm_library-resources">resources</a>, <a href="#kt_jvm_library-associates">associates</a>, <a href="#kt_jvm_library-exported_compiler_plugins">exported_compiler_plugins</a>, <a href="#kt_jvm_library-exports">exports</a>,
139-
<a href="#kt_jvm_library-javac_opts">javac_opts</a>, <a href="#kt_jvm_library-kotlinc_opts">kotlinc_opts</a>, <a href="#kt_jvm_library-module_name">module_name</a>, <a href="#kt_jvm_library-neverlink">neverlink</a>, <a href="#kt_jvm_library-plugins">plugins</a>, <a href="#kt_jvm_library-resource_jars">resource_jars</a>,
140-
<a href="#kt_jvm_library-resource_strip_prefix">resource_strip_prefix</a>, <a href="#kt_jvm_library-runtime_deps">runtime_deps</a>)
141+
<a href="#kt_jvm_library-java_stub_template">java_stub_template</a>, <a href="#kt_jvm_library-javac_opts">javac_opts</a>, <a href="#kt_jvm_library-kotlinc_opts">kotlinc_opts</a>, <a href="#kt_jvm_library-module_name">module_name</a>, <a href="#kt_jvm_library-neverlink">neverlink</a>, <a href="#kt_jvm_library-plugins">plugins</a>,
142+
<a href="#kt_jvm_library-resource_jars">resource_jars</a>, <a href="#kt_jvm_library-resource_strip_prefix">resource_strip_prefix</a>, <a href="#kt_jvm_library-runtime_deps">runtime_deps</a>)
141143
</pre>
142144

143145
This rule compiles and links Kotlin and Java sources into a .jar file.
@@ -155,6 +157,7 @@ This rule compiles and links Kotlin and Java sources into a .jar file.
155157
| <a id="kt_jvm_library-associates"></a>associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
156158
| <a id="kt_jvm_library-exported_compiler_plugins"></a>exported_compiler_plugins | Exported compiler plugins.<br><br>Compiler plugins listed here will be treated as if they were added in the plugins attribute of any targets that directly depend on this target. Like `java_plugin`s exported_plugins, this is not transitive | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
157159
| <a id="kt_jvm_library-exports"></a>exports | Exported libraries.<br><br>Deps listed here will be made available to other rules, as if the parents explicitly depended on these deps. This is not true for regular (non-exported) deps. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
160+
| <a id="kt_jvm_library-java_stub_template"></a>java_stub_template | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `"@rules_kotlin//third_party:java_stub_template.txt"` |
158161
| <a id="kt_jvm_library-javac_opts"></a>javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
159162
| <a id="kt_jvm_library-kotlinc_opts"></a>kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
160163
| <a id="kt_jvm_library-module_name"></a>module_name | The name of the module, if not provided the module name is derived from the label. --e.g., `//some/package/path:label_name` is translated to `some_package_path-label_name`. | String | optional | `""` |
@@ -172,9 +175,9 @@ This rule compiles and links Kotlin and Java sources into a .jar file.
172175
<pre>
173176
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test")
174177

175-
kt_jvm_test(<a href="#kt_jvm_test-name">name</a>, <a href="#kt_jvm_test-deps">deps</a>, <a href="#kt_jvm_test-srcs">srcs</a>, <a href="#kt_jvm_test-data">data</a>, <a href="#kt_jvm_test-resources">resources</a>, <a href="#kt_jvm_test-associates">associates</a>, <a href="#kt_jvm_test-env">env</a>, <a href="#kt_jvm_test-javac_opts">javac_opts</a>, <a href="#kt_jvm_test-jvm_flags">jvm_flags</a>, <a href="#kt_jvm_test-kotlinc_opts">kotlinc_opts</a>,
176-
<a href="#kt_jvm_test-main_class">main_class</a>, <a href="#kt_jvm_test-module_name">module_name</a>, <a href="#kt_jvm_test-plugins">plugins</a>, <a href="#kt_jvm_test-resource_jars">resource_jars</a>, <a href="#kt_jvm_test-resource_strip_prefix">resource_strip_prefix</a>, <a href="#kt_jvm_test-runtime_deps">runtime_deps</a>,
177-
<a href="#kt_jvm_test-test_class">test_class</a>)
178+
kt_jvm_test(<a href="#kt_jvm_test-name">name</a>, <a href="#kt_jvm_test-deps">deps</a>, <a href="#kt_jvm_test-srcs">srcs</a>, <a href="#kt_jvm_test-data">data</a>, <a href="#kt_jvm_test-resources">resources</a>, <a href="#kt_jvm_test-associates">associates</a>, <a href="#kt_jvm_test-env">env</a>, <a href="#kt_jvm_test-java_stub_template">java_stub_template</a>, <a href="#kt_jvm_test-javac_opts">javac_opts</a>,
179+
<a href="#kt_jvm_test-jvm_flags">jvm_flags</a>, <a href="#kt_jvm_test-kotlinc_opts">kotlinc_opts</a>, <a href="#kt_jvm_test-main_class">main_class</a>, <a href="#kt_jvm_test-module_name">module_name</a>, <a href="#kt_jvm_test-plugins">plugins</a>, <a href="#kt_jvm_test-resource_jars">resource_jars</a>,
180+
<a href="#kt_jvm_test-resource_strip_prefix">resource_strip_prefix</a>, <a href="#kt_jvm_test-runtime_deps">runtime_deps</a>, <a href="#kt_jvm_test-test_class">test_class</a>)
178181
</pre>
179182

180183
Setup a simple kotlin_test.
@@ -195,6 +198,7 @@ Setup a simple kotlin_test.
195198
| <a id="kt_jvm_test-resources"></a>resources | A list of files that should be include in a Java jar. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
196199
| <a id="kt_jvm_test-associates"></a>associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
197200
| <a id="kt_jvm_test-env"></a>env | Specifies additional environment variables to set when the target is executed by bazel test. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` |
201+
| <a id="kt_jvm_test-java_stub_template"></a>java_stub_template | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `"@rules_kotlin//third_party:java_stub_template.txt"` |
198202
| <a id="kt_jvm_test-javac_opts"></a>javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
199203
| <a id="kt_jvm_test-jvm_flags"></a>jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet support make variable substitution. | List of strings | optional | `[]` |
200204
| <a id="kt_jvm_test-kotlinc_opts"></a>kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |

kotlin/internal/jvm/impl.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _write_launcher_action(ctx, rjars, main_class, jvm_flags):
6767
args: Args that should be passed to the Binary.
6868
"""
6969
jvm_flags = " ".join([ctx.expand_location(f, ctx.attr.data) for f in jvm_flags])
70-
template = ctx.attr._java_stub_template.files.to_list()[0]
70+
template = ctx.attr.java_stub_template.files.to_list()[0]
7171

7272
java_runtime = ctx.toolchains["@bazel_tools//tools/jdk:runtime_toolchain_type"].java_runtime
7373
java_bin_path = java_runtime.java_executable_runfiles_path

kotlin/internal/jvm/jvm.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ _implicit_deps = {
134134
default = Label("@bazel_tools//tools/zip:zipper"),
135135
allow_files = True,
136136
),
137-
"_java_stub_template": attr.label(
137+
"java_stub_template": attr.label(
138138
cfg = "exec",
139-
default = Label("@bazel_tools//tools/java:java_stub_template.txt"),
139+
default = Label("//third_party:java_stub_template.txt"),
140140
allow_single_file = True,
141141
),
142142
"_toolchain": attr.label(

src/main/starlark/core/compile/cli/toolchain.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ cli_toolchain = rule(
7171
),
7272
"java_stub_template": attr.label(
7373
cfg = "exec",
74-
default = Label("@bazel_tools//tools/java:java_stub_template.txt"),
74+
default = Label("//third_party:java_stub_template.txt"),
7575
allow_single_file = True,
7676
),
7777
"_empty_jar": attr.label(

src/main/starlark/core/repositories/kotlin/BUILD.release.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
13
bzl_library(
24
name = "kotlin",
35
srcs = glob([

third_party/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package(default_visibility = ["//visibility:public"])
1919

2020
exports_files([
2121
"empty.jdeps",
22+
"java_stub_template.txt",
2223
])
2324

2425
genrule(
@@ -95,6 +96,7 @@ release_archive(
9596
"empty.jar",
9697
"empty.jdeps",
9798
"jarjar.bzl",
99+
"java_stub_template.txt",
98100
],
99101
src_map = {
100102
"jarjar_runner_deploy.jar": "jarjar.jar",

third_party/BUILD.release.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_import")
1818
exports_files([
1919
"empty.jar",
2020
"empty.jdeps",
21+
"java_stub_template.txt",
2122
])
2223

2324
java_binary(

0 commit comments

Comments
 (0)