Skip to content

Commit d9f65fe

Browse files
committed
Handle missing kotlinc gracefully
1 parent f918b2e commit d9f65fe

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

java/kotlin-extractor/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def compile_standalone(version):
201201
'build/temp_src',
202202
version)
203203

204+
if shutil.which(kotlinc) == None:
205+
print("Cannot build the Kotlin extractor: no '%s' found on your PATH" % kotlinc, file = sys.stderr)
206+
sys.exit(1)
207+
204208
if args.many:
205209
for version in kotlin_plugin_versions.many_versions:
206210
compile_standalone(version)

java/kotlin-extractor/kotlin_plugin_versions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ def version_string_to_tuple(version):
2222

2323
many_versions_tuples = [version_string_to_tuple(v) for v in many_versions]
2424

25+
class KotlincNotFoundException(Exception):
26+
pass
27+
2528
def get_single_version(fakeVersionOutput = None):
2629
# TODO: `shell=True` is a workaround to get CI working on Windows. It breaks the build on Linux.
27-
versionOutput = subprocess.run(['kotlinc', '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=is_windows()).stderr if fakeVersionOutput is None else fakeVersionOutput
30+
try:
31+
versionOutput = subprocess.run(['kotlinc', '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=is_windows()).stderr if fakeVersionOutput is None else fakeVersionOutput
32+
except FileNotFoundError as e:
33+
raise KotlincNotFoundException(e)
2834
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.[0-9]+) .*', versionOutput)
2935
if m is None:
3036
raise Exception('Cannot detect version of kotlinc (got ' + str(versionOutput) + ')')

0 commit comments

Comments
 (0)