如何导入Kotlin(Gradle)构建的ShadowJar插件?

构建失败:

thufir@dur:~/NetBeansProjects/kotlin_dsl$ thufir@dur:~/NetBeansProjects/kotlin_dsl$ gradle clean run > Configure project : e: /home/thufir/NetBeansProjects/kotlin_dsl/build.gradle.kts:4:12: Unresolved reference: github FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'kotlin_dsl'. > Could not open cache directory 74ykawxta6db3b2bfk9grjikp (/home/thufir/.gradle/caches/4.3.1/gradle-kotlin-dsl/74ykawxta6db3b2bfk9grjikp). > Internal error: unable to compile script, see log for details * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 1s thufir@dur:~/NetBeansProjects/kotlin_dsl$ 

有问题的import声明:

 thufir@dur:~/NetBeansProjects/kotlin_dsl$ thufir@dur:~/NetBeansProjects/kotlin_dsl$ cat build.gradle.kts import org.gradle.api.JavaVersion import org.gradle.kotlin.dsl.* import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { application kotlin("jvm") version "1.1.51" } application { mainClassName = "samples.HelloWorldKt" } dependencies { compile(kotlin("stdlib")) } repositories { jcenter() } thufir@dur:~/NetBeansProjects/kotlin_dsl$ 

如上所述去除Shadow的导入可以实现干净的构建和运行。 Shadow插件JAR如何提供给Kotlin导入?

Gradle本身使用DSL创建了Shadow JAR。

从不同的角度来看这个:

Kotlin与ShadowJar结合Gradle:gradle.build.kt

与一个工作生成文件。