11load ("//java/kotlin-extractor:versions.bzl" , "VERSIONS" , "version_less" )
2+ load ("//misc/bazel:lfs.bzl" , "lfs_smudge" )
23
34_kotlin_dep_build = """
45load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_import")
@@ -12,28 +13,12 @@ kt_jvm_import(
1213
1314_empty_zip = "PK\005 \006 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 \000 "
1415
15- _local_path = "{root}/resources/kotlin-dependencies/kotlin-{kind}-{version}.jar"
16- _maven_url = "https://repo1.maven.org/maven2/org/jetbrains/ kotlin/kotlin-{kind}/{version}/kotlin-{kind}-{version}.jar"
16+ def _get_dep ( repository_ctx , name ):
17+ return repository_ctx . path ( Label ( "//java/ kotlin-extractor/deps:%s" % name ))
1718
1819def _kotlin_dep_impl (repository_ctx ):
1920 _ , _ , name = repository_ctx .name .rpartition ("~" )
20- kind = repository_ctx .attr .kind
21- version = repository_ctx .attr .version
22- filename = "kotlin-%s-%s.jar" % (kind , version )
23- local_path = _local_path .format (root = repository_ctx .workspace_root , kind = kind , version = version )
24- if repository_ctx .path (local_path ).exists :
25- url = "file://%s" % local_path
26- else :
27- url = _maven_url .format (kind = kind , version = version )
28-
29- sha256 = VERSIONS [version ].get (kind , "" )
30- res = repository_ctx .download (url , output = filename , sha256 = sha256 )
31- if not sha256 :
32- fail ('\n Please add\n "%s": "%s",\n to VERSIONS["%s"] in java/kotlin-extractor/versions.bzl' % (
33- kind ,
34- res .sha256 ,
35- version ,
36- ))
21+ lfs_smudge (repository_ctx , [_get_dep (repository_ctx , name + ".jar" )])
3722
3823 # for some reason rules_kotlin warns about these jars missing, this is to silence those warnings
3924 repository_ctx .file ("empty.zip" , _empty_zip )
@@ -49,10 +34,6 @@ def _kotlin_dep_impl(repository_ctx):
4934
5035_kotlin_dep = repository_rule (
5136 implementation = _kotlin_dep_impl ,
52- attrs = {
53- "kind" : attr .string (),
54- "version" : attr .string (),
55- },
5637)
5738
5839def _walk (dir ):
@@ -140,7 +121,7 @@ _defaults = repository_rule(implementation = _defaults_impl)
140121def _kotlin_deps_impl (module_ctx ):
141122 for v in VERSIONS :
142123 for lib in ("compiler" , "compiler-embeddable" , "stdlib" ):
143- _kotlin_dep (name = "kotlin-%s-%s" % (lib , v ), kind = lib , version = v )
124+ _kotlin_dep (name = "kotlin-%s-%s" % (lib , v ))
144125 _embeddable_source (name = "codeql_kotlin_embeddable" )
145126 _defaults (name = "codeql_kotlin_defaults" )
146127 return module_ctx .extension_metadata (
0 commit comments