Skip to content

Commit

Permalink
Detect bundled native lib path, add notarized signing
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Jan 31, 2019
1 parent 7085eda commit 1789e29
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
/out/
/js/node_modules
/lib/javafx*
/.idea/workspace.xml
/.idea/uiDesigner.xml
/.idea/compiler.xml
Expand Down
33 changes: 26 additions & 7 deletions build.xml
Expand Up @@ -2,7 +2,7 @@

<project name="qz" default="distribute" basedir=".">

<target name="distribute" depends="init,clean,sign-jar,override-authcert,include-assets">
<target name="distribute" depends="init,clean,sign-jar,copy-native,override-authcert,include-assets">
<echo message="Process complete" />
</target>

Expand Down Expand Up @@ -154,6 +154,22 @@
<echo>Size: ${build.size} KB</echo>
</target>

<target name="copy-native">
<condition property="native.extension" value="*.dll">
<os family="windows"/>
</condition>
<condition property="native.extension" value="*.dylib">
<os family="mac"/>
</condition>
<condition property="native.extension" value="*.so">
<os family="unix"/>
</condition>
<!-- Copy JavaFX native libs -->
<copy todir="${dist.dir}/libs" flatten="true">
<fileset dir="lib/" includes ="javafx*/**/${native.extension}"/>
</copy>
</target>

<target name="internal-authcert" unless="authcert.use">
<echo>Using internal cert for signing auth</echo>
<property name="build.type" value=""/>
Expand Down Expand Up @@ -248,11 +264,6 @@
</copy>
<copy file="${windows.jsonparser.in}" tofile="${windows.jsonparser.out}" ></copy>

<!-- Copy JavaFX native libs -->
<copy todir="${dist.dir}/libs">
<fileset dir="lib/javafx/bin" includes ="*.dll"/>
</copy>

<exec executable="${nsisbin}" failonerror="true" >
<arg value="${windows.launcher.out}"/>
</exec>
Expand Down Expand Up @@ -389,7 +400,7 @@
<delete file="${dist.dir}/${apple.plist.out}" />
</target>

<target name="codesign" depends="init,prepackage" if="codesign.mac">
<target name="codesign" depends="init,copy-native,prepackage" if="codesign.mac">
<property file="ant/apple/apple.properties"/>
<exec executable="security">
<arg value="add-certificates"/>
Expand Down Expand Up @@ -420,6 +431,14 @@
<param name="signing.jarname" value="communication/libusb4java-*-osx-x86_64.jar"/>
<param name="signing.filetype" value="*.dylib"/>
</antcall>
<!-- Manually sign standalone libs -->
<!--use xargs to loop over and codesign all files-->
<echo message="Signing ${dist.dir}/libs/*.dylib using ${apple.packager.signid}"/>
<exec executable="bash" failonerror="true">
<arg value="-c"/>
<arg value="echo &quot;$(find ${dist.dir}/libs/*.dylib)&quot; |tr ':' '\n' |xargs codesign -s &quot;${apple.packager.signid}&quot; -v"/>
</exec>

</target>

<target name="codesign-libs">
Expand Down
9 changes: 9 additions & 0 deletions src/qz/printer/action/PrintHTML.java
Expand Up @@ -10,16 +10,19 @@

package qz.printer.action;

import com.github.zafarkhaja.semver.Version;
import org.apache.commons.io.IOUtils;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import qz.common.Constants;
import qz.deploy.DeployUtilities;
import qz.printer.PrintOptions;
import qz.printer.PrintOutput;
import qz.utils.PrintingUtilities;
import qz.utils.SystemUtilities;

import javax.print.attribute.PrintRequestAttributeSet;
import javax.swing.*;
Expand All @@ -28,6 +31,7 @@
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Expand All @@ -46,6 +50,11 @@ public class PrintHTML extends PrintImage implements PrintProcessor, Printable {

public PrintHTML() {
super();
//JavaFX native libs
if (SystemUtilities.isJar() && Constants.JAVA_VERSION.greaterThanOrEqualTo(Version.valueOf("11.0.0"))) {
System.setProperty("java.library.path", new File(DeployUtilities.detectJarPath()).getParent() + "/libs/");
}

models = new ArrayList<>();
}

Expand Down
12 changes: 12 additions & 0 deletions src/qz/utils/SystemUtilities.java
Expand Up @@ -33,6 +33,7 @@ public class SystemUtilities {

private static String uname;
private static String linuxRelease;
private static String classProtocol;


/**
Expand Down Expand Up @@ -247,4 +248,15 @@ public static void centerDialog(Dialog dialog, Point position) {
private static double getDpiScale() {
return SystemUtilities.isMac() ? 1 : Toolkit.getDefaultToolkit().getScreenResolution() / 96.0;
}

/**
* Detects if running from IDE or jar
* @return true if running from a jar, false if running from IDE
*/
public static boolean isJar() {
if (classProtocol == null) {
classProtocol = SystemUtilities.class.getResource("").getProtocol();
}
return "jar".equals(classProtocol);
}
}

0 comments on commit 1789e29

Please sign in to comment.