Skip to content

Commit d7ecaae

Browse files
committed
Kotlin: back off from lazy LFS rules
Those have shown to cause problems with too many concurrent downloads. This changes kotlinc dependencies fetching to: * use `resource/kotlinc-dependencies` if available (which is the case for the internal repo) * otherwise, download them from maven. This means sha256 hashes need to be written down for bazel.
1 parent a841a2b commit d7ecaae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+91
-133
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
/java/ql/test/stubs/**/*.java linguist-generated=true
5454
/java/ql/test/experimental/stubs/**/*.java linguist-generated=true
55-
/java/kotlin-extractor/deps/*.jar filter=lfs diff=lfs merge=lfs -text
5655

5756
# Force git not to modify line endings for go or html files under the go/ql directory
5857
/go/ql/**/*.go -text

java/kotlin-extractor/deps.bzl

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("//java/kotlin-extractor:versions.bzl", "VERSIONS", "version_less")
2-
load("//misc/bazel:lfs.bzl", "lfs_smudge")
32

43
_kotlin_dep_build = """
54
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_import")
@@ -16,9 +15,28 @@ _empty_zip = "PK\005\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000
1615
def _get_dep(repository_ctx, name):
1716
return repository_ctx.path(Label("//java/kotlin-extractor/deps:%s" % name))
1817

18+
_local_path = "{root}/resources/kotlin-dependencies/kotlin-{kind}-{version}.jar"
19+
_maven_url = "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-{kind}/{version}/kotlin-{kind}-{version}.jar"
20+
1921
def _kotlin_dep_impl(repository_ctx):
2022
_, _, name = repository_ctx.name.rpartition("~")
21-
lfs_smudge(repository_ctx, [_get_dep(repository_ctx, name + ".jar")])
23+
kind = repository_ctx.attr.kind
24+
version = repository_ctx.attr.version
25+
filename = "kotlin-%s-%s.jar" % (kind, version)
26+
local_path = _local_path.format(root = repository_ctx.workspace_root, kind = kind, version = version)
27+
if repository_ctx.path(local_path).exists:
28+
url = "file://%s" % local_path
29+
else:
30+
url = _maven_url.format(kind = kind, version = version)
31+
32+
sha256 = VERSIONS[version].get(kind, "")
33+
res = repository_ctx.download(url, output = filename, sha256 = sha256)
34+
if not sha256:
35+
fail('\nPlease add\n "%s": "%s",\nto VERSIONS["%s"] in java/kotlin-extractor/versions.bzl' % (
36+
kind,
37+
res.sha256,
38+
version,
39+
))
2240

2341
# for some reason rules_kotlin warns about these jars missing, this is to silence those warnings
2442
repository_ctx.file("empty.zip", _empty_zip)
@@ -34,6 +52,10 @@ def _kotlin_dep_impl(repository_ctx):
3452

3553
_kotlin_dep = repository_rule(
3654
implementation = _kotlin_dep_impl,
55+
attrs = {
56+
"kind": attr.string(),
57+
"version": attr.string(),
58+
},
3759
)
3860

3961
def _walk(dir):
@@ -121,7 +143,7 @@ _defaults = repository_rule(implementation = _defaults_impl)
121143
def _kotlin_deps_impl(module_ctx):
122144
for v in VERSIONS:
123145
for lib in ("compiler", "compiler-embeddable", "stdlib"):
124-
_kotlin_dep(name = "kotlin-%s-%s" % (lib, v))
146+
_kotlin_dep(name = "kotlin-%s-%s" % (lib, v), kind = lib, version = v)
125147
_embeddable_source(name = "codeql_kotlin_embeddable")
126148
_defaults(name = "codeql_kotlin_defaults")
127149
return module_ctx.extension_metadata(

java/kotlin-extractor/deps/BUILD.bazel

Whitespace-only changes.

java/kotlin-extractor/deps/LICENSE.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

java/kotlin-extractor/deps/kotlin-compiler-1.5.0.jar

Lines changed: 0 additions & 3 deletions
This file was deleted.

java/kotlin-extractor/deps/kotlin-compiler-1.5.10.jar

Lines changed: 0 additions & 3 deletions
This file was deleted.

java/kotlin-extractor/deps/kotlin-compiler-1.5.20.jar

Lines changed: 0 additions & 3 deletions
This file was deleted.

java/kotlin-extractor/deps/kotlin-compiler-1.5.30.jar

Lines changed: 0 additions & 3 deletions
This file was deleted.

java/kotlin-extractor/deps/kotlin-compiler-1.6.0.jar

Lines changed: 0 additions & 3 deletions
This file was deleted.

java/kotlin-extractor/deps/kotlin-compiler-1.6.20.jar

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)