Kotlin脚本Gradle:build.gradle.kts和ShadowJar

清理生成并运行:

thufir@dur:~/NetBeansProjects/kotlinShadowJar$ thufir@dur:~/NetBeansProjects/kotlinShadowJar$ gradle clean ShadowJar;java -jar build/libs/Hiya.jar > Task :compileKotlin Using Kotlin incremental compilation > Task :shadowJar A problem was found with the configuration of task ':shadowJar'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0. - No value has been specified for property 'mainClassName'. The SimpleWorkResult type has been deprecated and is scheduled to be removed in Gradle 5.0. Please use WorkResults.didWork() instead. BUILD SUCCESSFUL in 1s 3 actionable tasks: 3 executed Hello, world! thufir@dur:~/NetBeansProjects/kotlinShadowJar$ 

gradle构建文件:

 plugins { id 'com.gradle.build-scan' version '1.8' id 'java' id 'application' id "org.jetbrains.kotlin.jvm" version "1.1.51" id 'com.github.johnrengelman.shadow' version '2.0.1' } buildScan { licenseAgreementUrl = 'https://gradle.com/terms-of-service' licenseAgree = 'yes' //publishAlways() } repositories { jcenter() } sourceCompatibility = 1.8 targetCompatibility = 1.8 shadowJar { baseName = 'Hiya' classifier = null version = null } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.51" } mainClassName = 'foo.HelloWorldKt' 

科特林代码:

 package foo //import kotlin.jvm.JvmStatic //@JvmStatic fun main(args: Array) { println("Hello, world!") } 

我只是在检查Kotlin的确是按照预期的方法,用 Gradle中的ShadowJar插件来建立一个JAR 。 它做得很好。

如何将这个构建文件从Gradle DSL转换/翻译成Gradle脚本Kotlin ?