Created
October 9, 2012 16:26
-
-
Save dagvadorj/3859868 to your computer and use it in GitHub Desktop.
Find and compile all Jasper reports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.util.Collection; | |
import org.apache.commons.io.FileUtils; | |
import org.apache.commons.io.filefilter.DirectoryFileFilter; | |
import org.apache.commons.io.filefilter.RegexFileFilter; | |
import org.apache.commons.io.filefilter.TrueFileFilter; | |
import net.sf.jasperreports.engine.JRException; | |
import net.sf.jasperreports.engine.JasperCompileManager; | |
public class JasperCompiler { | |
public static void main(String[] args) throws JRException { | |
String currentPath = System.getProperty("user.dir"); | |
System.out.println("Current path is: " + currentPath); | |
File rootDir = new File(currentPath + "/reports"); | |
Collection<File> files = FileUtils.listFiles(rootDir, new RegexFileFilter("^(.*\\.jrxml)"), TrueFileFilter.INSTANCE); | |
for (File file : files) { | |
System.out.println("Compiling: " + file.getAbsolutePath()); | |
System.out.println("Output: " + file.getName() + ".jasper"); | |
JasperCompileManager.compileReportToFile(file.getAbsolutePath(), "src/reports/" + file.getName() + ".jasper"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment