Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Apr 17, 2020
0 parents commit 0a926e0
Show file tree
Hide file tree
Showing 25 changed files with 356 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Commandline Jasper Compiler
===========================

Simple tool able to comple FlexiBee customs reports into given destination

Usage
-----

call it like this:

```shell
jaspercompiler /path/to/report.jrxml
```
to build **/path/to/report.rasper**

also you can specify another destination (directory or filepath) as second parameter.



Installation
------------

```shell
sudo apt install lsb-release wget
echo "deb http://repo.vitexsoftware.cz $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vitexsoftware.list
sudo wget -O /etc/apt/trusted.gpg.d/vitexsoftware.gpg http://repo.vitexsoftware.cz/keyring.gpg
sudo apt update
sudo apt install jaspercompiler
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./src/main/resources/usr/bin/jaspercompiler
./target/jaspercompiler-0.1-jar-with-dependencies.jar
Empty file.
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
jaspercompiler (0.1) UNRELEASED; urgency=medium

* Initial release.

-- CyberVitexus <vitex@exiv.jinonice.czf> Fri, 17 Apr 2020 16:25:39 +0200
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
17 changes: 17 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Source: jaspercompiler
Section: devel
Priority: optional
Maintainer: Vítězslav Dvořák <info@vitexsoftware.cz>
Build-Depends: debhelper (>= 5), cdbs, default-jdk-headless, quilt, maven-debian-helper,
libslf4j-java, libjdom1-java
Standards-Version: 3.9.5
Homepage: https://github.com/VitexSoftware/jaspercompiler
Vcs-Git: git@github.com:VitexSoftware/jaspercompiler.git
Vcs-Browser: https://github.com/VitexSoftware/jaspercompiler

Package: jaspercompiler
Architecture: all
Depends: ${misc:Depends},flexibee-client
Description: Commandline Jasper compiler
Compile jrxml to binary jasper files

1 change: 1 addition & 0 deletions debian/debhelper-build-stamp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jaspercompiler
2 changes: 2 additions & 0 deletions debian/files
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jaspercompiler_0.1_all.deb devel optional
jaspercompiler_0.1_amd64.buildinfo devel optional
3 changes: 3 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src/main/resources/usr/bin/jaspercompiler usr/bin
target/jaspercompiler-0.1-jar-with-dependencies.jar usr/share/java/

3 changes: 3 additions & 0 deletions debian/jaspercompiler.poms
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pom.xml --no-parent --java-lib


2 changes: 2 additions & 0 deletions debian/jaspercompiler.substvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
misc:Depends=
misc:Pre-Depends=
11 changes: 11 additions & 0 deletions debian/jaspercompiler/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: jaspercompiler
Version: 0.1
Architecture: all
Maintainer: Vítězslav Dvořák <info@vitexsoftware.cz>
Installed-Size: 19984
Depends: flexibee-client
Section: devel
Priority: optional
Homepage: https://github.com/VitexSoftware/jaspercompiler
Description: Commandline Jasper compiler
Compile jrxml to binary jasper files
3 changes: 3 additions & 0 deletions debian/jaspercompiler/DEBIAN/md5sums
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
820289a5c2f84e3ce733a2ff0cc495d2 usr/bin/jaspercompiler
9dc03b01bb1266edb8e0d595edfc3605 usr/share/doc/jaspercompiler/changelog.gz
1ebeee638c29373463f81d1943e50bdf usr/share/java/jaspercompiler-0.1-jar-with-dependencies.jar
3 changes: 3 additions & 0 deletions debian/jaspercompiler/usr/bin/jaspercompiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
java --illegal-access=deny -jar /usr/share/java/jaspercompiler-0.1-jar-with-dependencies.jar $1 $2

Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions debian/maven.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
maven.test.skip=true
project.build.sourceEncoding=UTF-8

Empty file added debian/maven.rules
Empty file.
16 changes: 16 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/make -f

#export DH_VERBOSE = 1

JAVA_HOME := /usr/lib/jvm/default-java

override_dh_auto_configure:
override_dh_auto_test:
override_dh_auto_clean:
override_dh_auto_build:
mvn install

override_dh_auto_install:

%:
dh $@
14 changes: 14 additions & 0 deletions nb-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<config-data xmlns="http://www.netbeans.org/ns/maven-config-data/1">
<configurations>
<configuration id="Upload" profiles=""/>
</configurations>
</config-data>
</project-shared-configuration>
46 changes: 46 additions & 0 deletions nbactions-Upload.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath ${packageClassName} /home/vitex/Projects/FlexiBee/WinstromReports/vykazAnalyzaZakazky/analyzaZakazky.jrxml /tmp/analiza.jasper</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName} /home/vitex/Projects/FlexiBee/WinstromReports/vykazAnalyzaZakazky/analyzaZakazky.jrxml /tmp/analiza.jasper</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath ${packageClassName} /home/vitex/Projects/FlexiBee/WinstromReports/vykazAnalyzaZakazky/analyzaZakazky.jrxml /tmp/analiza.jasper</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
</actions>
72 changes: 72 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vitexsoftware</groupId>
<artifactId>jaspercompiler</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>jaspercompiler</name>
<description>Commandline compiler from jrxml file to jasper binary</description>
<developers>
<developer>
<name>Vitex</name>
<email>info@vitexsoftware.cz</email>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.12.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifestEntries>
<Main-Class>com.vitexsoftware.jaspercompiler.Commandline</Main-Class>
<Launcher-Agent-Class>com.vitexsoftware.jaspercompiler.Agent</Launcher-Agent-Class>
</manifestEntries>
<manifest>
<mainClass>com.vitexsoftware.jaspercompiler.Commandline</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<attach>true</attach>
</configuration>


</plugin>
</plugins>
</build>

</project>
30 changes: 30 additions & 0 deletions src/main/java/com/vitexsoftware/jaspercompiler/Agent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.vitexsoftware.jaspercompiler;

import java.io.File;
import java.lang.instrument.Instrumentation;
import java.util.jar.JarFile;

public class Agent {

private static Instrumentation inst = null;

// The JRE will call method before launching your main()
public static void agentmain(final String a, final Instrumentation inst) {
Agent.inst = inst;
}

public static boolean addClassPath(File f) {
try {
inst.appendToSystemClassLoaderSearch(new JarFile(f));
} catch (Throwable e) {
e.printStackTrace();
}
return true;
}

}
90 changes: 90 additions & 0 deletions src/main/java/com/vitexsoftware/jaspercompiler/Commandline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.vitexsoftware.jaspercompiler;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import org.apache.commons.io.filefilter.WildcardFileFilter;

/**
*
* @author vitex
*/
public class Commandline {

public static List<File> winstromJars(String searchIn) {
File dir = new File(searchIn);
FileFilter fileFilter = new WildcardFileFilter("*.jar");
List<File> files = new ArrayList<File>(Arrays.asList(dir.listFiles(fileFilter)));

Iterator<File> iterator = files.iterator();
while (iterator.hasNext()) {
File currentFile = iterator.next();
if (!(currentFile.getName().toString().startsWith("winstrom-") || currentFile.getName().toString().startsWith("binding-"))) {
iterator.remove();
}
}
return files;
}

/**
* Hacks the system classloader to add a classpath entry at
* runtime.<br /><br />
*
* <b>Example</b><br /><br />
* {@code ClasspathHacker.addToClasspath(new File('example.jar'));}<br />
* {@code ClassInExampleJar.doStuff();}
*
* @param file The jar file to add to the classpath
*/
public static void addToClasspath(File file) throws IOException {
Agent.addClassPath(file);
}

public static void main(String[] args) throws IOException, ClassNotFoundException {

if (args.length > 0) {
String sourceFileName = new String(args[0]);
String destinationFilename = new String();

for (File winstromJar : winstromJars("/usr/share/flexibee/lib/")) {
addToClasspath(winstromJar);
}

try {

if (args.length == 1) {
JasperCompileManager.compileReportToFile(sourceFileName);
} else {

File f = new File(args[1]);
if (f.exists() && f.isDirectory()) {
File tmp = new File(sourceFileName);
destinationFilename = args[1] + "/" + tmp.getName().replace(".jrxml", ".jasper");
} else {
destinationFilename = args[1];
}
JasperCompileManager.compileReportToFile(sourceFileName, destinationFilename);
}

} catch (JRException e) {
e.printStackTrace();
}
System.out.println("Compiling Report Design ... " + sourceFileName);

} else {
System.out.println("Usage: jaspcomp /path/to/report.jxml");
}
}

}
3 changes: 3 additions & 0 deletions src/main/resources/usr/bin/jaspercompiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
java --illegal-access=deny -jar /usr/share/java/jaspercompiler-0.1-jar-with-dependencies.jar $1 $2

0 comments on commit 0a926e0

Please sign in to comment.