For building KotlinLab (GitHub - sterglee/KotlinLabSimple: A MATLAB-like scientific scripting environment for Kotlin, a simpler Kotlin only version of KotlinLab. Java 16 or newer is required to run KotlinLabSimple) I used a Kotlin Gradle DSL script that builds the .jar file but it fails to load (KotlinLab builds perfectly with the IntelliJ IDEA).
Can anyone Gradle expert detect the cause?
Below I paste my Kotlin DSL script:
plugins {
java
application
kotlin("jvm") version "1.5.31"
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(16))
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation(fileTree(“./lib/”))
implementation(fileTree(“./libkotlin/”))
}
application {
mainClassName = “kotlinLabExec.kotlinLab.kotlinLab”
}
sourceSets {
main {
java.srcDir(“src/”)
}
}
tasks.register(“uberJar”) {
archiveClassifier.set(“uber”)
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from( {
configurations.runtimeClasspath.get().filter {
it.name.endsWith("jar")}.map{ zipTree(it) }
})
}
var libpathfiles= StringBuilder();
File(“./lib”).walk().forEach {
e-> if (e.toString().trim().endsWith(“.jar”))
libpathfiles.append(e.toString().replaceFirst(“./”,“”).trim()).append(" ")
}
var kotlinlibpathfiles= StringBuilder();
File(“./libkotlin”).walk().forEach {
e-> if (e.toString().trim().endsWith(“.jar”))
kotlinlibpathfiles.append(e.toString().replaceFirst(“./”,“”).trim()).append(" ")
}
var allClassPath = libpathfiles.toString().trim()+ " "+kotlinlibpathfiles.toString().trim()
tasks.jar {
baseName = “kotlinLab”
manifest {
attributes["Class-Path"] = allClassPath.trim()
attributes["Main-Class"] = "kotlinLabExec.kotlinLab.kotlinLab"
}
}