Skip to content

Commit

Permalink
Remove TaskInternal.execute
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfs committed Aug 14, 2018
1 parent 75bee28 commit 6521f6c
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 73 deletions.
Expand Up @@ -49,7 +49,6 @@
import org.gradle.api.internal.tasks.TaskLocalStateInternal;
import org.gradle.api.internal.tasks.TaskMutator;
import org.gradle.api.internal.tasks.TaskStateInternal;
import org.gradle.api.internal.tasks.execution.DefaultTaskExecutionContext;
import org.gradle.api.internal.tasks.execution.TaskValidator;
import org.gradle.api.internal.tasks.properties.PropertyWalker;
import org.gradle.api.logging.Logger;
Expand Down Expand Up @@ -377,19 +376,6 @@ public Path getIdentityPath() {
return identity.identityPath;
}

@Override
public final void execute() {
DeprecationLogger.nagUserOfDiscontinuedMethod("TaskInternal.execute()", getReuseTaskLogicAdvice());
TaskExecuter executer = DeprecationLogger.whileDisabled(new Factory<TaskExecuter>() {
@Override
public TaskExecuter create() {
return getExecuter();
}
});
executer.execute(this, _state, new DefaultTaskExecutionContext());
_state.rethrowFailure();
}

@Override
public TaskExecuter getExecuter() {
DeprecationLogger.nagUserOfDiscontinuedProperty("TaskInternal.executer", getReuseTaskLogicAdvice());
Expand Down
Expand Up @@ -50,9 +50,6 @@ public interface TaskInternal extends Task, Configurable<Task> {
@Internal
Spec<? super TaskInternal> getOnlyIf();

@Deprecated
void execute();

@Internal
@SuppressWarnings("deprecation")
StandardOutputCapture getStandardOutputCapture();
Expand Down
Expand Up @@ -42,14 +42,10 @@ public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionCon
if (!task.hasTaskActions()) {
LOGGER.info("Skipping {} as it has no actions.", task);
boolean upToDate = true;
// FIXME: When TaskInternal.execute is removed, the task has to be part of the task graph when it is executed.
// Then we can remove this check.
if (taskExecutionGraph.hasTask(task)) {
for (Task dependency : taskExecutionGraph.getDependencies(task)) {
if (!dependency.getState().getSkipped()) {
upToDate = false;
break;
}
for (Task dependency : taskExecutionGraph.getDependencies(task)) {
if (!dependency.getState().getSkipped()) {
upToDate = false;
break;
}
}
state.setActionable(false);
Expand Down
Expand Up @@ -18,7 +18,6 @@ package org.gradle.testfixtures

import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.internal.TaskInternal
import org.gradle.api.internal.project.DefaultProject
import org.gradle.test.fixtures.file.TestNameTestDirectoryProvider
import org.gradle.util.Resources
Expand Down Expand Up @@ -164,18 +163,6 @@ class ProjectBuilderTest extends Specification {
noExceptionThrown()
latch.get()
}

@Issue("https://github.com/gradle/gradle/issues/5396")
def "can run task by calling TaskInternal.execute()"() {
def project = buildProject()
TaskInternal task = project.task('custom', type: CustomTask)

when:
task.execute()

then:
noExceptionThrown()
}
}


Expand Up @@ -27,9 +27,6 @@ import org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFacto
import org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore
import org.gradle.api.internal.project.taskfactory.ITaskFactory
import org.gradle.api.internal.project.taskfactory.TaskFactory
import org.gradle.api.internal.tasks.TaskExecuter
import org.gradle.api.internal.tasks.TaskExecutionContext
import org.gradle.api.internal.tasks.TaskStateInternal
import org.gradle.api.specs.Spec
import org.gradle.internal.Actions
import org.gradle.internal.MutableBoolean
Expand Down Expand Up @@ -142,19 +139,6 @@ abstract class AbstractSpockTaskTest extends AbstractProjectBuilderSpec {
thrown(InvalidUserDataException)
}

def testExecuteDelegatesToTaskExecuter() {
final AbstractTask task = getTask()
TaskExecuter executer = Mock()
task.setExecuter(executer)

when:
task.execute()

then:
1 * executer.execute(task, _ as TaskStateInternal, _ as TaskExecutionContext)

}

def setGetDescription() {
when:
String testDescription = "testDescription"
Expand Down
Expand Up @@ -733,25 +733,6 @@ task someTask(dependsOn: [someDep, someOtherDep])
succeeds "custom", "--rerun-tasks"
}

def "calling `Task.execute()` is deprecated"() {
buildFile << """
task myTask
task executer {
doLast {
myTask.execute()
}
}
"""

when:
executer.expectDeprecationWarning()
succeeds "executer"

then:
output.contains("The TaskInternal.execute() method has been deprecated. This is scheduled to be removed in Gradle 5.0. There are better ways to re-use task logic, see ")
}

def "#description `Task.executer` is deprecated"() {
buildFile << """
task myTask
Expand Down

0 comments on commit 6521f6c

Please sign in to comment.