我已经尝试了几种使用JavaExec创建自定义任务的方法。我使用Gradle 8。
tasks {
val prepareDataset by creating(JavaExec::class) {
dependsOn("build")
// set the main class to be executed
mainClass.set("com.analytic.training.TrainingAppKt")
// set the arguments to pass to the main method (optional)
args("--arg1=value1", "--arg2=value2")
// set the classpath
// classpath(configurations.getByName("runtimeClasspath"))
// classpath(jvmRuntimeClasspath)
// set the task description
description = "Prepares the training dataset"
group = "training"
}
}
task<JavaExec>("prepareDataset2") {
dependsOn("build")
// set the main class to be executed
mainClass.set("com.analytic.training.TrainingAppKt")
// set the arguments to pass to the main method (optional)
args("--arg1=value1", "--arg2=value2")
// set the classpath
// classpath(configurations.getByName("runtimeClasspath"))
// classpath(jvmRuntimeClasspath)
classpath = java.sourceSets["main"].runtimeClasspath
// set the task description
description = "Prepares the training dataset"
group = "training"
}
两者都不行
Unable to find a single main class from the following candidates
[com.analytic.AnalyticApplicationKt, com.analytic.training.TrainingAppKt]
有什么想法吗
1条答案
按热度按时间drkbr07n1#
我把
dependsOn("build")
改成dependsOn("classes")
后就能用了,我觉得和spring Boot 冲突了。