Coder Social home page Coder Social logo

jasper-report-maven-plugin's Introduction

Version GitHub Actions Status

jasperreports-plugin

This maven plugin compiles JasperReport report files to the target directory.

Migration to version 3

alexnederlof is the original author of this plugin, but has not used it in years. The plugin got adopted by me (Postremus) and migrated to the pro-crafting organization. Main goal of the adoption is to always provide a version for the latest JasperReports release.

For this reason, when migrating from jasperreports-plugin 2.8 to 3.0, you will need to keep these things in mind:

  1. First, you will need to change the groupdId in the plugin definition, as outlined in section Usage
  2. Second, the plugin now gets compiled using jdk 17. Compatibility with java 1.8 is ensured, since the CI build now forces an --release 8 flag. If any problems arise though, please let me know by opening an issue - we can always adjust that.

Motivation

The original jasperreports-plugin from org.codehaus.mojo was a bit slow. This plugin is 10x faster. I tested it with 52 reports which took 48 seconds with the original plugin and only 4.7 seconds with this plugin.

Installation

You can use the plugin by adding it to the plugin section in your pom:

<build>
	<plugins>
		<plugin>
			<groupId>com.pro-crafting.tools</groupId>
			<artifactId>jasperreports-plugin</artifactId>
			<version>3.6.0</version>
			<executions>
				<execution>
					<phase>process-sources</phase>
	   				<goals>
	      					<goal>jasper</goal>
	   				</goals>
	   			</execution>
			</executions>
			<configuration>
				<!-- These are the default configurations: -->
				<compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
				<sourceDirectory>src/main/jasperreports</sourceDirectory>
				<outputDirectory>${project.build.directory}/jasper</outputDirectory>
				<outputFileExt>.jasper</outputFileExt>
				<xmlValidation>true</xmlValidation>
				<verbose>false</verbose>
				<numberOfThreads>4</numberOfThreads>
				<failOnMissingSourceDirectory>true</failOnMissingSourceDirectory>
				<sourceScanner>org.codehaus.plexus.compiler.util.scan.StaleSourceScanner</sourceScanner>
			</configuration>
		</plugin>
	</plugins>
</build>

You might also need to add the following repositories section to your pom in order to correctly resolve all dependencies:

<repositories>
    <repository>
        <id>jaspersoft-third-party</id>
        <url>https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
    </repository>
</repositories>

JasperReports Version 6.20.2 and 6.20.3 does not include the dependency for exporting pdfs. It needs to be provided by the user. See also issue #351 in the JasperReports repository.

This plugin already provides the openpdf library - you won't have to add it for compilation of your reports. However, the library needs to be present during report execution/filling time, e.g. it needs to be added to your deployed application.

<dependencies>
    <dependency>
        <groupId>com.github.librepdf</groupId>
        <artifactId>openpdf</artifactId>
        <version>1.3.30.jaspersoft.2</version>
    </dependency>
</dependencies>

Usage

If you want to pass any Jasper options to the compiler you can do so by adding them to the configuration like so:

<plugin>
	...
	<configuration>
		...
		<additionalProperties>
			<net.sf.jasperreports.awt.ignore.missing.font>true</net.sf.jasperreports.awt.ignore.missing.font>
			<net.sf.jasperreports.default.pdf.font.name>Courier</net.sf.jasperreports.default.pdf.font.name>
			<net.sf.jasperreports.default.pdf.encoding>UTF-8</net.sf.jasperreports.default.pdf.encoding>
			<net.sf.jasperreports.default.pdf.embedded>true</net.sf.jasperreports.default.pdf.embedded>
           </additionalProperties>
	</configuration>
</plugin>

You can also add extra elements to the classpath using

<plugin>
	...
	<configuration>
		...
		<classpathElements>
			<element>your.classpath.element</element>
        </classpathElements>
	</configuration>
</plugin>

You can also use this alternative approach for JARs:

<plugin>
	...
	<configuration>
		...
		<additionalClasspath>/web/lib/ServiceBeans.jar;/web/lib/WebForms.jar</additionalClasspath>
	</configuration>
</plugin>

JasperReports Compatibility

The following table shows which JasperReports version is included during compilation of each plugin version:

Plugin Version JasperReports Version
3.6.1 6.21.2
3.6.0 6.21.0
3.5.10 6.20.6
3.5.6 6.20.5
3.5.5 6.20.4
3.5.4 6.20.3
3.5.3 6.20.2
3.5.1 6.20.1
3.5.0 6.20.0
3.4.1 6.19.1
3.4.0 6.19.0
3.3.1 6.18.1
3.3.0 6.18.0
3.2.0 6.17.0
3.1.0 6.16.0
3.0.0 6.15.0

jasper-report-maven-plugin's People

Contributors

alexnederlof avatar ammachado avatar bwiedmann avatar cpolzer avatar css-inverso avatar denisfalqueto avatar dependabot[bot] avatar gadton avatar jlleitschuh avatar lucarota avatar marschall avatar mattthebig avatar mmalmeida avatar nelsongraca avatar postremus avatar sohibegit avatar srbala avatar tan9 avatar tobiasrdm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jasper-report-maven-plugin's Issues

Update slf4j to version 2

relates to #6

Can slf4j be updated to version 2?
This should have no effect on users of the plugin, since afaik no dependency of maven plugins is leaking onto the user classpath.

Lets test this out.

Error compiling using Eclipse/M2E

