Skip to content

Commit

Permalink
Changed ANT build script to put resources at the top level of one-jar.
Browse files Browse the repository at this point in the history
  • Loading branch information
winder committed Mar 30, 2014
1 parent 560f7c4 commit 1506d5e
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 285 deletions.
272 changes: 4 additions & 268 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,281 +10,16 @@
<project name="Universal_G-Code_Sender" default="default" basedir=".">
<description>Builds, tests, and runs the project Universal G-Code Sender.</description>
<import file="nbproject/build-impl.xml"/>


<property name="resources.dir" value="${basedir}/src/resources"/>
<!-- provide a path where executable distros should be saved -->
<property name="release.dir" value="${basedir}/release"/>
<!-- provide the path to the shared native libraries directory -->
<property name="natives.dir" value="${basedir}/lib/natives/"/>
<!-- provide a base name for your executable. -->
<property name="standalone.jar.name" value="UniversalGcodeSender"/>

<import file="one-jar-ant-task.xml" />

<!-- One-Jar .jar building -->
<target name="onejar-individual-platforms" depends="jar"
description="Bundles a stand-alone OneJAR distribution">
<echo>Bundling: OneJAR is copying natives to ${dist.jar.dir}/natives </echo>

<!-- Move natives into build directory. -->
<copy todir="${dist.jar.dir}/natives/linux64">
<fileset dir="${natives.dir}" includes="*"/>
</copy>
<copy todir="${dist.jar.dir}/natives/linux32">
<fileset dir="${natives.dir}/linux32" includes="*"/>
</copy>
<copy todir="${dist.jar.dir}/natives/windows32">
<fileset dir="${natives.dir}/windows32" includes="*"/>
</copy>
<copy todir="${dist.jar.dir}/natives/windows64">
<fileset dir="${natives.dir}/windows64" includes="*"/>
</copy>
<copy todir="${dist.jar.dir}/natives/macosx">
<fileset dir="${natives.dir}/macosx" includes="*.dylib"/>
<fileset dir="${natives.dir}/macosx" includes="*.jnilib"/>
</copy>

<echo>Bundling: OneJAR is composing ${standalone.jar.name}-all32.jar</echo>
<one-jar destfile="${dist.jar.dir}/${standalone.jar.name}-all32.jar" manifest="onejar.mf" update="true">
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<lib>
<fileset file="${dist.jar.dir}/lib/*.*" />
</lib>
<binlib>
<fileset dir="macosx" file="${dist.jar.dir}/natives/macosx/*.*" />
<fileset dir="linux32" file="${dist.jar.dir}/natives/linux32/*.*" />
<fileset dir="windows32" file="${dist.jar.dir}/natives/windows32/*.*" />
</binlib>
<fileset file="${basedir}/properties.cfg"></fileset><!-- optional -->
</one-jar>
<copy todir="${release.dir}/${standalone.jar.name}-all32/"
file="${basedir}/release_files/README.txt"/>

<echo>Bundling: OneJAR is composing ${standalone.jar.name}-all64.jar</echo>
<one-jar destfile="${dist.jar.dir}/${standalone.jar.name}-all64.jar" manifest="onejar.mf" update="true">
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<lib>
<fileset file="${dist.jar.dir}/lib/*.*" />
</lib>
<binlib>
<fileset file="${dist.jar.dir}/natives/macosx/*.*" />
<fileset file="${dist.jar.dir}/natives/linux64/*.*" />
<fileset file="${dist.jar.dir}/natives/windows64/*.*" />
</binlib>
<fileset file="${basedir}/properties.cfg"></fileset><!-- optional -->
</one-jar>

<copy todir="${release.dir}/${standalone.jar.name}-all32/"
file="${basedir}/release_files/README.txt"/>
<echo>Bundling: OneJAR is preparing ${standalone.jar.name}-win32.jar</echo>
<one-jar destfile="${dist.jar.dir}/${standalone.jar.name}-win32.jar" manifest="onejar.mf" update="true">
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<lib>
<fileset file="${dist.jar.dir}/lib/*.*" />
</lib>
<binlib>
<fileset file="${dist.jar.dir}/natives/windows32/*.*" />
</binlib>
</one-jar>

<echo>Bundling: OneJAR is preparing ${standalone.jar.name}-win64.jar</echo>
<one-jar destfile="${dist.jar.dir}/${standalone.jar.name}-win64.jar" manifest="onejar.mf" update="true">
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<lib>
<fileset file="${dist.jar.dir}/lib/*.*" />
</lib>
<binlib>
<fileset file="${dist.jar.dir}/natives/windows64/*.*" />
</binlib>
</one-jar>

<echo>Bundling: OneJAR is preparing ${standalone.jar.name}-linux32.jar</echo>
<one-jar destfile="${dist.jar.dir}/${standalone.jar.name}-linux32.jar" manifest="onejar.mf" update="true">
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<lib>
<fileset file="${dist.jar.dir}/lib/*.*" />
</lib>
<binlib>
<fileset file="${dist.jar.dir}/natives/linux32/*.*" />
</binlib>
</one-jar>

