From 846ad202a03511f17e03afb9d0dc63837aa28a78 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Tue, 19 Nov 2024 15:06:58 +0100 Subject: [PATCH] declare task output --- .../plugins/autodoc/tasks/AbstractManifestResolveTask.java | 7 +++++++ .../edc/plugins/autodoc/tasks/DependencySource.java | 5 ----- .../edc/plugins/autodoc/tasks/DownloadManifestTask.java | 5 ++--- .../org/eclipse/edc/plugins/autodoc/tasks/FileSource.java | 4 +++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/AbstractManifestResolveTask.java b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/AbstractManifestResolveTask.java index 22e7ba1..3d41fc0 100644 --- a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/AbstractManifestResolveTask.java +++ b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/AbstractManifestResolveTask.java @@ -18,6 +18,8 @@ import org.gradle.api.DefaultTask; import org.gradle.api.artifacts.Dependency; import org.gradle.api.tasks.Internal; +import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.options.Option; @@ -76,6 +78,11 @@ public void setOutput(String output) { this.outputDirectoryOverride = new File(output); } + @OutputDirectory + public File getOutputFile() { + return downloadDirectory.toFile(); + } + /** * Whether to consider a particular dependency for manifest resolution. * diff --git a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DependencySource.java b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DependencySource.java index d80a777..4dffe21 100644 --- a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DependencySource.java +++ b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DependencySource.java @@ -74,11 +74,6 @@ public String type() { return type; } - @Override - public int hashCode() { - return Objects.hash(dependency, uri, classifier, type); - } - /** * Opens an input stream to the file located at {@link DependencySource#uri()}. It is highly recommended to check {@link DependencySource#exists()} * beforehand. diff --git a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DownloadManifestTask.java b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DownloadManifestTask.java index 5a2e56e..d879e64 100644 --- a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DownloadManifestTask.java +++ b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DownloadManifestTask.java @@ -18,7 +18,9 @@ import org.gradle.api.artifacts.ProjectDependency; import org.gradle.api.artifacts.repositories.MavenArtifactRepository; import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency; +import org.gradle.api.tasks.OutputFile; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -48,7 +50,6 @@ protected InputStream resolveManifest(DependencySource autodocManifest) { getLogger().warn("Could not obtain {}", autodocManifest.dependency()); return null; } - return inputStream; } @@ -122,6 +123,4 @@ private boolean isLocalFileValid(Dependency dep) { throw new RuntimeException(e); } } - - } diff --git a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/FileSource.java b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/FileSource.java index 47e637c..9e6771a 100644 --- a/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/FileSource.java +++ b/plugins/autodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/FileSource.java @@ -7,6 +7,8 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; /** * A dependency that is represented in the local file system, e.g. the local Maven cache @@ -24,7 +26,7 @@ public FileSource(Dependency dependency, URI uri, String classifier, String type @Override public boolean exists() { - return new File(uri()).exists(); + return Files.exists(Path.of(uri())); } @Override