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 29e2cd7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ public void beforeResolve(ResolvableDependencies dependencies) {

if (addDependency(project, artifact)) {
var task = project.getTasks().findByName("compileJava");
if ((task instanceof JavaCompile compileJava)) {
if (task instanceof JavaCompile compileJava) {
var versionArg = format("-A%s=%s", VERSION, project.getVersion());
var idArg = format("-A%s=%s:%s", ID, project.getGroup(), project.getName());
var outputArg = format("-A%s=%s", OUTPUTDIR, extension.getOutputDirectory().getOrNull());
var projectBuildDirectory = project.getLayout().getBuildDirectory().getAsFile();
var outputArg = format("-A%s=%s", OUTPUTDIR, extension.getOutputDirectory().convention(projectBuildDirectory).get());

compileJava.getOptions().getCompilerArgs().addAll(List.of(idArg, versionArg, outputArg));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public class MergeManifestsTask extends DefaultTask {

public MergeManifestsTask() {
appender = new JsonFileAppender(getProject().getLogger());
destinationFile = Path.of(getProject().getRootProject().getBuildDir().getAbsolutePath(), MERGED_MANIFEST_FILENAME).toFile();
var rootProjectPath = getProject().getRootProject().getLayout().getBuildDirectory().getAsFile().get().getAbsolutePath();
destinationFile = Path.of(rootProjectPath, MERGED_MANIFEST_FILENAME).toFile();
}


Expand All @@ -48,12 +49,13 @@ 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 projectBuildDirectory = getProject().getLayout().getBuildDirectory().getAsFile();
var sourceFile = Path.of(autodocExt.getOutputDirectory().convention(projectBuildDirectory).get().getAbsolutePath(), "edc.json").toFile();
if (sourceFile.exists()) {
appender.append(destination, sourceFile);
} else {
Expand Down Expand Up @@ -84,4 +86,5 @@ public File getDestinationFile() {
public void setDestinationFile(File destinationFile) {
this.destinationFile = destinationFile;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ private void addArtifactIfExist(Project project, File location, MavenPublication

private static @NotNull File getManifestFile(Project target) {
var autodocExt = requireExtension(target, AutodocExtension.class);
var pathToManifest = autodocExt.getOutputDirectory().getOrElse(target.getLayout().getBuildDirectory().getAsFile().get()).getAbsolutePath();
var projectBuildDirectory = target.getLayout().getBuildDirectory().getAsFile();
var pathToManifest = autodocExt.getOutputDirectory().convention(projectBuildDirectory).get().getAbsolutePath();
var manifestFileName = "edc.json";
return Path.of(pathToManifest, manifestFileName).toFile();
}
Expand Down

0 comments on commit 29e2cd7

Please sign in to comment.