Neurogami-roir 1.3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +22 -0
- data/Manifest.txt +250 -0
- data/README.md +12 -0
- data/Rakefile +63 -0
- data/bin/roir +176 -0
- data/data/GenericJavaApp.icns +0 -0
- data/data/JavaApplicationStub +0 -0
- data/data/Rawr logo 1 large.png +0 -0
- data/data/Rawr logo 2 large.png +0 -0
- data/data/Rawr logo2.png +0 -0
- data/data/website/_notes/dwsync.xml +1 -0
- data/data/website/css/1.css +254 -0
- data/data/website/css/_notes/dwsync.xml +1 -0
- data/data/website/images/_notes/dwsync.xml +1 -0
- data/data/website/images/body_bg.jpg +0 -0
- data/data/website/images/bullet.gif +0 -0
- data/data/website/images/content.jpg +0 -0
- data/data/website/images/content_h2.gif +0 -0
- data/data/website/images/details.gif +0 -0
- data/data/website/images/details.jpg +0 -0
- data/data/website/images/header_bg.jpg +0 -0
- data/data/website/images/nav_a_hover.gif +0 -0
- data/data/website/images/rawr_logo.png +0 -0
- data/data/website/index.html +164 -0
- data/lib/app_bundler.rb +138 -0
- data/lib/bundler.rb +36 -0
- data/lib/command.rb +68 -0
- data/lib/exe_bundler.rb +106 -0
- data/lib/generator.rb +127 -0
- data/lib/jar_builder.rb +57 -0
- data/lib/jruby_batch_compiler.rb +127 -0
- data/lib/jruby_release.rb +104 -0
- data/lib/launch4j/LICENSE.txt +30 -0
- data/lib/launch4j/bin-linux/COPYING +340 -0
- data/lib/launch4j/bin-linux/ld +0 -0
- data/lib/launch4j/bin-linux/windres +0 -0
- data/lib/launch4j/bin-mac/COPYING +340 -0
- data/lib/launch4j/bin-mac/ld +0 -0
- data/lib/launch4j/bin-mac/readme.txt +1 -0
- data/lib/launch4j/bin-mac/windres +0 -0
- data/lib/launch4j/bin-win/COPYING +340 -0
- data/lib/launch4j/bin-win/ld.exe +0 -0
- data/lib/launch4j/bin-win/windres.exe +0 -0
- data/lib/launch4j/build.xml +62 -0
- data/lib/launch4j/demo/ConsoleApp/ConsoleApp.jar +0 -0
- data/lib/launch4j/demo/ConsoleApp/build.xml +57 -0
- data/lib/launch4j/demo/ConsoleApp/l4j/ConsoleApp.ico +0 -0
- data/lib/launch4j/demo/ConsoleApp/lib/readme.txt +8 -0
- data/lib/launch4j/demo/ConsoleApp/readme.txt +1 -0
- data/lib/launch4j/demo/ConsoleApp/src/net/sf/launch4j/example/ConsoleApp.java +72 -0
- data/lib/launch4j/demo/LICENSE.txt +30 -0
- data/lib/launch4j/demo/SimpleApp/SimpleApp.jar +0 -0
- data/lib/launch4j/demo/SimpleApp/build.xml +52 -0
- data/lib/launch4j/demo/SimpleApp/l4j/SimpleApp.ico +0 -0
- data/lib/launch4j/demo/SimpleApp/l4j/SimpleApp.xml +18 -0
- data/lib/launch4j/demo/SimpleApp/l4j/splash.bmp +0 -0
- data/lib/launch4j/demo/SimpleApp/lib/readme.txt +8 -0
- data/lib/launch4j/demo/SimpleApp/readme.txt +1 -0
- data/lib/launch4j/demo/SimpleApp/src/net/sf/launch4j/example/SimpleApp.java +104 -0
- data/lib/launch4j/demo/readme.txt +3 -0
- data/lib/launch4j/head/LICENSE.txt +23 -0
- data/lib/launch4j/head/consolehead.o +0 -0
- data/lib/launch4j/head/guihead.o +0 -0
- data/lib/launch4j/head/head.o +0 -0
- data/lib/launch4j/head_src/LICENSE.txt +23 -0
- data/lib/launch4j/head_src/consolehead/Makefile.win +33 -0
- data/lib/launch4j/head_src/consolehead/consolehead.c +65 -0
- data/lib/launch4j/head_src/consolehead/consolehead.dev +108 -0
- data/lib/launch4j/head_src/guihead/Makefile.win +33 -0
- data/lib/launch4j/head_src/guihead/guihead.c +185 -0
- data/lib/launch4j/head_src/guihead/guihead.dev +109 -0
- data/lib/launch4j/head_src/guihead/guihead.h +43 -0
- data/lib/launch4j/head_src/head.c +807 -0
- data/lib/launch4j/head_src/head.h +113 -0
- data/lib/launch4j/head_src/resource.h +71 -0
- data/lib/launch4j/launch4j +8 -0
- data/lib/launch4j/launch4j.jar +0 -0
- data/lib/launch4j/launch4j.jfpr +0 -0
- data/lib/launch4j/lib/JGoodies.Forms.LICENSE.txt +31 -0
- data/lib/launch4j/lib/JGoodies.Looks.LICENSE.txt +31 -0
- data/lib/launch4j/lib/Nuvola.Icon.Theme.LICENSE.txt +504 -0
- data/lib/launch4j/lib/XStream.LICENSE.txt +27 -0
- data/lib/launch4j/lib/commons-beanutils.jar +0 -0
- data/lib/launch4j/lib/commons-logging.jar +0 -0
- data/lib/launch4j/lib/commons.LICENSE.txt +50 -0
- data/lib/launch4j/lib/forms.jar +0 -0
- data/lib/launch4j/lib/formsrt.jar +0 -0
- data/lib/launch4j/lib/foxtrot.LICENSE.txt +25 -0
- data/lib/launch4j/lib/foxtrot.jar +0 -0
- data/lib/launch4j/lib/looks.jar +0 -0
- data/lib/launch4j/lib/xstream.jar +0 -0
- data/lib/launch4j/manifest/uac.exe.manifest +12 -0
- data/lib/launch4j/manifest/xp-themes.exe.manifest +14 -0
- data/lib/launch4j/src/images/asterix-o.gif +0 -0
- data/lib/launch4j/src/images/asterix.gif +0 -0
- data/lib/launch4j/src/images/build.png +0 -0
- data/lib/launch4j/src/images/button_ok.png +0 -0
- data/lib/launch4j/src/images/cancel16.png +0 -0
- data/lib/launch4j/src/images/down16.png +0 -0
- data/lib/launch4j/src/images/edit_add16.png +0 -0
- data/lib/launch4j/src/images/info.png +0 -0
- data/lib/launch4j/src/images/new.png +0 -0
- data/lib/launch4j/src/images/new16.png +0 -0
- data/lib/launch4j/src/images/ok16.png +0 -0
- data/lib/launch4j/src/images/open.png +0 -0
- data/lib/launch4j/src/images/open16.png +0 -0
- data/lib/launch4j/src/images/run.png +0 -0
- data/lib/launch4j/src/images/save.png +0 -0
- data/lib/launch4j/src/images/up16.png +0 -0
- data/lib/launch4j/src/launch4j.properties +2 -0
- data/lib/launch4j/src/net/sf/launch4j/Builder.java +207 -0
- data/lib/launch4j/src/net/sf/launch4j/BuilderException.java +52 -0
- data/lib/launch4j/src/net/sf/launch4j/ExecException.java +66 -0
- data/lib/launch4j/src/net/sf/launch4j/FileChooserFilter.java +76 -0
- data/lib/launch4j/src/net/sf/launch4j/Log.java +105 -0
- data/lib/launch4j/src/net/sf/launch4j/Main.java +99 -0
- data/lib/launch4j/src/net/sf/launch4j/Messages.java +78 -0
- data/lib/launch4j/src/net/sf/launch4j/OptionParser.java +71 -0
- data/lib/launch4j/src/net/sf/launch4j/RcBuilder.java +340 -0
- data/lib/launch4j/src/net/sf/launch4j/Util.java +197 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/AntClassPath.java +61 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/AntConfig.java +129 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/AntJre.java +69 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/Launch4jTask.java +162 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/Messages.java +55 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/StringWrapper.java +67 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/messages.properties +35 -0
- data/lib/launch4j/src/net/sf/launch4j/ant/messages_es.properties +35 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/Binding.java +62 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/BindingException.java +52 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/Bindings.java +317 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/IValidatable.java +44 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/InvariantViolationException.java +67 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/JComboBoxBinding.java +119 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/JListBinding.java +118 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/JRadioButtonBinding.java +146 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/JTextAreaBinding.java +123 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/JTextComponentBinding.java +108 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/JToggleButtonBinding.java +108 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/Messages.java +78 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/OptComponentBinding.java +119 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/OptJTextAreaBinding.java +141 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/Validator.java +259 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/messages.properties +52 -0
- data/lib/launch4j/src/net/sf/launch4j/binding/messages_es.properties +51 -0
- data/lib/launch4j/src/net/sf/launch4j/config/ClassPath.java +87 -0
- data/lib/launch4j/src/net/sf/launch4j/config/Config.java +396 -0
- data/lib/launch4j/src/net/sf/launch4j/config/ConfigPersister.java +249 -0
- data/lib/launch4j/src/net/sf/launch4j/config/ConfigPersisterException.java +51 -0
- data/lib/launch4j/src/net/sf/launch4j/config/Jre.java +235 -0
- data/lib/launch4j/src/net/sf/launch4j/config/LdDefaults.java +62 -0
- data/lib/launch4j/src/net/sf/launch4j/config/Messages.java +78 -0
- data/lib/launch4j/src/net/sf/launch4j/config/Msg.java +111 -0
- data/lib/launch4j/src/net/sf/launch4j/config/SingleInstance.java +74 -0
- data/lib/launch4j/src/net/sf/launch4j/config/Splash.java +103 -0
- data/lib/launch4j/src/net/sf/launch4j/config/VersionInfo.java +168 -0
- data/lib/launch4j/src/net/sf/launch4j/config/messages.properties +93 -0
- data/lib/launch4j/src/net/sf/launch4j/config/messages_es.properties +75 -0
- data/lib/launch4j/src/net/sf/launch4j/form/BasicForm.java +283 -0
- data/lib/launch4j/src/net/sf/launch4j/form/BasicForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/ClassPathForm.java +193 -0
- data/lib/launch4j/src/net/sf/launch4j/form/ClassPathForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/ConfigForm.java +132 -0
- data/lib/launch4j/src/net/sf/launch4j/form/ConfigForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/EnvironmentVarsForm.java +127 -0
- data/lib/launch4j/src/net/sf/launch4j/form/EnvironmentVarsForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/HeaderForm.java +171 -0
- data/lib/launch4j/src/net/sf/launch4j/form/HeaderForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/JreForm.java +266 -0
- data/lib/launch4j/src/net/sf/launch4j/form/JreForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/Messages.java +55 -0
- data/lib/launch4j/src/net/sf/launch4j/form/MessagesForm.java +183 -0
- data/lib/launch4j/src/net/sf/launch4j/form/MessagesForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/SingleInstanceForm.java +141 -0
- data/lib/launch4j/src/net/sf/launch4j/form/SingleInstanceForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/SplashForm.java +166 -0
- data/lib/launch4j/src/net/sf/launch4j/form/SplashForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/VersionInfoForm.java +232 -0
- data/lib/launch4j/src/net/sf/launch4j/form/VersionInfoForm.jfrm +0 -0
- data/lib/launch4j/src/net/sf/launch4j/form/messages.properties +146 -0
- data/lib/launch4j/src/net/sf/launch4j/form/messages_es.properties +118 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/AbstractAcceptListener.java +75 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/BasicFormImpl.java +101 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/BrowseActionListener.java +79 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/ClassPathFormImpl.java +222 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/ConfigFormImpl.java +100 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/EnvironmentVarsFormImpl.java +50 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/FileChooser.java +65 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/GlassPane.java +67 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/HeaderFormImpl.java +102 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/JreFormImpl.java +166 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/MainFrame.java +358 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/Messages.java +55 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/MessagesFormImpl.java +58 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/SingleInstanceFormImpl.java +54 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/SplashFormImpl.java +61 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/VersionInfoFormImpl.java +63 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/messages.properties +74 -0
- data/lib/launch4j/src/net/sf/launch4j/formimpl/messages_es.properties +56 -0
- data/lib/launch4j/src/net/sf/launch4j/messages.properties +45 -0
- data/lib/launch4j/src/net/sf/launch4j/messages_es.properties +45 -0
- data/lib/launch4j/w32api/MinGW.LICENSE.txt +25 -0
- data/lib/launch4j/w32api/crt2.o +0 -0
- data/lib/launch4j/w32api/libadvapi32.a +0 -0
- data/lib/launch4j/w32api/libgcc.a +0 -0
- data/lib/launch4j/w32api/libkernel32.a +0 -0
- data/lib/launch4j/w32api/libmingw32.a +0 -0
- data/lib/launch4j/w32api/libmsvcrt.a +0 -0
- data/lib/launch4j/w32api/libshell32.a +0 -0
- data/lib/launch4j/w32api/libuser32.a +0 -0
- data/lib/launch4j/web/bullet.gif +0 -0
- data/lib/launch4j/web/changelog.html +356 -0
- data/lib/launch4j/web/docs.html +585 -0
- data/lib/launch4j/web/index.html +128 -0
- data/lib/launch4j/web/launch4j-use.gif +0 -0
- data/lib/launch4j/web/launch4j.gif +0 -0
- data/lib/launch4j/web/links.html +73 -0
- data/lib/launch4j/web/style.css +159 -0
- data/lib/options.rb +101 -0
- data/lib/platform.rb +28 -0
- data/lib/rawr.rb +178 -0
- data/lib/rawr_bundle.rb +26 -0
- data/lib/rawr_version.rb +3 -0
- data/lib/web_bundler.rb +114 -0
- data/lib/zip/ioextras.rb +155 -0
- data/lib/zip/stdrubyext.rb +111 -0
- data/lib/zip/tempfile_bugfixed.rb +195 -0
- data/lib/zip/zip.rb +1848 -0
- data/lib/zip/zipfilesystem.rb +609 -0
- data/lib/zip/ziprequire.rb +90 -0
- data/tasks/ann.rake +81 -0
- data/tasks/bones.rake +21 -0
- data/tasks/gem.rake +121 -0
- data/tasks/manifest.rake +49 -0
- data/tasks/notes.rake +28 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +269 -0
- data/tasks/spec.rake +63 -0
- data/tasks/svn.rake +48 -0
- data/tasks/test.rake +38 -0
- data/test/unit/app_bundler_spec.rb +65 -0
- data/test/unit/bundler_spec.rb +27 -0
- data/test/unit/generator_spec.rb +49 -0
- data/test/unit/jar_builder_spec.rb +5 -0
- data/test/unit/options_spec.rb +97 -0
- data/test/unit/platform_spec.rb +29 -0
- data/test/unit/spec_helpers.rb +22 -0
- data/test/unit/web_bundler_spec.rb +83 -0
- metadata +501 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
/*
|
2
|
+
Launch4j (http://launch4j.sourceforge.net/)
|
3
|
+
Cross-platform Java application wrapper for creating Windows native executables.
|
4
|
+
|
5
|
+
Copyright (c) 2004, 2007 Grzegorz Kowal
|
6
|
+
|
7
|
+
All rights reserved.
|
8
|
+
|
9
|
+
Redistribution and use in source and binary forms, with or without modification,
|
10
|
+
are permitted provided that the following conditions are met:
|
11
|
+
|
12
|
+
* Redistributions of source code must retain the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer.
|
14
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
this list of conditions and the following disclaimer in the documentation
|
16
|
+
and/or other materials provided with the distribution.
|
17
|
+
* Neither the name of the Launch4j nor the names of its contributors
|
18
|
+
may be used to endorse or promote products derived from this software without
|
19
|
+
specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
25
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
26
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
27
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
*/
|
33
|
+
|
34
|
+
package net.sf.launch4j;
|
35
|
+
|
36
|
+
import java.text.MessageFormat;
|
37
|
+
import java.util.MissingResourceException;
|
38
|
+
import java.util.ResourceBundle;
|
39
|
+
|
40
|
+
public class Messages {
|
41
|
+
private static final String BUNDLE_NAME = "net.sf.launch4j.messages";
|
42
|
+
|
43
|
+
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
|
44
|
+
.getBundle(BUNDLE_NAME);
|
45
|
+
private static final MessageFormat FORMATTER = new MessageFormat("");
|
46
|
+
|
47
|
+
private Messages() {
|
48
|
+
}
|
49
|
+
|
50
|
+
public static String getString(String key) {
|
51
|
+
try {
|
52
|
+
return RESOURCE_BUNDLE.getString(key);
|
53
|
+
} catch (MissingResourceException e) {
|
54
|
+
return '!' + key + '!';
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
public static String getString(String key, String arg0) {
|
59
|
+
return getString(key, new Object[] {arg0});
|
60
|
+
}
|
61
|
+
|
62
|
+
public static String getString(String key, String arg0, String arg1) {
|
63
|
+
return getString(key, new Object[] {arg0, arg1});
|
64
|
+
}
|
65
|
+
|
66
|
+
public static String getString(String key, String arg0, String arg1, String arg2) {
|
67
|
+
return getString(key, new Object[] {arg0, arg1, arg2});
|
68
|
+
}
|
69
|
+
|
70
|
+
public static String getString(String key, Object[] args) {
|
71
|
+
try {
|
72
|
+
FORMATTER.applyPattern(RESOURCE_BUNDLE.getString(key));
|
73
|
+
return FORMATTER.format(args);
|
74
|
+
} catch (MissingResourceException e) {
|
75
|
+
return '!' + key + '!';
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/*
|
2
|
+
Launch4j (http://launch4j.sourceforge.net/)
|
3
|
+
Cross-platform Java application wrapper for creating Windows native executables.
|
4
|
+
|
5
|
+
Copyright (c) 2004, 2007 Grzegorz Kowal
|
6
|
+
|
7
|
+
All rights reserved.
|
8
|
+
|
9
|
+
Redistribution and use in source and binary forms, with or without modification,
|
10
|
+
are permitted provided that the following conditions are met:
|
11
|
+
|
12
|
+
* Redistributions of source code must retain the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer.
|
14
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
this list of conditions and the following disclaimer in the documentation
|
16
|
+
and/or other materials provided with the distribution.
|
17
|
+
* Neither the name of the Launch4j nor the names of its contributors
|
18
|
+
may be used to endorse or promote products derived from this software without
|
19
|
+
specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
25
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
26
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
27
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
*/
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Created on 2005-04-24
|
36
|
+
*/
|
37
|
+
package net.sf.launch4j;
|
38
|
+
|
39
|
+
//import net.sf.launch4j.config.Config;
|
40
|
+
|
41
|
+
//import org.apache.commons.cli.CommandLine;
|
42
|
+
//import org.apache.commons.cli.CommandLineParser;
|
43
|
+
//import org.apache.commons.cli.HelpFormatter;
|
44
|
+
//import org.apache.commons.cli.Options;
|
45
|
+
//import org.apache.commons.cli.ParseException;
|
46
|
+
//import org.apache.commons.cli.PosixParser;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @author Copyright (C) 2005 Grzegorz Kowal
|
50
|
+
*/
|
51
|
+
public class OptionParser {
|
52
|
+
|
53
|
+
// private final Options _options;
|
54
|
+
//
|
55
|
+
// public OptionParser() {
|
56
|
+
// _options = new Options();
|
57
|
+
// _options.addOption("h", "header", true, "header");
|
58
|
+
// }
|
59
|
+
//
|
60
|
+
// public Config parse(Config c, String[] args) throws ParseException {
|
61
|
+
// CommandLineParser parser = new PosixParser();
|
62
|
+
// CommandLine cl = parser.parse(_options, args);
|
63
|
+
// c.setJar(getFile(props, Config.JAR));
|
64
|
+
// c.setOutfile(getFile(props, Config.OUTFILE));
|
65
|
+
// }
|
66
|
+
//
|
67
|
+
// public void printHelp() {
|
68
|
+
// HelpFormatter formatter = new HelpFormatter();
|
69
|
+
// formatter.printHelp("launch4j", _options);
|
70
|
+
// }
|
71
|
+
}
|
@@ -0,0 +1,340 @@
|
|
1
|
+
/*
|
2
|
+
Launch4j (http://launch4j.sourceforge.net/)
|
3
|
+
Cross-platform Java application wrapper for creating Windows native executables.
|
4
|
+
|
5
|
+
Copyright (c) 2004, 2007 Grzegorz Kowal
|
6
|
+
|
7
|
+
All rights reserved.
|
8
|
+
|
9
|
+
Redistribution and use in source and binary forms, with or without modification,
|
10
|
+
are permitted provided that the following conditions are met:
|
11
|
+
|
12
|
+
* Redistributions of source code must retain the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer.
|
14
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
this list of conditions and the following disclaimer in the documentation
|
16
|
+
and/or other materials provided with the distribution.
|
17
|
+
* Neither the name of the Launch4j nor the names of its contributors
|
18
|
+
may be used to endorse or promote products derived from this software without
|
19
|
+
specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
25
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
26
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
27
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
*/
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Created on 2005-04-24
|
36
|
+
*/
|
37
|
+
package net.sf.launch4j;
|
38
|
+
|
39
|
+
import java.io.BufferedWriter;
|
40
|
+
import java.io.File;
|
41
|
+
import java.io.FileWriter;
|
42
|
+
import java.io.IOException;
|
43
|
+
import java.util.List;
|
44
|
+
|
45
|
+
import net.sf.launch4j.config.Config;
|
46
|
+
import net.sf.launch4j.config.ConfigPersister;
|
47
|
+
import net.sf.launch4j.config.Jre;
|
48
|
+
import net.sf.launch4j.config.Msg;
|
49
|
+
import net.sf.launch4j.config.Splash;
|
50
|
+
import net.sf.launch4j.config.VersionInfo;
|
51
|
+
|
52
|
+
/**
|
53
|
+
* @author Copyright (C) 2005 Grzegorz Kowal
|
54
|
+
*/
|
55
|
+
public class RcBuilder {
|
56
|
+
|
57
|
+
// winnt.h
|
58
|
+
public static final int LANG_NEUTRAL = 0;
|
59
|
+
public static final int SUBLANG_NEUTRAL = 0;
|
60
|
+
public static final int SUBLANG_DEFAULT = 1;
|
61
|
+
public static final int SUBLANG_SYS_DEFAULT = 2;
|
62
|
+
|
63
|
+
// MANIFEST
|
64
|
+
public static final int MANIFEST = 1;
|
65
|
+
|
66
|
+
// ICON
|
67
|
+
public static final int APP_ICON = 1;
|
68
|
+
|
69
|
+
// BITMAP
|
70
|
+
public static final int SPLASH_BITMAP = 1;
|
71
|
+
|
72
|
+
// RCDATA
|
73
|
+
public static final int JRE_PATH = 1;
|
74
|
+
public static final int JAVA_MIN_VER = 2;
|
75
|
+
public static final int JAVA_MAX_VER = 3;
|
76
|
+
public static final int SHOW_SPLASH = 4;
|
77
|
+
public static final int SPLASH_WAITS_FOR_WINDOW = 5;
|
78
|
+
public static final int SPLASH_TIMEOUT = 6;
|
79
|
+
public static final int SPLASH_TIMEOUT_ERR = 7;
|
80
|
+
public static final int CHDIR = 8;
|
81
|
+
public static final int SET_PROC_NAME = 9;
|
82
|
+
public static final int ERR_TITLE = 10;
|
83
|
+
public static final int GUI_HEADER_STAYS_ALIVE = 11;
|
84
|
+
public static final int JVM_OPTIONS = 12;
|
85
|
+
public static final int CMD_LINE = 13;
|
86
|
+
public static final int JAR = 14;
|
87
|
+
public static final int MAIN_CLASS = 15;
|
88
|
+
public static final int CLASSPATH = 16;
|
89
|
+
public static final int WRAPPER = 17;
|
90
|
+
public static final int JDK_PREFERENCE = 18;
|
91
|
+
public static final int ENV_VARIABLES = 19;
|
92
|
+
public static final int PRIORITY_CLASS = 20;
|
93
|
+
public static final int DOWNLOAD_URL = 21;
|
94
|
+
public static final int SUPPORT_URL = 22;
|
95
|
+
public static final int MUTEX_NAME = 23;
|
96
|
+
public static final int INSTANCE_WINDOW_TITLE = 24;
|
97
|
+
public static final int INITIAL_HEAP_SIZE = 25;
|
98
|
+
public static final int INITIAL_HEAP_PERCENT = 26;
|
99
|
+
public static final int MAX_HEAP_SIZE = 27;
|
100
|
+
public static final int MAX_HEAP_PERCENT = 28;
|
101
|
+
|
102
|
+
public static final int STARTUP_ERR = 101;
|
103
|
+
public static final int BUNDLED_JRE_ERR = 102;
|
104
|
+
public static final int JRE_VERSION_ERR = 103;
|
105
|
+
public static final int LAUNCHER_ERR = 104;
|
106
|
+
public static final int INSTANCE_ALREADY_EXISTS_MSG = 105;
|
107
|
+
|
108
|
+
private final StringBuffer _sb = new StringBuffer();
|
109
|
+
|
110
|
+
public String getContent() {
|
111
|
+
return _sb.toString();
|
112
|
+
}
|
113
|
+
|
114
|
+
public String getLine(int line) {
|
115
|
+
return _sb.toString().split("\n")[line - 1];
|
116
|
+
}
|
117
|
+
|
118
|
+
public File build(Config c) throws IOException {
|
119
|
+
_sb.append("LANGUAGE ");
|
120
|
+
_sb.append(LANG_NEUTRAL);
|
121
|
+
_sb.append(", ");
|
122
|
+
_sb.append(SUBLANG_DEFAULT);
|
123
|
+
_sb.append('\n');
|
124
|
+
addVersionInfo(c.getVersionInfo());
|
125
|
+
addJre(c.getJre());
|
126
|
+
addManifest(MANIFEST, c.getManifest());
|
127
|
+
addIcon(APP_ICON, c.getIcon());
|
128
|
+
addText(ERR_TITLE, c.getErrTitle());
|
129
|
+
addText(DOWNLOAD_URL, c.getDownloadUrl());
|
130
|
+
addText(SUPPORT_URL, c.getSupportUrl());
|
131
|
+
addText(CMD_LINE, c.getCmdLine());
|
132
|
+
addWindowsPath(CHDIR, c.getChdir());
|
133
|
+
addText(PRIORITY_CLASS, String.valueOf(c.getPriorityClass()));
|
134
|
+
addTrue(SET_PROC_NAME, c.isCustomProcName());
|
135
|
+
addTrue(GUI_HEADER_STAYS_ALIVE, c.isStayAlive());
|
136
|
+
addSplash(c.getSplash());
|
137
|
+
addMessages(c);
|
138
|
+
|
139
|
+
if (c.getSingleInstance() != null) {
|
140
|
+
addText(MUTEX_NAME, c.getSingleInstance().getMutexName());
|
141
|
+
addText(INSTANCE_WINDOW_TITLE, c.getSingleInstance().getWindowTitle());
|
142
|
+
}
|
143
|
+
|
144
|
+
if (c.getVariables() != null && !c.getVariables().isEmpty()) {
|
145
|
+
StringBuffer vars = new StringBuffer();
|
146
|
+
append(vars, c.getVariables(), "\t");
|
147
|
+
addText(ENV_VARIABLES, vars.toString());
|
148
|
+
}
|
149
|
+
|
150
|
+
// MAIN_CLASS / JAR
|
151
|
+
addTrue(WRAPPER, !c.isDontWrapJar());
|
152
|
+
if (c.getClassPath() != null) {
|
153
|
+
addText(MAIN_CLASS, c.getClassPath().getMainClass());
|
154
|
+
addWindowsPath(CLASSPATH, c.getClassPath().getPathsString());
|
155
|
+
}
|
156
|
+
if (c.isDontWrapJar() && c.getJar() != null) {
|
157
|
+
addWindowsPath(JAR, c.getJar().getPath());
|
158
|
+
}
|
159
|
+
|
160
|
+
File f = Util.createTempFile("rc");
|
161
|
+
BufferedWriter w = new BufferedWriter(new FileWriter(f));
|
162
|
+
w.write(_sb.toString());
|
163
|
+
w.close();
|
164
|
+
return f;
|
165
|
+
}
|
166
|
+
|
167
|
+
private void addVersionInfo(VersionInfo v) {
|
168
|
+
if (v == null) {
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
_sb.append("1 VERSIONINFO\n");
|
172
|
+
_sb.append("FILEVERSION ");
|
173
|
+
_sb.append(v.getFileVersion().replaceAll("\\.", ", "));
|
174
|
+
_sb.append("\nPRODUCTVERSION ");
|
175
|
+
_sb.append(v.getProductVersion().replaceAll("\\.", ", "));
|
176
|
+
_sb.append("\nFILEFLAGSMASK 0\n" +
|
177
|
+
"FILEOS 0x40000\n" +
|
178
|
+
"FILETYPE 1\n" +
|
179
|
+
"{\n" +
|
180
|
+
" BLOCK \"StringFileInfo\"\n" +
|
181
|
+
" {\n" +
|
182
|
+
" BLOCK \"040904E4\"\n" + // English
|
183
|
+
" {\n");
|
184
|
+
addVerBlockValue("CompanyName", v.getCompanyName());
|
185
|
+
addVerBlockValue("FileDescription", v.getFileDescription());
|
186
|
+
addVerBlockValue("FileVersion", v.getTxtFileVersion());
|
187
|
+
addVerBlockValue("InternalName", v.getInternalName());
|
188
|
+
addVerBlockValue("LegalCopyright", v.getCopyright());
|
189
|
+
addVerBlockValue("OriginalFilename", v.getOriginalFilename());
|
190
|
+
addVerBlockValue("ProductName", v.getProductName());
|
191
|
+
addVerBlockValue("ProductVersion", v.getTxtProductVersion());
|
192
|
+
_sb.append(" }\n }\nBLOCK \"VarFileInfo\"\n{\nVALUE \"Translation\", 0x0409, 0x04E4\n}\n}");
|
193
|
+
}
|
194
|
+
|
195
|
+
private void addJre(Jre jre) {
|
196
|
+
addWindowsPath(JRE_PATH, jre.getPath());
|
197
|
+
addText(JAVA_MIN_VER, jre.getMinVersion());
|
198
|
+
addText(JAVA_MAX_VER, jre.getMaxVersion());
|
199
|
+
addText(JDK_PREFERENCE, String.valueOf(jre.getJdkPreferenceIndex()));
|
200
|
+
addInteger(INITIAL_HEAP_SIZE, jre.getInitialHeapSize());
|
201
|
+
addInteger(INITIAL_HEAP_PERCENT, jre.getInitialHeapPercent());
|
202
|
+
addInteger(MAX_HEAP_SIZE, jre.getMaxHeapSize());
|
203
|
+
addInteger(MAX_HEAP_PERCENT, jre.getMaxHeapPercent());
|
204
|
+
|
205
|
+
StringBuffer options = new StringBuffer();
|
206
|
+
if (jre.getOptions() != null && !jre.getOptions().isEmpty()) {
|
207
|
+
addSpace(options);
|
208
|
+
append(options, jre.getOptions(), " ");
|
209
|
+
}
|
210
|
+
addText(JVM_OPTIONS, options.toString());
|
211
|
+
}
|
212
|
+
|
213
|
+
private void addSplash(Splash splash) {
|
214
|
+
if (splash == null) {
|
215
|
+
return;
|
216
|
+
}
|
217
|
+
addTrue(SHOW_SPLASH, true);
|
218
|
+
addTrue(SPLASH_WAITS_FOR_WINDOW, splash.getWaitForWindow());
|
219
|
+
addText(SPLASH_TIMEOUT, String.valueOf(splash.getTimeout()));
|
220
|
+
addTrue(SPLASH_TIMEOUT_ERR, splash.isTimeoutErr());
|
221
|
+
addBitmap(SPLASH_BITMAP, splash.getFile());
|
222
|
+
}
|
223
|
+
|
224
|
+
private void addMessages(Config c) {
|
225
|
+
Msg msg = c.getMessages();
|
226
|
+
if (msg == null) {
|
227
|
+
msg = new Msg();
|
228
|
+
}
|
229
|
+
addText(STARTUP_ERR, msg.getStartupErr());
|
230
|
+
addText(BUNDLED_JRE_ERR, msg.getBundledJreErr());
|
231
|
+
addText(JRE_VERSION_ERR, msg.getJreVersionErr());
|
232
|
+
addText(LAUNCHER_ERR, msg.getLauncherErr());
|
233
|
+
if (c.getSingleInstance() != null) {
|
234
|
+
addText(INSTANCE_ALREADY_EXISTS_MSG, msg.getInstanceAlreadyExistsMsg());
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
private void append(StringBuffer sb, List list, String separator) {
|
239
|
+
for (int i = 0; i < list.size(); i++) {
|
240
|
+
sb.append(list.get(i));
|
241
|
+
if (i < list.size() - 1) {
|
242
|
+
sb.append(separator);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
private void addText(int id, String text) {
|
248
|
+
if (text == null || text.equals("")) {
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
_sb.append(id);
|
252
|
+
_sb.append(" RCDATA BEGIN \"");
|
253
|
+
_sb.append(escape(text));
|
254
|
+
_sb.append("\\0\" END\n");
|
255
|
+
}
|
256
|
+
|
257
|
+
private void addTrue(int id, boolean value) {
|
258
|
+
if (value) {
|
259
|
+
addText(id, "true");
|
260
|
+
}
|
261
|
+
}
|
262
|
+
|
263
|
+
private void addInteger(int id, Integer value) {
|
264
|
+
if (value != null) {
|
265
|
+
addText(id, value.toString());
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Stores path in Windows format with '\' separators.
|
271
|
+
*/
|
272
|
+
private void addWindowsPath(int id, String path) {
|
273
|
+
if (path == null || path.equals("")) {
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
_sb.append(id);
|
277
|
+
_sb.append(" RCDATA BEGIN \"");
|
278
|
+
_sb.append(path.replaceAll("\\\\", "\\\\\\\\")
|
279
|
+
.replaceAll("/", "\\\\\\\\"));
|
280
|
+
_sb.append("\\0\" END\n");
|
281
|
+
}
|
282
|
+
|
283
|
+
private void addManifest(int id, File manifest) {
|
284
|
+
if (manifest == null || manifest.getPath().equals("")) {
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
_sb.append(id);
|
288
|
+
_sb.append(" 24 \"");
|
289
|
+
_sb.append(getPath(Util.getAbsoluteFile(
|
290
|
+
ConfigPersister.getInstance().getConfigPath(), manifest)));
|
291
|
+
_sb.append("\"\n");
|
292
|
+
}
|
293
|
+
|
294
|
+
private void addIcon(int id, File icon) {
|
295
|
+
if (icon == null || icon.getPath().equals("")) {
|
296
|
+
return;
|
297
|
+
}
|
298
|
+
_sb.append(id);
|
299
|
+
_sb.append(" ICON DISCARDABLE \"");
|
300
|
+
_sb.append(getPath(Util.getAbsoluteFile(
|
301
|
+
ConfigPersister.getInstance().getConfigPath(), icon)));
|
302
|
+
_sb.append("\"\n");
|
303
|
+
}
|
304
|
+
|
305
|
+
private void addBitmap(int id, File bitmap) {
|
306
|
+
if (bitmap == null) {
|
307
|
+
return;
|
308
|
+
}
|
309
|
+
_sb.append(id);
|
310
|
+
_sb.append(" BITMAP \"");
|
311
|
+
_sb.append(getPath(Util.getAbsoluteFile(
|
312
|
+
ConfigPersister.getInstance().getConfigPath(), bitmap)));
|
313
|
+
_sb.append("\"\n");
|
314
|
+
}
|
315
|
+
|
316
|
+
private String getPath(File f) {
|
317
|
+
return f.getPath().replaceAll("\\\\", "\\\\\\\\");
|
318
|
+
}
|
319
|
+
|
320
|
+
private void addSpace(StringBuffer sb) {
|
321
|
+
int len = sb.length();
|
322
|
+
if (len-- > 0 && sb.charAt(len) != ' ') {
|
323
|
+
sb.append(' ');
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
private void addVerBlockValue(String key, String value) {
|
328
|
+
_sb.append(" VALUE \"");
|
329
|
+
_sb.append(key);
|
330
|
+
_sb.append("\", \"");
|
331
|
+
if (value != null) {
|
332
|
+
_sb.append(escape(value));
|
333
|
+
}
|
334
|
+
_sb.append("\"\n");
|
335
|
+
}
|
336
|
+
|
337
|
+
private String escape(String text) {
|
338
|
+
return text.replaceAll("\"", "\"\"");
|
339
|
+
}
|
340
|
+
}
|
@@ -0,0 +1,197 @@
|
|
1
|
+
/*
|
2
|
+
Launch4j (http://launch4j.sourceforge.net/)
|
3
|
+
Cross-platform Java application wrapper for creating Windows native executables.
|
4
|
+
|
5
|
+
Copyright (c) 2004, 2007 Grzegorz Kowal
|
6
|
+
|
7
|
+
All rights reserved.
|
8
|
+
|
9
|
+
Redistribution and use in source and binary forms, with or without modification,
|
10
|
+
are permitted provided that the following conditions are met:
|
11
|
+
|
12
|
+
* Redistributions of source code must retain the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer.
|
14
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
this list of conditions and the following disclaimer in the documentation
|
16
|
+
and/or other materials provided with the distribution.
|
17
|
+
* Neither the name of the Launch4j nor the names of its contributors
|
18
|
+
may be used to endorse or promote products derived from this software without
|
19
|
+
specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
25
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
26
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
27
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
*/
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Created on 2005-04-24
|
36
|
+
*/
|
37
|
+
package net.sf.launch4j;
|
38
|
+
|
39
|
+
import java.io.BufferedReader;
|
40
|
+
import java.io.File;
|
41
|
+
import java.io.IOException;
|
42
|
+
import java.io.InputStream;
|
43
|
+
import java.io.InputStreamReader;
|
44
|
+
import java.io.OutputStream;
|
45
|
+
import java.io.Reader;
|
46
|
+
import java.io.Writer;
|
47
|
+
import java.util.regex.Matcher;
|
48
|
+
import java.util.regex.Pattern;
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @author Copyright (C) 2005 Grzegorz Kowal
|
52
|
+
*/
|
53
|
+
public class Util {
|
54
|
+
public static final boolean WINDOWS_OS = System.getProperty("os.name")
|
55
|
+
.toLowerCase().startsWith("windows");
|
56
|
+
|
57
|
+
private Util() {}
|
58
|
+
|
59
|
+
public static File createTempFile(String suffix) throws IOException {
|
60
|
+
String tmpdir = System.getProperty("launch4j.tmpdir");
|
61
|
+
if (tmpdir != null) {
|
62
|
+
if (tmpdir.indexOf(' ') != -1) {
|
63
|
+
throw new IOException(Messages.getString("Util.tmpdir"));
|
64
|
+
}
|
65
|
+
return File.createTempFile("launch4j", suffix, new File(tmpdir));
|
66
|
+
} else {
|
67
|
+
return File.createTempFile("launch4j", suffix);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Returns the base directory of a jar file or null if the class is a standalone file.
|
73
|
+
* @return System specific path
|
74
|
+
*
|
75
|
+
* Based on a patch submitted by Josh Elsasser
|
76
|
+
*/
|
77
|
+
public static File getJarBasedir() {
|
78
|
+
String url = Util.class.getClassLoader()
|
79
|
+
.getResource(Util.class.getName().replace('.', '/') + ".class")
|
80
|
+
.getFile()
|
81
|
+
.replaceAll("%20", " ");
|
82
|
+
if (url.startsWith("file:")) {
|
83
|
+
String jar = url.substring(5, url.lastIndexOf('!'));
|
84
|
+
int x = jar.lastIndexOf('/');
|
85
|
+
if (x == -1) {
|
86
|
+
x = jar.lastIndexOf('\\');
|
87
|
+
}
|
88
|
+
String basedir = jar.substring(0, x + 1);
|
89
|
+
return new File(basedir);
|
90
|
+
} else {
|
91
|
+
return new File(".");
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
public static File getAbsoluteFile(File basepath, File f) {
|
96
|
+
return f.isAbsolute() ? f : new File(basepath, f.getPath());
|
97
|
+
}
|
98
|
+
|
99
|
+
public static String getExtension(File f) {
|
100
|
+
String name = f.getName();
|
101
|
+
int x = name.lastIndexOf('.');
|
102
|
+
if (x != -1) {
|
103
|
+
return name.substring(x);
|
104
|
+
} else {
|
105
|
+
return "";
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
public static void exec(String[] cmd, Log log) throws ExecException {
|
110
|
+
BufferedReader is = null;
|
111
|
+
try {
|
112
|
+
if (WINDOWS_OS) {
|
113
|
+
for (int i = 0; i < cmd.length; i++) {
|
114
|
+
cmd[i] = cmd[i].replaceAll("/", "\\\\");
|
115
|
+
}
|
116
|
+
}
|
117
|
+
Process p = Runtime.getRuntime().exec(cmd);
|
118
|
+
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
|
119
|
+
String line;
|
120
|
+
int errLine = -1;
|
121
|
+
Pattern pattern = Pattern.compile(":\\d+:");
|
122
|
+
while ((line = is.readLine()) != null) {
|
123
|
+
log.append(line);
|
124
|
+
Matcher matcher = pattern.matcher(line);
|
125
|
+
if (matcher.find()) {
|
126
|
+
errLine = Integer.valueOf(
|
127
|
+
line.substring(matcher.start() + 1, matcher.end() - 1))
|
128
|
+
.intValue();
|
129
|
+
if (line.matches("(?i).*unrecognized escape sequence")) {
|
130
|
+
log.append(Messages.getString("Util.use.double.backslash"));
|
131
|
+
}
|
132
|
+
break;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
is.close();
|
136
|
+
p.waitFor();
|
137
|
+
if (errLine != -1) {
|
138
|
+
throw new ExecException(Messages.getString("Util.exec.failed")
|
139
|
+
+ ": " + cmd, errLine);
|
140
|
+
}
|
141
|
+
if (p.exitValue() != 0) {
|
142
|
+
throw new ExecException(Messages.getString("Util.exec.failed")
|
143
|
+
+ "(" + p.exitValue() + "): " + cmd);
|
144
|
+
}
|
145
|
+
} catch (IOException e) {
|
146
|
+
close(is);
|
147
|
+
throw new ExecException(e);
|
148
|
+
} catch (InterruptedException e) {
|
149
|
+
close(is);
|
150
|
+
throw new ExecException(e);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
public static void close(final InputStream o) {
|
155
|
+
if (o != null) {
|
156
|
+
try {
|
157
|
+
o.close();
|
158
|
+
} catch (IOException e) {
|
159
|
+
System.err.println(e); // XXX log
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
public static void close(final OutputStream o) {
|
165
|
+
if (o != null) {
|
166
|
+
try {
|
167
|
+
o.close();
|
168
|
+
} catch (IOException e) {
|
169
|
+
System.err.println(e); // XXX log
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
public static void close(final Reader o) {
|
175
|
+
if (o != null) {
|
176
|
+
try {
|
177
|
+
o.close();
|
178
|
+
} catch (IOException e) {
|
179
|
+
System.err.println(e); // XXX log
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
public static void close(final Writer o) {
|
185
|
+
if (o != null) {
|
186
|
+
try {
|
187
|
+
o.close();
|
188
|
+
} catch (IOException e) {
|
189
|
+
System.err.println(e); // XXX log
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
public static boolean delete(File f) {
|
195
|
+
return (f != null) ? f.delete() : false;
|
196
|
+
}
|
197
|
+
}
|