Skip to content

Commit

Permalink
[Gradle] Make DependencyLicensesTask cacheable (elastic#110110)
Browse files Browse the repository at this point in the history
  • Loading branch information
breskeby authored Jun 24, 2024
1 parent 208711b commit d8ff997
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
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.InputDirectory;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.TaskAction;

import java.io.File;
Expand Down Expand Up @@ -89,6 +92,7 @@
* for the dependency. This artifact will be redistributed by us with the release to
* comply with the license terms.
*/
@CacheableTask
public abstract class DependencyLicensesTask extends DefaultTask {

private final Pattern regex = Pattern.compile("-v?\\d+.*");
Expand Down Expand Up @@ -148,7 +152,7 @@ public DependencyLicensesTask(ObjectFactory objects, ProjectLayout projectLayout
licensesDir = objects.directoryProperty().convention(projectLayout.getProjectDirectory().dir("licenses"));
}

@InputFiles
@Classpath
public FileCollection getDependencies() {
return dependencies;
}
Expand All @@ -159,6 +163,7 @@ public void setDependencies(FileCollection dependencies) {

@Optional
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
public File getLicensesDir() {
File asFile = licensesDir.get().getAsFile();
if (asFile.exists()) {
Expand Down

0 comments on commit d8ff997

Please sign in to comment.