Skip to content

Commit

Permalink
fix: add default value for outputDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Aug 21, 2024
1 parent cb190f9 commit 271627d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import org.eclipse.edc.plugins.autodoc.AutodocExtension;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.gradle.util.internal.GFileUtils;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.nio.file.Path;
Expand All @@ -37,7 +39,7 @@ public class MergeManifestsTask extends DefaultTask {

public MergeManifestsTask() {
appender = new JsonFileAppender(getProject().getLogger());
destinationFile = Path.of(getProject().getRootProject().getBuildDir().getAbsolutePath(), MERGED_MANIFEST_FILENAME).toFile();
destinationFile = Path.of(buildDirectory(getProject().getRootProject()).getAbsolutePath(), MERGED_MANIFEST_FILENAME).toFile();
}


Expand All @@ -48,12 +50,12 @@ public void mergeManifests() {
Objects.requireNonNull(autodocExt, "AutodocExtension cannot be null");

var destination = getDestinationFile();
var sourceFile = Path.of(autodocExt.getOutputDirectory().get().getAbsolutePath(), "edc.json").toFile();

if (destination == null) {
throw new GradleException("destinationFile must be configured but was null!");
}

var sourceFile = Path.of(autodocExt.getOutputDirectory().getOrElse(buildDirectory(getProject())).getAbsolutePath(), "edc.json").toFile();
if (sourceFile.exists()) {
appender.append(destination, sourceFile);
} else {
Expand Down Expand Up @@ -84,4 +86,8 @@ public File getDestinationFile() {
public void setDestinationFile(File destinationFile) {
this.destinationFile = destinationFile;
}

private @NotNull File buildDirectory(Project project) {
return project.getLayout().getBuildDirectory().getAsFile().get();
}
}

0 comments on commit 271627d

Please sign in to comment.