Skip to content

Commit

Permalink
Fix #74: JasperReports 7.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 3, 2024
1 parent 35f4614 commit 37bb09d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -25,11 +33,32 @@ UberJarMergedResourceBuildItem mergeResource() {
return new UberJarMergedResourceBuildItem(EXTENSIONS_FILE);
}

@BuildStep
void indexTransitiveDependencies(BuildProducer<IndexDependencyBuildItem> 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<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {

final List<String> 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<RuntimeInitializedPackageBuildItem> 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);
Expand All @@ -51,4 +80,19 @@ void substrateResourceBuildItems(BuildProducer<NativeImageResourceBuildItem> nat
resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages"));
resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages-defaults"));
}

public List<String> collectClassesInPackage(CombinedIndexBuildItem combinedIndex, String packageName) {
final List<String> classes = new ArrayList<>();
final List<DotName> packages = new ArrayList<>(combinedIndex.getIndex().getSubpackages(packageName));
packages.add(DotName.createSimple(packageName));
for (DotName aPackage : packages) {
final List<String> packageClasses = combinedIndex.getIndex()
.getClassesInPackage(aPackage)
.stream()
.map(ClassInfo::toString)
.toList();
classes.addAll(packageClasses);
}
return classes;
}
}
20 changes: 20 additions & 0 deletions runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@
<artifactId>jasperreports</artifactId>
<version>${version.jasperreports}</version>
<exclusions>
<!-- provided by quarkus-jackson -->
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<!-- provided by quarkus-jackson -->
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<!-- provided by quarkus-jackson -->
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<!-- provided by quarkus-jackson -->
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down

0 comments on commit 37bb09d

Please sign in to comment.