Skip to content

Commit 26020c3

Browse files
author
ntwigg
committed
Tasks which declare outputs are now automatically cached.
1 parent 262ca2b commit 26020c3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Webtools releases
22

33
## [Unreleased]
4+
### Fixed
5+
- Tasks which declare outputs are now automatically cached.
46

57
## [1.2.5] - 2025-08-20
68
### Fixed

src/main/java/com/diffplug/webtools/node/NodePlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,18 @@ public TaskProvider<?> npm_run(String name, Action<NpmRunTask> taskConfig) {
6161

6262
task.getSetup().set(setup);
6363
task.getProjectDir().set(project.getProjectDir());
64+
task.getInputs().file("package.json").withPathSensitivity(PathSensitivity.RELATIVE);
6465
task.getInputs().file("package-lock.json").withPathSensitivity(PathSensitivity.RELATIVE);
6566

6667
task.getInputs().property("nodeVersion", setup.nodeVersion);
6768
task.getInputs().property("npmVersion", setup.npmVersion);
6869
taskConfig.execute(task);
70+
task.getOutputs().cacheIf(spec -> !task.getOutputs().getFiles().isEmpty());
6971
});
7072
}
7173
}
7274

73-
@DisableCachingByDefault(because = "Runs external 'npm run' and produces undeclared outputs; not safely cacheable")
75+
@DisableCachingByDefault(because = "Add `outputs.[dir|file](...)` (and necessary inputs) in the configuration block to enable caching.")
7476
public abstract static class NpmRunTask extends DefaultTask {
7577
public String npmTaskName;
7678
private TreeMap<String, String> environment = new TreeMap<>();

0 commit comments

Comments
 (0)