@Override public void executeNode() throws Exception { String digest = FileUtil.getDigest(getSourceFiles()); super.executeNode(); _writeSourceDigestFile(digest.getBytes(StandardCharsets.UTF_8)); }
@OutputFile public File getSourceDigestFile() { Project project = getProject(); String pathname = "npm/" + getNpmCommand() + "/" + getName() + "/.digest"; return new File(project.getBuildDir(), pathname); }
private void _writeSourceDigestFile(byte[] bytes) throws Exception { File file = getSourceDigestFile(); File dir = file.getParentFile(); if (dir != null) { Files.createDirectories(dir.toPath()); } Files.write(file.toPath(), bytes); }
@InputFiles @Optional public FileCollection getSourceFiles() { File sourceDir = getSourceDir(); if ((sourceDir == null) || !sourceDir.exists()) { return null; } Project project = getProject(); FileTree fileTree = project.fileTree(sourceDir); FileCollection fileCollection = fileTree.matching(_patternFilterable); if (fileCollection.isEmpty()) { return null; } return fileCollection; }
@Override protected List<String> getCompleteArgs() { List<String> completeArgs = super.getCompleteArgs(); completeArgs.add(getNpmCommand()); completeArgs.add(getDependencyName()); return completeArgs; }
@Input @Optional public File getSourceDir() { return GradleUtil.toFile(getProject(), _sourceDir); }
@Override protected List<String> getCompleteArgs() { List<String> completeArgs = super.getCompleteArgs(); completeArgs.add(getNpmCommand()); completeArgs.add(getScriptName()); return completeArgs; }