正确的方式从gradle任务运行kotlin应用程序

我有简单的脚本

package com.lapots.game.journey.ims.example fun main(args: Array) { println("Hello, world!") } 

这里是gradle任务

 task runExample(type: JavaExec) { main ='com.lapots.game.journey.ims.example.Example' classpath = sourceSets.main.runtimeClasspath } 

但是,当我尝试运行任务gradle runExample我得到错误

Error: Could not find or load main class com.lapots.game.journey.ims.example.Example

什么是运行应用程序的正确方法?

感谢链接如何在Kotlin中运行编译的类文件? 由@JaysonMinard提供的main

 @file:JvmName("Example") package com.lapots.game.journey.ims.example fun main(args: Array) { print("executable!") } 

和那个task

 task runExample(type: JavaExec) { main = 'com.lapots.game.journey.ims.example.Example' classpath = sourceSets.main.runtimeClasspath } 

做的伎俩