<echo>Bundling: OneJAR is preparing ${standalone.jar.name}-linux64.jar</echo>
<one-jar destfile="${dist.jar.dir}/${standalone.jar.name}-linux64.jar" manifest="onejar.mf" update="true">
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<lib>
<fileset file="${dist.jar.dir}/lib/*.*" />
</lib>
<binlib>
<fileset file="${dist.jar.dir}/natives/linux64/*.*" />
</binlib>
</one-jar>

<echo>Bundling: OneJAR is preparing ${standalone.jar.name}-mac.jar</echo>
<one-jar destfile="${dist.jar.dir}/${standalone.jar.name}-mac.jar" manifest="onejar.mf" update="true">
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<lib>
<fileset file="${dist.jar.dir}/lib/*.*" />
</lib>
<binlib>
<fileset file="${dist.jar.dir}/natives/macosx/*.*" />
</binlib>
</one-jar>
<echo>Bundling: OneJAR is done.</echo>
</target>

<!-- Zipped One-Jar Releases -->
<target name="onejar-individual-platforms-zip" depends="onejar-individual-platforms"
description="Creating ZIP archives of the standalone OneJAR for windows, mac, linux">
<mkdir dir="${release.dir}" />

<!-- Mac (all in one) -->
<echo>Mac: Creating JAR Launcher</echo>
<mkdir dir="${release.dir}/${standalone.jar.name}-mac" />
<move todir="${release.dir}/${standalone.jar.name}-mac/"
file="${dist.jar.dir}/${standalone.jar.name}-mac.jar" >
</move>

<echo>Mac: Creating ZIP Archive</echo>
<zip destfile="${release.dir}/${standalone.jar.name}-mac.zip"
basedir="${release.dir}/${standalone.jar.name}-mac" update="true" />

<echo>Mac: Cleaning up temporary files</echo>
<delete dir="${release.dir}/${standalone.jar.name}-mac" />


<!-- Windows 32 Bit -->
<echo>Win32: Creating JAR Launcher</echo>
<mkdir dir="${release.dir}/${standalone.jar.name}-win32" />
<echo file="${release.dir}/${standalone.jar.name}-win32/${standalone.jar.name}.bat">
java -jar -Xmx256m ${standalone.jar.name}-win32.jar
</echo>
<copy todir="${release.dir}/${standalone.jar.name}-win32/"
file="${dist.jar.dir}/${standalone.jar.name}-win32.jar" />

<echo>Win32: Creating ZIP Archive</echo>
<zip destfile="${release.dir}/${standalone.jar.name}-win32.zip"
basedir="${release.dir}/${standalone.jar.name}-win32" update="true" />

<echo>Win32: Cleaning up temporary files</echo>
<delete dir="${release.dir}/${standalone.jar.name}-win32" />
<delete file="${dist.jar.dir}/${standalone.jar.name}-win32.jar" />

<!-- Windows 64 Bit -->
<echo>Win64: Creating JAR Launcher</echo>
<mkdir dir="${release.dir}/${standalone.jar.name}-win64" />
<echo file="${release.dir}/${standalone.jar.name}-win64/${standalone.jar.name}.bat">
java -jar -Xmx256m ${standalone.jar.name}-win64.jar
</echo>
<copy todir="${release.dir}/${standalone.jar.name}-win64/"
file="${dist.jar.dir}/${standalone.jar.name}-win64.jar" />

<echo>Win64: Creating ZIP Archive</echo>
<zip destfile="${release.dir}/${standalone.jar.name}-win64.zip"
basedir="${release.dir}/${standalone.jar.name}-win64" update="true" />

<echo>Win64: Cleaning up temporary files</echo>
<delete dir="${release.dir}/${standalone.jar.name}-win64" />
<delete file="${dist.jar.dir}/${standalone.jar.name}-win64.jar" />


<!-- Linux Bit 32 -->
<echo>Linux32: Creating JAR Launcher</echo>
<mkdir dir="${release.dir}/${standalone.jar.name}-linux32" />
<echo file="${release.dir}/${standalone.jar.name}-linux32/${standalone.jar.name}.sh">
java -jar -Xmx256m ${standalone.jar.name}-linux32.jar
</echo>
<copy todir="${release.dir}/${standalone.jar.name}-linux32/"
file="${dist.jar.dir}/${standalone.jar.name}-linux32.jar" />

<echo>Linux32: Creating ZIP Archive</echo>
<zip destfile="${release.dir}/${standalone.jar.name}-linux32.zip"
basedir="${release.dir}/${standalone.jar.name}-linux32" update="true" />

<echo>Linux32: Cleaning up temporary files</echo>
<delete dir="${release.dir}/${standalone.jar.name}-linux32" />
<delete file="${dist.jar.dir}/${standalone.jar.name}-linux32.jar" />

<!-- Linux Bit 64 -->
<echo>Linux64: Creating JAR Launcher</echo>
<mkdir dir="${release.dir}/${standalone.jar.name}-linux64" />
<echo file="${release.dir}/${standalone.jar.name}-linux64/${standalone.jar.name}.sh">
java -jar -Xmx256m ${standalone.jar.name}-linux64.jar
</echo>
<copy todir="${release.dir}/${standalone.jar.name}-linux64/"
file="${dist.jar.dir}/${standalone.jar.name}-linux64.jar" />

