Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Added compiler option to the plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
ammachado committed Jan 16, 2013
1 parent 6828343 commit 85c7c05
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
.project
.settings/
target/
.idea
*.iml
28 changes: 20 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@
<developerConnection>scm:git:[email protected]:alexnederlof/Jasper-report-maven-plugin.git</developerConnection>
</scm>

<developers>
<developer>
<id>alexnederlof</id>
<name>Alex Nederlof</name>
</developer>

<developer>
<id>ammachado</id>
<name>Adriano Machado</name>
<email>[email protected]</email>
</developer>
</developers>

<dependencies>
<dependency>
Expand All @@ -36,10 +47,17 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.5.1</version>
<version>5.0.1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -71,6 +89,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<goals>deploy site</goals>
</configuration>
Expand All @@ -80,17 +99,10 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<encoding>UTF-8</encoding>
<useFile>false</useFile>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/de/enovationbtc/jasperreport/JasperReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import net.sf.jasperreports.engine.DefaultJasperReportsContext;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.util.JRProperties;
import net.sf.jasperreports.engine.design.JRCompiler;
import net.sf.jasperreports.engine.design.JRJdtCompiler;
import net.sf.jasperreports.engine.xml.JRReportSaxParserFactory;

import org.apache.commons.lang.Validate;
import org.apache.maven.plugin.AbstractMojo;
Expand All @@ -43,6 +46,14 @@ public class JasperReporter extends AbstractMojo {

static final String ERROR_JRE_COMPILE_ERROR = "Some Jasper reports could not be compiled. See log above for details.";

/**
* This is the java compiler used
*
* @parameter default-value="net.sf.jasperreports.engine.design.JRJdtCompiler"
* @required
*/
private String compiler;

/**
* This is where the .jasper files are written.
*
Expand Down Expand Up @@ -99,7 +110,10 @@ public class JasperReporter extends AbstractMojo {

private Log log;

@Override
public JasperReporter() {
}

@Override
public void execute() throws MojoExecutionException {
log = getLog();

Expand All @@ -113,7 +127,11 @@ public void execute() throws MojoExecutionException {
}
checkOutDirWritable(outputDirectory);

JRProperties.setProperty(JRProperties.COMPILER_XML_VALIDATION, xmlValidation);
DefaultJasperReportsContext jasperReportsContext = DefaultJasperReportsContext.getInstance();
jasperReportsContext.setProperty(JRReportSaxParserFactory.COMPILER_XML_VALIDATION, String.valueOf(xmlValidation));
jasperReportsContext.setProperty(JRCompiler.COMPILER_CLASS, compiler == null ?
JRJdtCompiler.class.getName() : compiler);
jasperReportsContext.setProperty(JRCompiler.COMPILER_KEEP_JAVA_FILE, Boolean.FALSE.toString());

List<CompileTask> tasks = generateTasks(sourceDirectory, outputDirectory);

Expand All @@ -131,7 +149,8 @@ private void logConfiguration(Log log) {
log.info("Output ext=" + outputFileExt);
log.info("Source ext=" + sourceFileExt);
log.info("XML Validation=" + xmlValidation);
log.info("Numer of threads:" + numberOfThreads);
log.info("JasperReports Compiler=" + compiler);
log.info("Number of threads:" + numberOfThreads);
}

/**
Expand Down

0 comments on commit 85c7c05

Please sign in to comment.