2016-09-08 4 views
1

다음 폴더 구조를 가지고 있으며 그라디언트 테스트를하고 싶습니다. 내가 작업을 사용할 수 있는지보고 싶어 어떤 테스트를 시작하기 전에Gradle - 메인 클래스 src.main.java.Test를 찾을 수 없거나로드 할 수 없습니다.

Eclipse Image

.

------------------------------------------------------------ 
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 

이 오류를 해결하는 방법에 대한 아이디어가 있으십니까?

감사합니다.

답변

2

'src/main/java'는 java 파일에 대한 파일 시스템 경로입니다. 패키지 이름이 여기에서 시작됩니다.

apply plugin: 'java' 

task execute(type: JavaExec) { 
    main = 'Test' 
    classpath = sourceSets.main.runtimeClasspath 
} 
: 어떤 패키지 이름이없는 사용자의 경우

는 완전한 클래스 이름은 그래서, 당신의 build.gradle 변경 "테스트"입니다

관련 문제