Skip to content

Commit

Permalink
fix: use root project output or configured output (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger authored Oct 14, 2024
1 parent c1f8f66 commit 024d25a
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ public abstract class MergeManifestsTask extends DefaultTask {
private final File projectBuildDirectory;
private File destinationFile;
private File inputDirectory;
private String outputDirectoryOption;

public MergeManifestsTask() {
appender = new JsonFileAppender(getProject().getLogger());
projectBuildDirectory = getProject().getLayout().getBuildDirectory().getAsFile().get();
destinationFile = projectBuildDirectory.toPath().resolve(MERGED_MANIFEST_FILENAME).toFile();
destinationFile = getProject().getRootProject().getLayout().getBuildDirectory().get().getAsFile().toPath().resolve(MERGED_MANIFEST_FILENAME).toFile();
inputDirectory = projectBuildDirectory.toPath().resolve("autodoc").toFile();
}

Expand All @@ -59,12 +60,19 @@ public void setDestinationFile(File destinationFile) {

@TaskAction
public void mergeManifests() {
File destination;
if (outputDirectoryOption != null) {
var customOutputDir = new File(outputDirectoryOption);
customOutputDir.mkdirs();
destination = new File(customOutputDir, MERGED_MANIFEST_FILENAME);
} else {
destination = destinationFile;
}

var autodocExt = getProject().getExtensions().findByType(AutodocExtension.class);

Objects.requireNonNull(autodocExt, "AutodocExtension cannot be null");

var destination = getDestinationFile();

if (destination == null) {
throw new GradleException("destinationFile must be configured but was null!");
}
Expand Down Expand Up @@ -104,4 +112,9 @@ public void mergeManifests() {
public void setInputDirectory(String inputDirectory) {
this.inputDirectory = new File(inputDirectory);
}

@Option(option = "output", description = "Directory where the merged manifest should be stored")
public void setOutputDirectory(String outputDirectory) {
this.outputDirectoryOption = outputDirectory;
}
}

0 comments on commit 024d25a

Please sign in to comment.