Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle issue: Using the incremental task API without declaring any outputs has been deprecated. #427

Closed
ZacSweers opened this issue Aug 6, 2019 · 3 comments · Fixed by #434

Comments

@ZacSweers
Copy link
Contributor

Gradle 5.5.1
Spotless 3.24.0
MacOS 10.14.6
Github repo: https://github.com/zacsweers/catchup

Full trace reported from gradle below. Unfortunately it doesn't say where the issue is from in code, just that it occurs when running the spotlessKotlin task on any project that applies it

Warning deprecated usage found: Using the incremental task API without declaring any outputs has been deprecated.

org.gradle.api.internal.changedetection.changes.DefaultTaskExecutionModeResolver.getExecutionMode(DefaultTaskExecutionModeResolver.java:46)
org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:67)
org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
java.base/java.lang.Thread.run(Thread.java:834)
@nedtwigg
Copy link
Member

nedtwigg commented Aug 6, 2019

Thanks for finding this! Each SpotlessTask already has one synthetic output file, e.g. for java it is build/spotlessJava, which we write to on every run.

/** Internal use only. */
@InputFiles
@Deprecated
public Iterable<File> getInternalTarget() {
// used to combine the special cache file and the real target
return Iterables.concat(ImmutableList.of(getCacheFile()), target);
}
private File getCacheFile() {
return new File(getProject().getBuildDir(), getName());
}

We could easily list this file as an output, but the trick is we also need to list it as an input (it fixes a tricky up-to-date corner-case, described here). If having this file as both an input and an output triggers their warnings (which would be reasonable), then we can just make another synthetic output and list that as our output.

Until these deprecated warnings become errors, this won't be high on my todo list. Happy to merge a PR before then, or I'll get to it when it becomes urgent.

@ZacSweers
Copy link
Contributor Author

I'll see what I can do as a PR 👍. They're not errors, but they do warn on every build in gradle 5.x+

@nedtwigg
Copy link
Member

Released in 3.24.2

tiembo pushed a commit to android/sunflower that referenced this issue Jun 15, 2020
…puts to incremental task"

Previous version was 3.24.0. When building, it produced the following exception:

```bash
$ ./gradlew build

> Configure project :app

> Task :spotlessKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':spotlessKotlin'.
> You must declare outputs or use `TaskOutputs.upToDateWhen()` when using the incremental task API
```

This issue was fixed in Spotless 3.24.2 as per [Issue #427](diffplug/spotless#427).
I optimistically upgraded to the latest release (4.3.0, June 2020). There are also higher minor releases
(3.30.0, May 2020) and patch releases (3.24.3, Sep 2019) available in
[mvnrepository](https://mvnrepository.com/artifact/com.diffplug.spotless/spotless-plugin-gradle) as
alternatives. The build passes on all three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants