我有以下简单的build.gradle文件:
apply plugin: 'java'
task foo(type: JavaExec) {
main = 'gradletest2.Main'
classpath = runtimeClasspath
}它在执行时会生成以下错误:
C:\Users\J\Documents\Development\eclipse-photon\gradletest2>gradle foo
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\J\Documents\Development\eclipse-photon\gradletest2\build.gradle' line: 17
* What went wrong:
A problem occurred evaluating root project 'gradletest2'.
> Could not get unknown property 'runtimeClasspath' for task ':foo' of type org.gradle.api.tasks.JavaExec.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s顺便说一句,主要是:
package gradletest2;
public class Main {
public static void main(String[] args) {
System.out.println("gradletest2");
}
}我为什么要犯这个错误?我正在https://youtu.be/OFUEb7pLLXw?t=2043的YT上跟踪一个正式的梯度教程视频,但不幸的是它已经很老了,所以我想知道这是否是现在不正确的语法。提前谢谢。
我用的是4.10.2级。
发布于 2018-10-04 21:40:06
runtimeClasspath是主sourceSet的一个属性。正确的语法是
classpath = sourceSets.main.runtimeClasspathhttps://stackoverflow.com/questions/52655374
复制相似问题