Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc62ed5

Browse files
committed
Kotlin/Bazel: port custom_plugin test to use bazel
1 parent 3d14654 commit fc62ed5

3 files changed

Lines changed: 47 additions & 55 deletions

File tree

java/ql/integration-tests/linux-only/kotlin/custom_plugin/build_plugin

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("@codeql_kotlin_defaults//:defaults.bzl", "kotlin_extractor_defaults")
2+
load("@rules_kotlin//kotlin:core.bzl", "kt_kotlinc_options")
3+
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
4+
load("//java/kotlin-extractor:versions.bzl", "get_language_version")
5+
6+
_version = kotlin_extractor_defaults.extractor_version
7+
8+
kt_kotlinc_options(
9+
name = "kotlinc-options",
10+
include_stdlibs = "none",
11+
jvm_target = "1.8",
12+
language_version = get_language_version(_version),
13+
)
14+
15+
kt_jvm_library(
16+
name = "plugin",
17+
srcs = ["Plugin.kt"],
18+
kotlinc_opts = ":kotlinc-options",
19+
module_name = "test",
20+
resource_strip_prefix = "%s/resources" % package_name(),
21+
resources = glob(["resources/**"]),
22+
deps = [
23+
"@kotlin-compiler-%s" % _version,
24+
"@kotlin-stdlib-%s" % _version,
25+
],
26+
)
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
from create_database_utils import *
2-
import subprocess
32

4-
subprocess.call("./build_plugin", shell=True)
3+
import pathlib
4+
import shutil
5+
6+
this_dir = pathlib.Path(__file__).resolve().parent
7+
cwd = pathlib.Path.cwd()
8+
builddir = cwd / 'build'
9+
10+
builddir.mkdir(exist_ok=True)
11+
12+
try:
13+
runSuccessfully(['bazel', f'--output_user_root={builddir}', '--max_idle_secs=1', 'build',
14+
'//java/ql/integration-tests/linux-only/kotlin/custom_plugin/plugin', '--spawn_strategy=local',
15+
'--nouse_action_cache', '--noremote_accept_cached', '--noremote_upload_local_results',
16+
f'--symlink_prefix={cwd / "bazel-"}'], cwd=this_dir)
17+
finally:
18+
# rules_python creates a read-only directory in bazel's output, this allows cleanup to succeed
19+
runSuccessfully(['chmod', '-R', '+w', builddir])
20+
21+
shutil.copy(
22+
'bazel-bin/java/ql/integration-tests/linux-only/kotlin/custom_plugin/plugin/plugin.jar', 'plugin.jar')
23+
524
run_codeql_database_create(
625
["kotlinc -J-Xmx2G -Xplugin=plugin.jar a.kt b.kt c.kt d.kt e.kt"], lang="java")

0 commit comments

Comments
 (0)