aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarkDacek <dacek@google.com>2023-07-25 20:12:37 +0000
committerMarkDacek <dacek@google.com>2023-07-25 20:48:46 +0000
commit960043796bbda173c40b1381338117749ba7b589 (patch)
tree7880dc42ef77eed2b7787cf32b693c52a14113bd /tools
parent2d99ab7781561ae32e22653253c9712a1cdae0a8 (diff)
parent4effec817231742ccf4ee377790bf42426ef612e (diff)
downloadbazelbuild-kotlin-rules-960043796bbda173c40b1381338117749ba7b589.tar.gz
Merge remote-tracking branch 'aosp/upstream-main' into bazel-release-725
* aosp/upstream-main: (37 commits) Set toolchain parameter inside rules_kotlin Update Kotlinc to 1.9.0 Rebuild source_jar_zipper_deploy.jar Rebuild source_jar_zipper_deploy.jar Fix SourceJarZipper to handle leading underscores and trailing comments. Rebuild source_jar_zipper_deploy.jar n/a Remove `kotlin_annotation_processing` from kotlin toolchain restore kotlinc progress message to what it was Add java toolchain type to all rules which are using java_common include `default_applicable_licenses` to subpackages of `bazel_rules/rules_kotlin` package Pass complete lint_actions.AndroidLintRulesetInfos into lint_actions.run_lint_on_library Delete unused field turbine_jsa from kt_jvm_toolchains n/a n/a Sort kt_jvm_toolchain attrs alphabetically Include exported targets on the J2clInfo provider Update Kotlinc to 1.8.21 Rebuild source_jar_zipper_deploy.jar Rebuild source_jar_zipper_deploy.jar ... Test: N/A Bug: 292565910 Change-Id: I346a123415737fe5a7a92d78031e3ec6549237cd
Diffstat (limited to 'tools')
-rw-r--r--tools/BUILD4
-rwxr-xr-xtools/bin/source_jar_zipper_deploy.jarbin2077285 -> 2149157 bytes
-rw-r--r--tools/java/com/google/devtools/kotlin/BUILD4
-rw-r--r--tools/java/com/google/devtools/kotlin/SourceJarZipper.kt22
4 files changed, 23 insertions, 7 deletions
diff --git a/tools/BUILD b/tools/BUILD
index 02f945c..812302f 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -17,7 +17,9 @@ load("//bazel:deploy_jar_freshness_golden_test.bzl", "deploy_jar_freshness_golde
licenses(["notice"])
-package(default_visibility = ["//:internal"])
+package(
+ default_visibility = ["//:internal"],
+)
# JAR that contains a marker entry, for identifying apps built by rules_kotlin.
genrule(
diff --git a/tools/bin/source_jar_zipper_deploy.jar b/tools/bin/source_jar_zipper_deploy.jar
index 8c6309e..b181e8a 100755
--- a/tools/bin/source_jar_zipper_deploy.jar
+++ b/tools/bin/source_jar_zipper_deploy.jar
Binary files differ
diff --git a/tools/java/com/google/devtools/kotlin/BUILD b/tools/java/com/google/devtools/kotlin/BUILD
index 544536b..0b7a223 100644
--- a/tools/java/com/google/devtools/kotlin/BUILD
+++ b/tools/java/com/google/devtools/kotlin/BUILD
@@ -16,7 +16,9 @@
load("//kotlin:rules.bzl", "kt_jvm_library")
-package(default_visibility = ["//:internal"])
+package(
+ default_visibility = ["//:internal"],
+)
licenses(["notice"])
diff --git a/tools/java/com/google/devtools/kotlin/SourceJarZipper.kt b/tools/java/com/google/devtools/kotlin/SourceJarZipper.kt
index c2d34d8..2ad7568 100644
--- a/tools/java/com/google/devtools/kotlin/SourceJarZipper.kt
+++ b/tools/java/com/google/devtools/kotlin/SourceJarZipper.kt
@@ -22,6 +22,7 @@ import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
+import java.time.LocalDateTime
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream
@@ -41,6 +42,7 @@ import picocli.CommandLine.Spec
)
class SourceJarZipper : Runnable {
@Spec private lateinit var spec: CommandSpec
+
override fun run() {
throw ParameterException(spec.commandLine(), "Specify a command: zip, zip_resources or unzip")
}
@@ -85,6 +87,9 @@ private fun clearSingletonEmptyPath(list: MutableList<Path>) {
}
}
+// Normalize timestamps
+val DEFAULT_TIMESTAMP = LocalDateTime.of(2010, 1, 1, 0, 0, 0)
+
fun MutableMap<Path, Path>.writeToStream(
zipper: ZipOutputStream,
prefix: String = "",
@@ -92,7 +97,7 @@ fun MutableMap<Path, Path>.writeToStream(
for ((zipPath, sourcePath) in this) {
BufferedInputStream(Files.newInputStream(sourcePath)).use { inputStream ->
val entry = ZipEntry(Paths.get(prefix).resolve(zipPath).toString())
- entry.time = 0
+ entry.timeLocal = DEFAULT_TIMESTAMP
zipper.putNextEntry(entry)
inputStream.copyTo(zipper, bufferSize = 1024)
}
@@ -125,9 +130,11 @@ class Zip : Runnable {
)
val commonSrcs = mutableListOf<Path>()
- companion object {
+ private companion object {
const val PACKAGE_SPACE = "package "
- val PACKAGE_NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_]*(\\.[a-zA-Z0-9_]+)*".toRegex()
+ // can't start with digit and can't be all underscores
+ val IDENTIFIER_REGEX = Regex("(?:[a-zA-Z]|_+[a-zA-Z0-9])\\w*")
+ val PACKAGE_NAME_REGEX = Regex("$IDENTIFIER_REGEX(?:\\.$IDENTIFIER_REGEX)*")
}
override fun run() {
@@ -149,9 +156,14 @@ class Zip : Runnable {
// Kotlin allows usage of reserved words in package names framing them
// with backquote symbol "`"
val packageName =
- line.substring(PACKAGE_SPACE.length).trim().replace(";", "").replace("`", "")
+ line
+ .removePrefix(PACKAGE_SPACE)
+ .substringBefore("//")
+ .trim()
+ .removeSuffix(";")
+ .replace(Regex("\\B`(.+?)`\\B"), "$1")
if (!PACKAGE_NAME_REGEX.matches(packageName)) {
- errors.add("${this} contains an invalid package name")
+ errors.add("$this contains an invalid package name")
return this.fileName
}
return Paths.get(packageName.replace(".", "/")).resolve(this.fileName)