<echo>Linux64: Creating ZIP Archive</echo>
<zip destfile="${release.dir}/${standalone.jar.name}-linux64.zip"
basedir="${release.dir}/${standalone.jar.name}-linux64" update="true" />

<echo>Linux64: Cleaning up temporary files</echo>
<delete dir="${release.dir}/${standalone.jar.name}-linux64" />
<delete file="${dist.jar.dir}/${standalone.jar.name}-linux64.jar" />

<!-- All 32-Bit -->
<echo>All32: Creating JAR Launcher</echo>
<mkdir dir="${release.dir}/${standalone.jar.name}-all32" />

<!-- static files and scripts -->
<copy todir="${release.dir}/${standalone.jar.name}-all32/"
file="${basedir}/release_files/README.txt"/>
<copy todir="${release.dir}/${standalone.jar.name}-all32/"
file="${basedir}/release_files/start-windows.bat"/>
<copy todir="${release.dir}/${standalone.jar.name}-all32/"
file="${basedir}/release_files/start.sh"/>

<!-- JAR -->
<copy todir="${release.dir}/${standalone.jar.name}-all32/"
file="${dist.jar.dir}/${standalone.jar.name}-all32.jar" />

<echo>All32: Creating ZIP Archive</echo>
<zip destfile="${release.dir}/${standalone.jar.name}-all32.zip"
basedir="${release.dir}/${standalone.jar.name}-all32" update="true" />

<echo>All32: Cleaning up temporary files</echo>
<delete dir="${release.dir}/${standalone.jar.name}-all32" />
<delete file="${dist.jar.dir}/${standalone.jar.name}-all32.jar" />


<!-- All 64-Bit -->
<echo>All64: Creating JAR Launcher</echo>
<mkdir dir="${release.dir}/${standalone.jar.name}-all64" />

<!-- static files and scripts -->
<copy todir="${release.dir}/${standalone.jar.name}-all64/"
file="${basedir}/release_files/README.txt"/>
<copy todir="${release.dir}/${standalone.jar.name}-all64/"
file="${basedir}/release_files/start-windows.bat"/>
<copy todir="${release.dir}/${standalone.jar.name}-all64/"
file="${basedir}/release_files/start.sh"/>

<!-- JAR -->
<copy todir="${release.dir}/${standalone.jar.name}-all64/"
file="${dist.jar.dir}/${standalone.jar.name}-all64.jar" />

<echo>All64: Creating ZIP Archive</echo>
<zip destfile="${release.dir}/${standalone.jar.name}-all64.zip"
basedir="${release.dir}/${standalone.jar.name}-all64" update="true" />

<echo>All64: Cleaning up temporary files</echo>
<delete dir="${release.dir}/${standalone.jar.name}-all64" />
<delete file="${dist.jar.dir}/${standalone.jar.name}-all64.jar" />
</target>

<import file="one-jar-ant-task.xml" />

<!-- One-Jar release to be manually edited. -->
<target name="onejar-build-release" depends="jar"
Expand All @@ -296,6 +31,7 @@
<main>
<fileset dir="${build.classes.dir}/" />
</main>
<fileset dir="${basedir}/src/" includes="resources/**" />
<lib>
<fileset file="${dist.jar.dir}/lib/*.*">
<!-- Switch to native jars when JOGL fixes One-Jar bug. -->
Expand Down
4 changes: 2 additions & 2 deletions src/com/willwinder/universalgcodesender/MainWindow.form
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@
<Component id="firmwareLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="firmwareComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="38" max="32767" attributes="0"/>
<EmptySpace pref="23" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -1173,7 +1173,7 @@
</Group>
</Group>
</Group>
<EmptySpace pref="19" max="32767" attributes="0"/>
<EmptySpace pref="10" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down
20 changes: 5 additions & 15 deletions src/com/willwinder/universalgcodesender/i18n/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ This file is part of Universal Gcode Sender (UGS).
*/
package com.willwinder.universalgcodesender.i18n;

import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

/**
Expand All @@ -36,23 +33,16 @@ This file is part of Universal Gcode Sender (UGS).
*/
public class Localization {
private static ResourceBundle bundle = null;

public static void initialize(String language, String region) throws IOException {
try {
Locale locale = new Locale(language, region);
bundle = ResourceBundle.getBundle("resources.MessagesBundle", locale);
} catch (Exception e) {
InputStream is = Localization.class.getClassLoader()
.getResourceAsStream("resources/MessagesBundle_en_US.properties");
bundle = new PropertyResourceBundle(is);
}

public static void initialize(String language, String region) {
Locale locale = new Locale(language, region);
bundle = ResourceBundle.getBundle("resources.MessagesBundle", locale);
}

public static String getString(String id) throws IOException {
public static String getString(String id) {
if (bundle == null) {
Localization.initialize("en", "US");
}

return bundle.getString(id);
}
}
Loading

0 comments on commit 1506d5e

Please sign in to comment.