Eclipse

image

Eclipse view Problem

Description	Resource	Path	Location	Type
Failed to execute mojo com.pro-crafting.tools:jasperreports-plugin:3.5.10:jasper {execution: default} (com.pro-crafting.tools:jasperreports-plugin:3.5.10:jasper:default:process-sources)

org.eclipse.core.runtime.CoreException: Failed to execute mojo com.pro-crafting.tools:jasperreports-plugin:3.5.10:jasper {execution: default}
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:340)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.lambda$0(MavenExecutionContext.java:291)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:290)
	at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:57)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.lambda$1(MavenBuilderImpl.java:139)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:729)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:122)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:164)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:109)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:228)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:100)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:83)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:192)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:1020)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:247)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:392)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:395)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:506)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:454)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:536)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:196)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:289)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error while compiling Jasper reports
	at com.pro_crafting.tools.jasperreport.JasperReporter.executeTasks(JasperReporter.java:429)
	at com.pro_crafting.tools.jasperreport.JasperReporter.execute(JasperReporter.java:223)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:338)
	... 32 more
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at com.pro_crafting.tools.jasperreport.JasperReporter.checkForExceptions(JasperReporter.java:436)
	at com.pro_crafting.tools.jasperreport.JasperReporter.executeTasks(JasperReporter.java:418)
	... 35 more
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3502)
	at java.base/java.lang.Class.getDeclaredMethods(Class.java:2601)
	at lombok.launch.PatchFixesHider$Util.findMethodAnyArgs(PatchFixesHider.java:124)
	at lombok.launch.PatchFixesHider$Transform.init(PatchFixesHider.java:203)
	at lombok.launch.PatchFixesHider$Transform.transform_swapped(PatchFixesHider.java:213)
	at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:10882)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12065)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12289)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12246)
	at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:10654)
	at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:849)
	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:394)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
	at net.sf.jasperreports.engine.design.JRJdtCompiler.compileUnits(JRJdtCompiler.java:157)
	at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:231)
	at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358)
	at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:327)
	at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:310)
	at net.sf.jasperreports.engine.JasperCompileManager.compileReportToStream(JasperCompileManager.java:588)
	at com.pro_crafting.tools.jasperreport.CompileTask.call(CompileTask.java:58)
	at com.pro_crafting.tools.jasperreport.CompileTask.call(CompileTask.java:28)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration
	at java.base/java.lang.ClassLoader.findClass(ClassLoader.java:719)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
	at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:555)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 27 more

Versions

  • OS Fedora Linux 37 (Workstation Edition) x86_64
  • OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
  • Eclipse 2023-06 (4.28.0)
  • Jasper 6.20.6

Does anyone know the solution?

Jasper file created is empty

I'm using this plugin in a spring web application and it produces empty .jasper files while with the original official plugin (in beta) they are produced correctly.
Can you tell me what the problem is?

Thank you.

Java version:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Jasper Reports version used:

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.20.5</version>
</dependency>

New plugin configuration (produces empty .jasper files):

<plugins>
<plugin>
<groupId>com.pro-crafting.tools</groupId>
<artifactId>jasperreports-plugin</artifactId>
<version>3.5.6</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>jasper</goal>
</goals>
</execution>
</executions>
<configuration>
<compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
<sourceDirectory>src/main/webapp/resources/jasperreports</sourceDirectory>
<outputDirectory>src/main/webapp/resources/jasper-compiled</outputDirectory>
<outputFileExt>.jasper</outputFileExt>
<xmlValidation>true</xmlValidation>
<verbose>false</verbose>
<numberOfThreads>4</numberOfThreads>
<failOnMissingSourceDirectory>true</failOnMissingSourceDirectory>
<sourceScanner>org.codehaus.plexus.compiler.util.scan.StaleSourceScanner</sourceScanner>
</configuration>
</plugin>
</plugins>

<repositories>
     <repository>
         <id>jaspersoft-third-party</id>
         <url>https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
     </repository>
</repositories>

Old plugin configuration (jasper files are produced correctly):

             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>jasperreports-maven-plugin</artifactId>
                 <version>1.0-beta-2</version>
                 <configuration>
<sourceDirectory>src/main/webapp/resources/jasperreports</sourceDirectory>
<outputDirectory>src/main/webapp/resources/jasper-compiled</outputDirectory>
                 </configuration>
                 <executions>
                     <execution>
                         <phase>compile</phase>
                         <goals>
                             <goal>compile-reports</goal>
                         </goals>
                     </execution>
                 </executions>
                 <dependencies>
                     <dependency>
                         <groupId>net.sf.jasperreports</groupId>
                         <artifactId>jasperreports</artifactId>
                         <version>6.20.5</version>
                     </dependency>
                     <dependency>
                         <groupId>org.codehaus.groovy</groupId>
                         <artifactId>groovy-all</artifactId>
                         <version>2.0.1</version>
                         <scope>compile</scope>
                         <optional>true</optional>
                     </dependency>
                 </dependencies>
             </plugin>

Please place maven artifacts into provided scope

Hi,

Maven requires all maven provided artifacts from their distribution (ie maven itself) to be listed in provided scope since it provides them. This reduces junk in m2 repository.

My current notes have that this plugin had maven core and maven plugin api both in compile scope. They need to be placed into provided. Could you please do so and get a release out?

You may have to adjust the usage, I use Eclipse which helps see the resolution better. If you need assistance here I can help.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.