Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #167: Allow source folder to be any Path #169

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,9 @@ void ignoreJacksonDeserialize(CombinedIndexBuildItem combinedIndex,
@BuildStep
ReportRootBuildItem defaultReportRoot(ReportBuildTimeConfig config) {
if (config.build().enable()) {
return new ReportRootBuildItem(config.build().source().toString());
return new ReportRootBuildItem(config.build().source());
}
return new ReportRootBuildItem(Constants.DEFAULT_SOURCE_PATH);
return new ReportRootBuildItem(Path.of(Constants.DEFAULT_SOURCE_PATH));
}

/**
Expand All @@ -489,15 +489,23 @@ void collectReportFiles(List<ReportRootBuildItem> reportRoots, BuildProducer<Rep
BuildProducer<CompiledReportFileBuildItem> compiledReportFileProducer, OutputTargetBuildItem outputTarget) {
final AtomicInteger count = new AtomicInteger(0);
for (ReportRootBuildItem reportRoot : reportRoots) {
final Path projectRoot = findProjectRoot(outputTarget.getOutputDirectory());
if (projectRoot == null) {
Log.warnf("JasperReport Source Directory does not exist!");
continue;
Path startDir = null;
// #167 allow an external directory so check if the core path exists first
if (Files.exists(reportRoot.getOriginalPath())) {
Log.debugf("JasperReport Source Directory: %s", reportRoot.getOriginalPath());
startDir = reportRoot.getOriginalPath();
}
final Path startDir = projectRoot.resolve(Paths.get(reportRoot.getPath())).normalize();
if (!Files.exists(startDir)) {
Log.warnf("JasperReport Source Directory: %s does not exist!", startDir);
continue;
if (startDir == null) {
final Path projectRoot = findProjectRoot(outputTarget.getOutputDirectory());
if (projectRoot == null) {
Log.warnf("JasperReport Source Directory does not exist!");
continue;
}
startDir = projectRoot.resolve(Paths.get(reportRoot.getPath())).normalize();
if (!Files.exists(startDir)) {
Log.warnf("JasperReport Source Directory: %s does not exist!", startDir);
continue;
}
}

try {
Expand Down Expand Up @@ -758,4 +766,4 @@ private static Path findProjectRoot(Path outputDirectory) {
}
} while (true);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkiverse.jasperreports.deployment.item;

import java.nio.file.Path;

import io.quarkus.builder.item.MultiBuildItem;

/**
Expand All @@ -12,16 +14,22 @@
*/
public final class ReportRootBuildItem extends MultiBuildItem {

private final Path originalPath;
private final String path;

public ReportRootBuildItem(String path) {
this.path = normalize(path);
public ReportRootBuildItem(Path path) {
this.originalPath = path;
this.path = normalize(path.toString());
}

public String getPath() {
return path;
}

public Path getOriginalPath() {
return originalPath;
}

static String normalize(String path) {
path = path.strip();
if (path.startsWith("/")) {
Expand Down