-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strict Kotlin dependency checking/enforcement.
- Loading branch information
1 parent
4fb6e0a
commit 7f39b76
Showing
16 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/io/bazel/kotlin/builder/utils/jars/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2020 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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_library") | ||
load("//src/main/kotlin:bootstrap.bzl", "kt_bootstrap_library") | ||
|
||
kt_bootstrap_library( | ||
name = "jars", | ||
srcs = glob([ | ||
"*.kt", | ||
"**/*.kt", | ||
]), | ||
visibility = ["//src:__subpackages__"], | ||
deps = [ | ||
"//src/main/protobuf:deps_java_proto", | ||
], | ||
) |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarOwner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.bazel.kotlin.builder.utils.jars | ||
|
||
import io.bazel.kotlin.builder.utils.jars.JarHelper.Companion.INJECTING_RULE_KIND | ||
import io.bazel.kotlin.builder.utils.jars.JarHelper.Companion.TARGET_LABEL | ||
import java.io.IOException | ||
import java.io.UncheckedIOException | ||
import java.nio.file.Path | ||
import java.util.jar.JarFile | ||
|
||
data class JarOwner(val jar: Path, val label: String? = null, val aspect: String? = null) { | ||
companion object { | ||
fun readJarOwnerFromManifest(jarPath: Path): JarOwner { | ||
try { | ||
JarFile(jarPath.toFile()).use { jarFile -> | ||
val manifest = jarFile.manifest ?: return JarOwner(jarPath) | ||
val attributes = manifest.mainAttributes | ||
val label = attributes[TARGET_LABEL] as String? | ||
?: return JarOwner(jarPath) | ||
val injectingRuleKind = attributes[INJECTING_RULE_KIND] as String? | ||
return JarOwner(jarPath, label, injectingRuleKind) | ||
} | ||
} catch (e: IOException) { | ||
// This jar file pretty much has to exist. | ||
throw UncheckedIOException(e) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters