Skip to content

Commit

Permalink
Merge pull request #384 from themkat/snap_install_stdlib
Browse files Browse the repository at this point in the history
Resolve kotlin-stdlib.jar from snap install
  • Loading branch information
fwcd authored Sep 13, 2022
2 parents eef14bd + 4219851 commit 81b6b4c
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ object BackupClassPathResolver : ClassPathResolver {
fun findKotlinStdlib(): Path? =
findLocalArtifact("org.jetbrains.kotlin", "kotlin-stdlib")
?: findKotlinCliCompilerLibrary("kotlin-stdlib")
?: findAlternativeLibraryLocation("kotlin-stdlib")

private fun findLocalArtifact(group: String, artifact: String) =
tryResolving("$artifact using Maven") { tryFindingLocalArtifactUsing(group, artifact, findLocalArtifactDirUsingMaven(group, artifact)) }
Expand Down Expand Up @@ -70,6 +71,11 @@ private fun findKotlinCliCompilerLibrary(name: String): Path? =
?.orElse(null)


// alternative library locations like for snap
// (can probably just use elvis operator and multiple similar expressions for other install directories)
private fun findAlternativeLibraryLocation(name: String): Path? =
Paths.get("/snap/kotlin/current/lib/${name}.jar").existsOrNull()

private fun Path.existsOrNull() =
if (Files.exists(this)) this else null

Expand Down

0 comments on commit 81b6b4c

Please sign in to comment.