Why test task always executed?

I have a task like the following:

task euaTest(type: Test) << {
    useTestNG()
    testLogging.showStandardStreams = true
      // clean all the data in database
    tasks.cleandb.execute()
      // insert init data into databse
    tasks.run.execute()
      // deploy war file to weblogic
    tasks.deploy.execute()
      // start weblogic
    tasks.startWLS.execute()
      // explicitly include tests
    include 'oracle/emceuas/mapreduce/**'
    include 'oracle/emceuas/ws/**'
      // stop weblogic
    euaTest << {
        tasks.stopWLS.execute()
    }
}

when I tried to install weblogic, it always execute this euaTask even when I use ‘-x euaTest’. And because the ‘tasks.deploy.execute()’ will deploy a war file into weblogic, it fails every time.

I checked the debug output, the exception throws right after DependencyGraphBuilder.

My question is what will the DependencyGraphBuilder do? Why the ‘euaTest’ executed even when I use ‘-x euaTest’ to exclude it?

Here’s the full trace log:

01:47:54.521 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'com.oracle.emaas.emdi:bugVistaOraHubRepo:1.0.0-201410142122:bugVistaOraHubRepo.txt' in resolver cache: /home/rbrouwer/.gradle/caches/modules-2/files-2.1/com.oracle.emaas.emdi/bugVistaOraHubRepo/1.0.0-201410142122/8a7787bbcf38653bfd7433a4eedd09fe79ccdf47/bugVistaOraHubRepo-1.0.0-201410142122.txt
01:47:54.572 [ERROR] [org.gradle.BuildExceptionReporter]
 01:47:54.576 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
01:47:54.581 [ERROR] [org.gradle.BuildExceptionReporter]
 01:47:54.585 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
01:47:54.589 [ERROR] [org.gradle.BuildExceptionReporter] Build file '/scratch/rbrouwer/emceuas/eua/build.gradle' line: 111
01:47:54.593 [ERROR] [org.gradle.BuildExceptionReporter]
 01:47:54.597 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
01:47:54.601 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':deploy'.
01:47:54.604 [ERROR] [org.gradle.BuildExceptionReporter] > Process 'command 'ln'' finished with non-zero exit value 1
01:47:54.612 [ERROR] [org.gradle.BuildExceptionReporter]
 01:47:54.616 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
01:47:54.620 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':deploy'.
01:47:54.624 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
01:47:54.629 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
01:47:54.639 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
01:47:54.643 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
01:47:54.647 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
01:47:54.650 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
01:47:54.654 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
01:47:54.658 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
01:47:54.665 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
01:47:54.667 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
01:47:54.670 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:284)
01:47:54.672 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.TaskInternal$execute.call(Unknown Source)
01:47:54.674 [ERROR] [org.gradle.BuildExceptionReporter]
      at build_ltjbiinpj3omntqqo3b1v3q1a$_run_closure9.doCall(/scratch/rbrouwer/emceuas/eua/build.gradle:111)
01:47:54.680 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
01:47:54.682 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
01:47:54.689 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:110)
01:47:54.691 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:439)
01:47:54.692 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.AbstractProject.task(AbstractProject.java:948)
01:47:54.694 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:225)
01:47:54.695 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:129)
01:47:54.695 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
01:47:54.696 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
01:47:54.697 [ERROR] [org.gradle.BuildExceptionReporter]
      at build_ltjbiinpj3omntqqo3b1v3q1a.run(/scratch/rbrouwer/emceuas/eua/build.gradle:98)
01:47:54.698 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
01:47:54.698 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:152)
01:47:54.699 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:40)
01:47:54.700 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
01:47:54.701 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
01:47:54.701 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
01:47:54.702 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:493)
01:47:54.703 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:80)
01:47:54.704 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
01:47:54.704 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
01:47:54.705 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
01:47:54.706 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
01:47:54.707 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
01:47:54.707 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
01:47:54.723 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
01:47:54.724 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
01:47:54.724 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
01:47:54.725 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
01:47:54.725 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
01:47:54.726 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
01:47:54.726 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
01:47:54.730 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
01:47:54.731 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
01:47:54.731 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
01:47:54.732 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
01:47:54.734 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.Main.doAction(Main.java:46)
01:47:54.736 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
01:47:54.737 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.Main.main(Main.java:37)
01:47:54.738 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
01:47:54.741 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
01:47:54.744 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
01:47:54.756 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.process.internal.ExecException: Process 'command 'ln'' finished with non-zero exit value 1
01:47:54.760 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)
01:47:54.763 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.process.internal.DefaultExecAction.execute(DefaultExecAction.java:31)
01:47:54.769 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.tasks.Exec.exec(Exec.java:63)
01:47:54.771 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
01:47:54.774 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
01:47:54.776 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
01:47:54.782 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
01:47:54.784 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
01:47:54.786 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
01:47:54.788 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
01:47:54.792 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
01:47:54.794 [ERROR] [org.gradle.BuildExceptionReporter]
      ... 53 more
01:47:54.801 [ERROR] [org.gradle.BuildExceptionReporter]
 01:47:54.803 [LIFECYCLE] [org.gradle.BuildResultLogger]
 01:47:54.806 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
01:47:54.809 [LIFECYCLE] [org.gradle.BuildResultLogger]
 01:47:54.811 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 55.997 secs

‘TaskInternal#execute’ is an internal method that should never be called from user code. Instead you should add task relationships such as ‘euaTest.dependsOn(cleanDb)’ and ‘euaTest.finalizedBy(stopWLS)’. Also, task configuration such as ‘include …’ and ‘dependsOn …’ needs to happen in the configuration phase, i.e. without ‘<<’.

That really is the cause of my problem. Use dependsOn instead of TaskInternal#execute fix my problem. I don’t recall which exact page I get this method, what I’m sure is I was fixing some other problem while searching by google and get the method, which you mention as internal method. I think it might be good to make it inaccessible if you don’t want user code refer it. :slight_smile:

Thanks a lot!