jasper-reports
Compilare JasperReports .jrxml a .jasper
Ricerca…
Con IDE (ambiente di sviluppo integrato)
In IDE Jaspersoft Studio ( JSS ) o nella versione precedente iReport Designer è sufficiente premere Anteprima .
Il file di disegno JasperReports .jrxml verrà automaticamente compilato in .jasper nella stessa cartella di .jrxml se non sono presenti errori .
Un altro modo è quello di premere il pulsante "Compila rapporto" in JSS
oppure utilizzare il menu di scelta rapida "Compile Report" chiamato da Report Inspector in iReport
Con Apache Ant
<target name="compile" description="Compiles report designs specified using the 'srcdir' in the <jrc> tag." depends="prepare-compile-classpath">
<mkdir dir="./build/reports"/>
<taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask">
<classpath refid="project-classpath"/>
</taskdef>
<jrc
srcdir="./reports"
destdir="./build/reports"
tempdir="./build/reports"
keepjava="true"
xmlvalidation="true">
<classpath refid="sample-classpath"/>
<include name="**/*.jrxml"/>
</jrc>
</target>
Lo strumento di compilazione di Apache Ant deve essere installato correttamente sul tuo sistema
Con Java
Mentre è possibile compilare i file .jrxml in file .jasper usando il codice Java, questo comporta un .jasper prestazioni che è meglio evitare pre-compilando i file .jrxml usando l'IDE. Con questo in mente, la compilazione di file .jrxml può essere eseguita utilizzando JasperCompileManager come segue:
JasperCompileManager.compileReportToFile(
"designFile.jrxml", //Relative or absoulte path to the .jrxml file to compile
"compiled.jasper"); //Relative or absolute path to the compiled file .jasper
Con Apache Maven
Il plugin JasperReports di Alex Nederlof è una buona alternativa di org.codehaus.mojo abbandonato : jasperreports-maven-plugin plugin.
L'aggiunta di plug-in è una procedura semplice e tipica:
<build>
<plugins>
<plugin>
<groupId>com.alexnederlof</groupId>
<artifactId>jasperreports-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>jasper</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDirectory>src/main/resources/jrxml</sourceDirectory>
<outputDirectory>${project.build.directory}/jasper</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
Il comando per la compilazione con Maven :
mvn jasperreports: jasper
I file jasper verranno creati nella cartella $ {project.build.directory} / jasper (ad esempio, in / target / jasper )

