Skip to content

Commit

Permalink
Cacheability improvements for thirdparty audit task (#42085)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira authored May 15, 2019
1 parent c59da59 commit 03e53e8
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
import org.gradle.api.file.FileTree;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SkipWhenEmpty;
Expand All @@ -45,6 +47,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
Expand Down Expand Up @@ -113,14 +116,19 @@ public void setJavaHome(String javaHome) {
this.javaHome = javaHome;
}

@OutputDirectory
@Internal
public File getJarExpandDir() {
return new File(
new File(getProject().getBuildDir(), "precommit/thirdPartyAudit"),
getName()
);
}

@OutputFile
public File getSuccessMarker() {
return new File(getProject().getBuildDir(), "markers/" + getName());
}

public void ignoreMissingClasses(String... classesOrPackages) {
if (classesOrPackages.length == 0) {
missingClassExcludes = null;
Expand Down Expand Up @@ -157,8 +165,7 @@ public Set<String> getMissingClassExcludes() {
return missingClassExcludes;
}

@InputFiles
@PathSensitive(PathSensitivity.NAME_ONLY)
@Classpath
@SkipWhenEmpty
public Set<File> getJarsToScan() {
// These are SelfResolvingDependency, and some of them backed by file collections, like the Gradle API files,
Expand Down Expand Up @@ -241,6 +248,10 @@ public void runThirdPartyAudit() throws IOException {
}

assertNoJarHell(jdkJarHellClasses);

// Mark successful third party audit check
getSuccessMarker().getParentFile().mkdirs();
Files.write(getSuccessMarker().toPath(), new byte[]{});
}

private void logForbiddenAPIsOutput(String forbiddenApisOutput) {
Expand Down

0 comments on commit 03e53e8

Please sign in to comment.