2017-04-25 22 views
1

が存在するにもかかわらず、 "指定されていませんメインクラス":このJavaコードとGradleのメインクラスは、私はこのGradleのタスクを実行しようとし

task resources_cleaner_bl(type: JavaExec) { 
    classpath sourceSets.main.runtimeClasspath 
    systemProperties['cleanTarget'] = 'bl' 
    mainClassName = "com.w.routing.automation.runners.cleaner.ResourcesCleanerRunner" 
} 

package com.w.routing.automation.runners.cleaner; 

public class ResourcesCleanerRunner { 


    private static IResourcesCleaner resourcesCleaner; 
    private static Injector injector; 


    public static void main(String args[]) { 
     init(); 
     String cleanTarget = System.getProperty("cleanTarget"); 
     switch (cleanTarget) { 

をしかし、私はこのエラーを取得:

15:48:06.532 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 
15:48:06.533 [ERROR] [org.gradle.BuildExceptionReporter] 
15:48:06.549 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 
15:48:06.549 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':resources_cleaner_bl'. 
15:48:06.549 [ERROR] [org.gradle.BuildExceptionReporter] > No main class specified 
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter] 
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is: 
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':resources_cleaner_bl'. 
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 
15:48:06.551 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) 
15:48:06.551 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) 
15:48:06.551 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 
15:48:06.552 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) 
15:48:06.552 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 
15:48:06.553 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) 
15:48:06.553 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 
15:48:06.553 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) 
15:48:06.577 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) 
15:48:06.577 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43) 
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) 
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) 
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30) 
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154) 
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.internal.Factories$1.create(Factories.java:22) 
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) 
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52) 
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82) 
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94) 
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) 
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43) 
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) 
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75) 
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45) 
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51) 
15:48:06.582 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28) 
15:48:06.582 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43) 
15:48:06.582 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170) 
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127) 
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56) 
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalStateException: No main class specified 
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.process.internal.JavaExecHandleBuilder.build(JavaExecHandleBuilder.java:212) 
15:48:06.585 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:28) 
15:48:06.585 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:74) 
15:48:06.585 [ERROR] [org.gradle.BuildExceptionReporter]  at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) 

私は右の名前空間のメインクラスを持っているので、何が欠けていますか?

+0

編集修正:[このページ](https://docs.gradle.org/3.4.1/dsl/org.gradle.api.tasks.JavaExec.html)をしてみてください。古いコメント:ちょうど推測ですが、プラグインがほしいとは思いませんか?使用するプロパティは、タスクで使用できない場合があります。使用しているプラ​​グインについての情報を提供するためにbuild.gradleの詳細を追加しても構いませんか? – getjackx

答えて

0

JavaExecタスクでmainプロパティを使用する必要があります。 mainClassNameプロパティは存在しません。

task resources_cleaner_bl(type: JavaExec) { 
    classpath sourceSets.main.runtimeClasspath 
    systemProperties['cleanTarget'] = 'bl' 
    main = "com.w.routing.automation.runners.cleaner.ResourcesCleanerRunner" 
} 

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

関連する問題