Skip to content

Commit

Permalink
fix: use correct dependency filter in downloadManifestTask (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger authored Nov 19, 2024
1 parent ef6409e commit bef0c68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.eclipse.edc.plugins.autodoc.AutodocExtension;
import org.gradle.api.DefaultTask;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option;
Expand Down Expand Up @@ -64,7 +63,8 @@ public void resolveAutodocManifest() {

getProject().getConfigurations()
.stream().flatMap(config -> config.getDependencies().stream())
.filter(dep -> dep instanceof DefaultProjectDependency)
.distinct()
.filter(this::dependencyFilter)
.filter(dep -> !getExclusions().contains(dep.getName()))
.map(this::createSource)
.filter(Optional::isPresent)
Expand All @@ -76,6 +76,8 @@ public void setOutput(String output) {
this.outputDirectoryOverride = new File(output);
}

protected abstract boolean dependencyFilter(Dependency dependency);

/**
* Returns an {@link InputStream} that points to the physical location of the autodoc manifest file.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -42,6 +43,11 @@ public DownloadManifestTask() {
httpClient = HttpClient.newHttpClient();
}

@Override
protected boolean dependencyFilter(Dependency dependency) {
return !(dependency instanceof DefaultProjectDependency);
}

@Override
protected InputStream resolveManifest(DependencySource autodocManifest) {
var request = HttpRequest.newBuilder().uri(autodocManifest.uri()).GET().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class ResolveManifestTask extends AbstractManifestResolveTask {
public static final String NAME = "resolveManifests";
public static final String DESCRIPTION = "This task is intended for BOM modules and resolves the autodoc manifests of all modules that the project depends on. By default, all manifests are stored in {project}/build/autodoc.";

@Override
protected boolean dependencyFilter(Dependency dependency) {
return dependency instanceof DefaultProjectDependency;
}

@Override
protected InputStream resolveManifest(DependencySource autodocManifest) {
var uri = autodocManifest.uri();
Expand Down

0 comments on commit bef0c68

Please sign in to comment.