Kotlin 在使用';多拉斯特';在梯度任务中
在Kotlin+Gradle+IntelliJ项目中,我注意到我可以使用Gradle.build中定义的以下任务之一运行\debug(命中断点)我的主类:Kotlin 在使用';多拉斯特';在梯度任务中,kotlin,debugging,gradle,intellij-idea,cucumber,Kotlin,Debugging,Gradle,Intellij Idea,Cucumber,在Kotlin+Gradle+IntelliJ项目中,我注意到我可以使用Gradle.build中定义的以下任务之一运行\debug(命中断点)我的主类: // debug works!! task debugTest1(type:JavaExec) { group = "Execution" description = "Run the main class with JavaExecTask" classpath = sourc
// debug works!!
task debugTest1(type:JavaExec) {
group = "Execution"
description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
main = "temp.Main"
}
// debug works!
task debugTest2() {
javaexec{
group = "Execution"
description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
main = "temp.Main"
}
}
但是,在添加“doLast”时,IntelliJ中的调试会运行,但会忽略断点:
// debug ignores breakpoint!
task debugTest3() {
doLast {
javaexec{
group = "Execution"
description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
main = "temp.Main"
}
}
}
我的build.gradle文件与此类似
plugins {
//id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'org.jetbrains.kotlin.jvm' version "1.4.20-RC"
}
group 'MY-COMPANY-GROUP'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
allprojects {
compileJava { options.encoding = "UTF-8" }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
我的临时主文件(Main.kt):
我的规格是:
- 爪哇:11
- 操作系统:Windows 10
- Intellij:Intellij IDEA 2020.2.3,10月6日构建
@file:JvmName("Main")
package temp
fun main(args: Array<String>) {
println("Hello World!")
Object.setProperties();
print("Object.setProperties() = ${Object.property1}")
}
task cucumber() {
dependsOn assemble, testClasses
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = [/*'--plugin','pretty', */
'--glue', 'COMPANY-PACKAGE.cucumber.steps', 'src/test/resources/features',
'--tags','not @inProgress']
}
}
}