Gradle-无法找到或加载主类src.main.java.Test

Gradle-无法找到或加载主类src.main.java.Test,gradle,Gradle,我有下面的文件夹结构,想玩gradle测试 在开始任何测试之前,我想看看有哪些任务可用 ------------------------------------------------------------ All tasks runnable from root project ------------------------------------------------------------ Build tasks ----------- assemble - Assembles

我有下面的文件夹结构,想玩gradle测试

在开始任何测试之前,我想看看有哪些任务可用

------------------------------------------------------------
 All tasks runnable from root project
------------------------------------------------------------

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that   
depend on it.
buildNeeded - Assembles and tests this project and all projects it depends   
on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root   
project 'GradleTesting'.
components - Displays the components produced by root project   
'GradleTesting'. [incubating]
dependencies - Displays all dependencies declared in root project   
'GradleTesting'.
dependencyInsight - Displays the insight into a specific dependency in root    
project 'GradleTesting'.
help - Displays a help message.
model - Displays the configuration model of root project 'GradleTesting'.    
[incubating]
projects - Displays the sub-projects of root project 'GradleTesting'.
properties - Displays the properties of root project 'GradleTesting'.
tasks - Displays the tasks runnable from root project 'GradleTesting'.

Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

Other tasks
-----------
execute
所以我知道gradle没有任何问题。现在我在build.gradle文件中编写这段代码

apply plugin: 'java'

task execute(type: JavaExec) {
//This line throws me an exception.
main = "src.main.java.Test"
classpath = sourceSets.main.runtimeClasspath
}

并得到这个信息

$ gradle execute
:compileJava
:processResources UP-TO-DATE
:classes
:executeError: Could not find or load main class src.main.java.Test
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':execute'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe''   
finished with non-zero exit value 1
有没有办法修复这个错误


谢谢。

'src/main/java'是指向java文件的文件系统路径。 包名称从这里开始

如果没有包名称,则完全限定类名为“Test”,因此,将build.gradle更改为:

apply plugin: 'java'

task execute(type: JavaExec) {
    main = 'Test'
    classpath = sourceSets.main.runtimeClasspath
}