From 37bb09d35e3f733bbaaa0d68ac3def1e836fb9c2 Mon Sep 17 00:00:00 2001 From: melloware Date: Thu, 3 Oct 2024 08:49:04 -0400 Subject: [PATCH] Fix #74: JasperReports 7.0.1 --- .../deployment/JasperReportsProcessor.java | 46 ++++++++++++++++++- runtime/pom.xml | 20 ++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java b/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java index 9106699..3cf5b9a 100644 --- a/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java @@ -1,12 +1,20 @@ package io.quarkiverse.jasperreports.deployment; +import java.util.ArrayList; +import java.util.List; import java.util.stream.Stream; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.DotName; + import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.IndexDependencyBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem; import io.quarkus.deployment.pkg.builditem.UberJarMergedResourceBuildItem; @@ -25,11 +33,32 @@ UberJarMergedResourceBuildItem mergeResource() { return new UberJarMergedResourceBuildItem(EXTENSIONS_FILE); } + @BuildStep + void indexTransitiveDependencies(BuildProducer index) { + index.produce(new IndexDependencyBuildItem("net.sf.jasperreports", "jasperreports")); + index.produce(new IndexDependencyBuildItem("net.sf.jasperreports", "jasperreports-fonts")); + index.produce(new IndexDependencyBuildItem("net.sf.jasperreports", "jasperreports-jaxen")); + index.produce(new IndexDependencyBuildItem("com.fasterxml.jackson.dataformat", "jackson-dataformat-xml")); + index.produce(new IndexDependencyBuildItem("jaxen", "jaxen")); + } + + @BuildStep + void registerForReflection(BuildProducer reflectiveClass, + CombinedIndexBuildItem combinedIndex) { + + final List classNames = new ArrayList<>(); + // Fonts + classNames.add(net.sf.jasperreports.engine.fonts.SimpleFontFace.class.getName()); + + reflectiveClass.produce( + ReflectiveClassBuildItem.builder(classNames.toArray(new String[0])).methods(true).serialization(true).build()); + } + @BuildStep void runtimeInitializedClasses(BuildProducer runtimeInitializedPackages) { //@formatter:off Stream.of( - javax.swing.plaf.metal.MetalIconFactory.class.getPackageName() + net.sf.jasperreports.engine.base.ElementsBlock.class.getName() ) .map(RuntimeInitializedPackageBuildItem::new) .forEach(runtimeInitializedPackages::produce); @@ -51,4 +80,19 @@ void substrateResourceBuildItems(BuildProducer nat resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages")); resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages-defaults")); } + + public List collectClassesInPackage(CombinedIndexBuildItem combinedIndex, String packageName) { + final List classes = new ArrayList<>(); + final List packages = new ArrayList<>(combinedIndex.getIndex().getSubpackages(packageName)); + packages.add(DotName.createSimple(packageName)); + for (DotName aPackage : packages) { + final List packageClasses = combinedIndex.getIndex() + .getClassesInPackage(aPackage) + .stream() + .map(ClassInfo::toString) + .toList(); + classes.addAll(packageClasses); + } + return classes; + } } \ No newline at end of file diff --git a/runtime/pom.xml b/runtime/pom.xml index 77a1090..bfb4136 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -37,6 +37,26 @@ jasperreports ${version.jasperreports} + + + com.fasterxml.jackson.core + jackson-annotations + + + + com.fasterxml.jackson.core + jackson-core + + + + com.fasterxml.jackson.core + jackson-databind + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + commons-logging commons-logging