Skip to content

Commit

Permalink
Fix #130: Fix hot reload and recompile of reports (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Oct 17, 2024
1 parent 45b2b52 commit 2b048d4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void registerResourceBuildItems(BuildProducer<NativeImageResourcePatternsBuildIt
resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages"));
resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages-defaults"));

// Register resource patterns for OOXML export and font icons
// Register resource patterns for POI export and font icons
final NativeImageResourcePatternsBuildItem.Builder builder = NativeImageResourcePatternsBuildItem.builder();
builder.includeGlob("net/sf/jasperreports/engine/export/ooxml/docx/**");
builder.includeGlob("net/sf/jasperreports/engine/export/ooxml/pptx/**");
Expand Down Expand Up @@ -515,11 +515,12 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
@BuildStep(onlyIf = IsDevelopment.class)
void watchReportFiles(BuildProducer<HotDeploymentWatchedFileBuildItem> watchedPaths,
List<ReportFileBuildItem> reportFiles) {

// Print the found files
reportFiles.forEach((file) -> {
Log.tracef("Watching report file %s", file);
watchedPaths.produce(new HotDeploymentWatchedFileBuildItem(file.getFileName()));

if (Files.isRegularFile(file.getPath())) {
Log.debugf("Watching report file %s", file);
watchedPaths.produce(new HotDeploymentWatchedFileBuildItem(file.getPath().toString()));
}
});
}

Expand All @@ -531,13 +532,11 @@ void watchReportFiles(BuildProducer<HotDeploymentWatchedFileBuildItem> watchedPa
*
* @param config The ReportConfig containing configuration settings for report compilation.
* @param reportFiles A list of ReportFileBuildItem representing the report files to be compiled.
* @param compiledReportProducer A producer for GeneratedClassBuildItem to handle compiled report classes.
* @param compiledReportFileProducer A producer for CompiledReportFileBuildItem to handle compiled report files.
* @param outputTarget The OutputTargetBuildItem containing information about the build output directory.
*/
@BuildStep
void compileReports(ReportBuildTimeConfig config, List<ReportFileBuildItem> reportFiles,
BuildProducer<GeneratedClassBuildItem> compiledReportProducer,
BuildProducer<CompiledReportFileBuildItem> compiledReportFileProducer,
OutputTargetBuildItem outputTarget) {

Expand Down Expand Up @@ -577,8 +576,6 @@ void compileReports(ReportBuildTimeConfig config, List<ReportFileBuildItem> repo

// allow dynamically compiled files to be processed
compiledReportFileProducer.produce(new CompiledReportFileBuildItem(outputFilePath));
compiledReportProducer
.produce(new GeneratedClassBuildItem(true, item.getFileName(), outputStream.toByteArray()));
} catch (JRException ex) {
Log.fatalf("JasperReports error while compiling reports: %s", ex.getMessage());
Log.debug(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.nio.file.Path;
import java.util.List;
import java.util.Locale;
import java.util.StringJoiner;

import org.apache.commons.io.FilenameUtils;

Expand Down Expand Up @@ -50,4 +51,10 @@ public String getType() {
};
}

@Override
public String toString() {
return new StringJoiner(", ", AbstractReportFileBuildItem.class.getSimpleName() + "[", "]")
.add("path=" + path)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field name="address" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<sortField name="city" order="Descending"/>
<sortField name="city" order="Ascending"/>
<sortField name="name"/>
<variable name="CityNumber" incrementType="Group" calculation="Count" incrementGroup="CityGroup" class="java.lang.Integer">
<expression><![CDATA[Boolean.TRUE]]></expression>
Expand Down Expand Up @@ -116,4 +116,4 @@
<expression><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></expression>
</element>
</lastPageFooter>
</jasperReport>
</jasperReport>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ quarkus.log.file.enable=false
quarkus.log.file.path=it.log
quarkus.log.file.format=%d{yyyy-MM-dd HH:mm:ss} %-5p [%c] (%t) %s%e%n
quarkus.log.level=INFO
quarkus.log.category."io.quarkiverse.jasperreports.deployment".level=INFO
%prod.quarkus.log.category."net.sf.jasperreports".level=INFO
%test.quarkus.log.category."net.sf.jasperreports".level=INFO
quarkus.log.category."net.sf.jasperreports".level=INFO
Expand Down

0 comments on commit 2b048d4

Please sign in to comment.