diff options
author | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2012-11-08 20:07:55 +0100 |
---|---|---|
committer | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2012-11-08 20:07:55 +0100 |
commit | 01692d8e696807881a533d4a4f8fa1b0394de5e4 (patch) | |
tree | 32344bc4a24ed9348503167c7057de14814e26a9 /trunk/pdf-over-gui | |
parent | 4626780495948c96a1aa343c46c062c1635c33ef (diff) | |
download | pdf-over-01692d8e696807881a533d4a4f8fa1b0394de5e4.tar.gz pdf-over-01692d8e696807881a533d4a4f8fa1b0394de5e4.tar.bz2 pdf-over-01692d8e696807881a533d4a4f8fa1b0394de5e4.zip |
Only build 1 pkg per OS, load SWT libs @ runtime
Diffstat (limited to 'trunk/pdf-over-gui')
-rw-r--r-- | trunk/pdf-over-gui/pom.xml | 18 | ||||
-rw-r--r-- | trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java | 21 | ||||
-rw-r--r-- | trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java | 89 | ||||
-rw-r--r-- | trunk/pdf-over-gui/src/main/jnlp/pdfover.jnlp | 61 | ||||
-rw-r--r-- | trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-32.jar | bin | 0 -> 1594280 bytes | |||
-rw-r--r-- | trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-64.jar | bin | 0 -> 1758696 bytes | |||
-rw-r--r-- | trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-32.jar | bin | 0 -> 1755486 bytes | |||
-rw-r--r-- | trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-64.jar | bin | 0 -> 1659145 bytes | |||
-rw-r--r-- | trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-32.jar | bin | 0 -> 1951661 bytes | |||
-rw-r--r-- | trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-64.jar | bin | 0 -> 1938930 bytes |
10 files changed, 118 insertions, 71 deletions
diff --git a/trunk/pdf-over-gui/pom.xml b/trunk/pdf-over-gui/pom.xml index 4c485366..23ddf1ca 100644 --- a/trunk/pdf-over-gui/pom.xml +++ b/trunk/pdf-over-gui/pom.xml @@ -118,7 +118,7 @@ <overWriteSnapshots>true</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <excludeScope>system</excludeScope> <!-- this excludes tools.jar, e.g. --> - <excludeGroupIds>org.codehaus.izpack</excludeGroupIds> + <excludeGroupIds>org.codehaus.izpack,org.eclipse.swt</excludeGroupIds> </configuration> </execution> </executions> @@ -167,8 +167,9 @@ <resource> <directory>src/main/resources</directory> <includes> - <include>scripts/*</include> <include>icons/*</include> + <include>lib-swt/swt-${target.name}-*</include> + <include>scripts/*</include> </includes> </resource> <resource> @@ -211,6 +212,7 @@ <directory>src/main/resources</directory> <excludes> <exclude>izpack/*</exclude> + <exclude>lib-swt/*</exclude> <exclude>scripts/*</exclude> <exclude>keystore.jks</exclude> </excludes> @@ -240,8 +242,8 @@ </activation> <properties> <swt.artifactId>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId> - <staging.dir>${project.build.directory}/staging/linux-64</staging.dir> - <target.name>linux-64</target.name> + <staging.dir>${project.build.directory}/staging/linux</staging.dir> + <target.name>linux</target.name> </properties> </profile> <profile> @@ -283,8 +285,8 @@ </activation> <properties> <swt.artifactId>org.eclipse.swt.win32.win32.x86_64</swt.artifactId> - <staging.dir>${project.build.directory}/staging/windows-64</staging.dir> - <target.name>windows-64</target.name> + <staging.dir>${project.build.directory}/staging/windows</staging.dir> + <target.name>windows</target.name> </properties> </profile> @@ -312,8 +314,8 @@ </activation> <properties> <swt.artifactId>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId> - <staging.dir>${project.build.directory}/staging/mac-64</staging.dir> - <target.name>mac-64</target.name> + <staging.dir>${project.build.directory}/staging/mac</staging.dir> + <target.name>mac</target.name> </properties> </profile> </profiles> diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java index e650cfc4..42a811be 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java @@ -21,6 +21,8 @@ import java.io.File; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.asit.pdfover.gui.exceptions.InitializationException; +import at.asit.pdfover.gui.utils.SWTLoader; import at.asit.pdfover.gui.workflow.StateMachineImpl; /** @@ -37,20 +39,23 @@ public class Main { * @param args */ public static void main(String[] args) { - StateMachineImpl stateMachine = new StateMachineImpl(args); - + log.debug("Loading SWT libraries"); //$NON-NLS-1$ + try { + SWTLoader.loadSWT(); + } catch (InitializationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + File configDir = new File(System.getProperty("user.home")+"/.pdfover"); //$NON-NLS-1$//$NON-NLS-2$ - if(!configDir.exists()) { configDir.mkdir(); - } - + + StateMachineImpl stateMachine = new StateMachineImpl(args); + log.debug("Starting stateMachine ..."); //$NON-NLS-1$ - stateMachine.start(); - log.debug("Ended stateMachine ..."); //$NON-NLS-1$ } - } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java new file mode 100644 index 00000000..f966bb71 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java @@ -0,0 +1,89 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.utils; + +// Imports +import java.io.File; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.exceptions.InitializationException; + +/** + * + */ +@SuppressWarnings("nls") +public class SWTLoader { + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory.getLogger(SWTLoader.class); + + /** + * Load the SWT library for this OS + * @throws InitializationException Loading failed + */ + public static void loadSWT() throws InitializationException { + try { + log.debug("loading " + getSwtJarName()); + URLClassLoader cl = (URLClassLoader)SWTLoader.class.getClassLoader(); + Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); + addUrlMethod.setAccessible(true); + + String swtLibPath = "lib-swt/" + getSwtJarName(); + File swtLib = new File(swtLibPath); + if (!swtLib.isFile()) + throw new SWTLoadFailedException("Library " + swtLibPath + " not found"); + log.debug("Adding " + swtLib + " to ClassLoader..."); + addUrlMethod.invoke(cl, swtLib.toURI().toURL()); + log.debug("Success."); + } catch (Exception e) { + throw new InitializationException("SWT loading failed", e); + } + } + + private static int getArchBits() { + String arch = System.getProperty("os.arch"); + return arch.contains("64") ? 64 : 32; + } + + private static String getSwtJarName() throws SWTLoadFailedException { + String os = System.getProperty("os.name").toLowerCase(); + if (os.contains("win")) + os = "windows"; + else if (os.contains("mac")) + os = "mac"; + else if (os.contains("linux") || os.contains("nix")) + os = "linux"; + else { + log.error("Unknown OS: " + os); + throw new SWTLoadFailedException("Unknown OS: " + os); + } + return "swt-" + os + "-" + getArchBits() + ".jar"; + } + + private static class SWTLoadFailedException extends Exception { + private static final long serialVersionUID = 1L; + + SWTLoadFailedException(String msg) { + super(msg); + } + } +} diff --git a/trunk/pdf-over-gui/src/main/jnlp/pdfover.jnlp b/trunk/pdf-over-gui/src/main/jnlp/pdfover.jnlp index df064c22..ccf8a297 100644 --- a/trunk/pdf-over-gui/src/main/jnlp/pdfover.jnlp +++ b/trunk/pdf-over-gui/src/main/jnlp/pdfover.jnlp @@ -21,68 +21,19 @@ <update check="timeout" policy="prompt-update"/> - <resources os="Linux" arch="i386"> + <resources os="Linux"> <java version="1.6+"/> - <jar href="setup_pdfover_linux_x86.jar" main="true"/> - </resources> - <resources os="Linux" arch="x86"> - <java version="1.6+"/> - <jar href="setup_pdfover_linux_x86.jar" main="true"/> - </resources> - - <resources os="Linux" arch="x86_64"> - <java version="1.6+"/> - <jar href="setup_pdfover_linux_x64.jar" main="true"/> - </resources> - <resources os="Linux" arch="amd64"> - <java version="1.6+"/> - <jar href="setup_pdfover_linux_x64.jar" main="true"/> - </resources> - <resources os="Linux" arch="ppc64"> - <java version="1.6+"/> - <jar href="setup_pdfover_linux_x64.jar" main="true"/> + <jar href="setup_pdfover_linux.jar" main="true"/> </resources> - - <resources os="Windows" arch="x86"> + <resources os="Windows"> <java version="1.6+"/> - <jar href="setup_pdfover_windows_x86.jar" main="true"/> + <jar href="setup_pdfover_windows.jar" main="true"/> </resources> - <resources os="Windows" arch="x86_64"> - <java version="1.6+"/> - <jar href="setup_pdfover_windows_x64.jar" main="true"/> - </resources> - <resources os="Windows" arch="amd64"> - <java version="1.6+"/> - <jar href="setup_pdfover_windows_x64.jar" main="true"/> - </resources> - - - <resources os="Mac OS X" arch="x86"> - <java version="1.6+"/> - <jar href="setup_pdfover_mac_x86.jar" main="true"/> - </resources> - <resources os="Mac OS X" arch="i386"> - <java version="1.6+"/> - <jar href="setup_pdfover_mac_x86.jar" main="true"/> - </resources> - <resources os="Mac OS X" arch="ppc"> - <java version="1.6+"/> - <jar href="setup_pdfover_mac_x86.jar" main="true"/> - </resources> - - <resources os="Mac OS X" arch="x86_64"> - <java version="1.6+"/> - <jar href="setup_pdfover_mac_x64.jar" main="true"/> - </resources> - <resources os="Mac OS X" arch="amd64"> - <java version="1.6+"/> - <jar href="setup_pdfover_mac_x64.jar" main="true"/> - </resources> - <resources os="Mac OS X" arch="ppc64"> + <resources os="Mac OS X"> <java version="1.6+"/> - <jar href="setup_pdfover_mac_x64.jar" main="true"/> + <jar href="setup_pdfover_mac" main="true"/> </resources> <application-desc main-class="com.izforge.izpack.installer.Installer"/> diff --git a/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-32.jar b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-32.jar Binary files differnew file mode 100644 index 00000000..95d36dca --- /dev/null +++ b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-32.jar diff --git a/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-64.jar b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-64.jar Binary files differnew file mode 100644 index 00000000..2141c784 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-linux-64.jar diff --git a/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-32.jar b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-32.jar Binary files differnew file mode 100644 index 00000000..7f1718fd --- /dev/null +++ b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-32.jar diff --git a/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-64.jar b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-64.jar Binary files differnew file mode 100644 index 00000000..e16cfa1f --- /dev/null +++ b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-mac-64.jar diff --git a/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-32.jar b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-32.jar Binary files differnew file mode 100644 index 00000000..eff617af --- /dev/null +++ b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-32.jar diff --git a/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-64.jar b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-64.jar Binary files differnew file mode 100644 index 00000000..1e46b588 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/resources/lib-swt/swt-windows-64.jar |