Skip to content

Commit

Permalink
fix: transparently add kotlin-stdlib to the deps based on the configu…
Browse files Browse the repository at this point in the history
…red kotlin version

feat: update the default kotlin version
fix: remove the trailing ; in the kotlin template
  • Loading branch information
evanchooly authored and maxandersen committed Aug 13, 2024
1 parent 3797d78 commit 6e342c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/dev/jbang/net/KotlinManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public class KotlinManager {
private static final String KOTLIN_DOWNLOAD_URL = "https://github.com/JetBrains/kotlin/releases/download/v%s/kotlin-compiler-%s.zip";
public static final String DEFAULT_KOTLIN_VERSION = "1.8.22";
public static final String DEFAULT_KOTLIN_VERSION = "2.0.0";

public static String resolveInKotlinHome(String cmd, String requestedVersion) {
Path kotlinHome = getKotlin(requestedVersion);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/dev/jbang/source/sources/KotlinSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public KotlinSource(String script, Function<String, String> replaceProperties) {
super(script, replaceProperties);
}

@Override
protected List<String> collectBinaryDependencies() {
final List<String> allDependencies = super.collectBinaryDependencies();
allDependencies.add("org.jetbrains.kotlin:kotlin-stdlib:" + getKotlinVersion());
return allDependencies;
}

@Override
protected List<String> getCompileOptions() {
return tagReader.collectOptions("COMPILE_OPTIONS");
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/init-hello.kt.qute
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
///usr/bin/env jbang "$0" "$@" ; exit $?

{#for dep in dependencies.orEmpty}
//DEPS {dep}
{/for}
Expand All @@ -8,6 +9,6 @@
{magiccontent}
{#else}
public fun main() {
println("Hello World");
println("Hello World")
}
{/if}

0 comments on commit 6e342c9

Please sign in to comment.