Skip to content
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
6 changes: 4 additions & 2 deletions src/main/kotlin/BUILD.release.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ java_binary(
":jdeps-gen",
":skip-code-gen",
"//src/main/kotlin/io/bazel/kotlin/compiler",
"@com_github_jetbrains_kotlin//:lib/jvm-abi-gen.jar",
"@com_github_jetbrains_kotlin//:lib/kotlin-compiler.jar",
"@com_github_jetbrains_kotlin//:jvm-abi-gen",
"@com_github_jetbrains_kotlin//:kotlin-compiler",
],
jvm_flags = [
"-D@com_github_jetbrains_kotlin...jvm-abi-gen=$(rootpath @com_github_jetbrains_kotlin//:jvm-abi-gen)",
"-D@com_github_jetbrains_kotlin...kotlin-compiler=$(rootpath @com_github_jetbrains_kotlin//:kotlin-compiler)",
"-XX:-MaxFDLimit",
],
main_class = "io.bazel.kotlin.builder.cmd.Build",
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/bootstrap.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def kt_bootstrap_binary(
main_class,
runtime_library,
shade_rules,
jvm_flags = [],
data = [],
visibility = ["//visibility:public"]):
raw = name + "_raw"
Expand All @@ -165,7 +166,7 @@ def kt_bootstrap_binary(
java_binary(
name = name,
data = data,
jvm_flags = [
jvm_flags = jvm_flags + [
"-XX:+IgnoreUnrecognizedVMOptions",
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/io/bazel/kotlin/builder/cmd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ kt_bootstrap_binary(
"//src/main/kotlin:jdeps-gen",
"//src/main/kotlin:skip-code-gen",
"//src/main/kotlin/io/bazel/kotlin/compiler",
"@com_github_jetbrains_kotlin//:lib/jvm-abi-gen.jar",
"@com_github_jetbrains_kotlin//:lib/kotlin-compiler.jar",
"@com_github_jetbrains_kotlin//:jvm-abi-gen",
"@com_github_jetbrains_kotlin//:kotlin-compiler",
],
jvm_flags = [
"-D@com_github_jetbrains_kotlin...jvm-abi-gen=$(rootpath @com_github_jetbrains_kotlin//:jvm-abi-gen)",
"-D@com_github_jetbrains_kotlin...kotlin-compiler=$(rootpath @com_github_jetbrains_kotlin//:kotlin-compiler)",
],
main_class = "io.bazel.kotlin.builder.cmd.Build",
runtime_library = ":build_lib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ class KotlinToolchain private constructor(
)

private val DEFAULT_JVM_ABI_PATH = BazelRunFiles.resolveVerified(
"external",
"com_github_jetbrains_kotlin",
"lib",
"jvm-abi-gen.jar",
System.getProperty("@com_github_jetbrains_kotlin...jvm-abi-gen"),
).toPath()

private val COMPILER = BazelRunFiles.resolveVerified(
Expand Down Expand Up @@ -116,10 +113,7 @@ class KotlinToolchain private constructor(
val jdepsGenFile = JDEPS_GEN_PLUGIN.verified().absoluteFile

val kotlinCompilerJar = BazelRunFiles.resolveVerified(
"external",
"com_github_jetbrains_kotlin",
"lib",
"kotlin-compiler.jar",
System.getProperty("@com_github_jetbrains_kotlin...kotlin-compiler"),
)

val jvmAbiGenFile = jvmAbiGenPath.verified()
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/bazel/kotlin/builder/Deps.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static Dep importJar(String label, File compileJar) {
* @return Dep reprenseting the resource
* @throws IllegalArgumentException if the label does not exist.
*/
protected static Dep fromLabel(String label) {
public static Dep fromLabel(String label) {
// jvm properties do not allow slashes or :.
String key = label.replaceAll("/", ".").replaceAll(":", ".");
Properties properties = System.getProperties();
Expand Down
24 changes: 11 additions & 13 deletions src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,23 @@ kt_rules_test(
],
)

# TODO(bazelbuild/rules_kotlin/issues/275): Remove full jar reference when the kt_rules_test handles jvm_import data better.
_MAVEN_CENTRAL_PREFIX = "@kotlin_rules_maven//:v1/https/maven-central.storage.googleapis.com/repos/central/data"

_AUTO_VALUE_PREFIX = "%s/com/google/auto/value" % _MAVEN_CENTRAL_PREFIX

_AUTO_VALUE_JAR = _AUTO_VALUE_PREFIX + "/auto-value/1.6.5/auto-value-1.6.5.jar"
# Trick to get default files produced by jvm_import into data
filegroup(
name = "auto_value",
srcs = ["@kotlin_rules_maven//:com_google_auto_value_auto_value"],
)

_AUTO_VALUE_ANNOTATIONS_JAR = _AUTO_VALUE_PREFIX + "/auto-value-annotations/1.6.5/auto-value-annotations-1.6.5.jar"
filegroup(
name = "auto_value_annotations",
srcs = ["@kotlin_rules_maven//:com_google_auto_value_auto_value_annotations"],
)

kt_rules_test(
name = "KotlinBuilderJvmKaptTest",
srcs = ["jvm/KotlinBuilderJvmKaptTest.java"],
data = [
_AUTO_VALUE_JAR,
_AUTO_VALUE_ANNOTATIONS_JAR,
],
jvm_flags = [
"-Dauto_value=$(location %s)" % _AUTO_VALUE_JAR,
"-Dauto_value_annotations=$(location %s)" % _AUTO_VALUE_ANNOTATIONS_JAR,
"auto_value",
"auto_value_annotations",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ class KotlinBuilderJvmJdepsTest(private val enableK2Compiler: Boolean) {

val ctx = KotlinJvmTestBuilder()

val TEST_FIXTURES_DEP = Dep.importJar(
"testFixtures",
BazelRunFiles.resolveVerified(
"dev_io_bazel_rules_kotlin", "src", "test", "kotlin", "io", "bazel", "kotlin", "builder", "tasks", "libJdepsParserTestFixtures.jar"
)
)
val TEST_FIXTURES_DEP = Dep.fromLabel(":JdepsParserTestFixtures")

@Test
fun `no kotlin source produces empty jdeps`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@
@RunWith(JUnit4.class)
public class KotlinBuilderJvmKaptTest {
private static final Dep AUTO_VALUE_ANNOTATIONS =
Dep.importJar(
"autovalue_annotations",
System.getProperty("auto_value_annotations")
.replaceFirst("external" + File.separator, ""));
Dep.fromLabel("auto_value_annotations");
private static final Dep AUTO_VALUE =
Dep.importJar(
"autovalue",
System.getProperty("auto_value")
.replaceFirst("external" + File.separator, ""));
Dep.fromLabel("auto_value");
private static final AnnotationProcessor AUTO_VALUE_ANNOTATION_PROCESSOR =
AnnotationProcessor.builder()
.processClass("com.google.auto.value.processor.AutoValueProcessor")
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/io/bazel/kotlin/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def kt_rules_test(name, **kwargs):
"//src/main/kotlin:jdeps-gen",
"@com_github_jetbrains_kotlin//:annotations",
"@com_github_jetbrains_kotlin//:jvm-abi-gen",
"@com_github_jetbrains_kotlin//:kotlin-compiler",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7",
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8",
Expand Down