From dc91e5946daa6ba1ba9fac4e0f0bb01ec6d93cb7 Mon Sep 17 00:00:00 2001 From: Claudio Tasso Date: Wed, 27 Aug 2014 06:46:51 +0200 Subject: [PATCH 01/37] Ported to Eclipse --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e936397..f37f235 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ target/* .settings/* .project .classpath +/target From 7663600191d2146e0c098e6abb3d143a3af57064 Mon Sep 17 00:00:00 2001 From: Claudio Tasso Date: Wed, 27 Aug 2014 06:51:48 +0200 Subject: [PATCH 02/37] Upgrade to Java 7 --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index e0a3ffe..b57a60d 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + maven-antrun-plugin From e9f7ad2cac2287474cb14c770b2d807566684360 Mon Sep 17 00:00:00 2001 From: Claudio Tasso Date: Tue, 2 Sep 2014 06:57:06 +0200 Subject: [PATCH 03/37] Removed Launch4j code. Now Maven dependencies are used. --- pom.xml | 427 ++++++++---------- .../maven/plugins/launch4j/Launch4jMojo.java | 88 ++-- src/main/java/net/sf/launch4j/Builder.java | 207 --------- .../net/sf/launch4j/BuilderException.java | 52 --- .../java/net/sf/launch4j/ExecException.java | 66 --- .../net/sf/launch4j/FileChooserFilter.java | 76 ---- src/main/java/net/sf/launch4j/Log.java | 105 ----- src/main/java/net/sf/launch4j/Messages.java | 78 ---- .../java/net/sf/launch4j/OptionParser.java | 71 --- src/main/java/net/sf/launch4j/RcBuilder.java | 344 -------------- src/main/java/net/sf/launch4j/Util.java | 212 --------- .../net/sf/launch4j/ant/AntClassPath.java | 61 --- .../java/net/sf/launch4j/ant/AntConfig.java | 129 ------ src/main/java/net/sf/launch4j/ant/AntJre.java | 69 --- .../net/sf/launch4j/ant/Launch4jTask.java | 162 ------- .../java/net/sf/launch4j/ant/Messages.java | 55 --- .../net/sf/launch4j/ant/StringWrapper.java | 67 --- .../java/net/sf/launch4j/binding/Binding.java | 62 --- .../sf/launch4j/binding/BindingException.java | 52 --- .../net/sf/launch4j/binding/Bindings.java | 317 ------------- .../net/sf/launch4j/binding/IValidatable.java | 44 -- .../binding/InvariantViolationException.java | 67 --- .../sf/launch4j/binding/JComboBoxBinding.java | 119 ----- .../net/sf/launch4j/binding/JListBinding.java | 118 ----- .../launch4j/binding/JRadioButtonBinding.java | 146 ------ .../sf/launch4j/binding/JTextAreaBinding.java | 123 ----- .../binding/JTextComponentBinding.java | 108 ----- .../binding/JToggleButtonBinding.java | 108 ----- .../net/sf/launch4j/binding/Messages.java | 78 ---- .../launch4j/binding/OptComponentBinding.java | 119 ----- .../launch4j/binding/OptJTextAreaBinding.java | 141 ------ .../net/sf/launch4j/binding/Validator.java | 259 ----------- .../net/sf/launch4j/config/ClassPath.java | 87 ---- .../java/net/sf/launch4j/config/Config.java | 396 ---------------- .../sf/launch4j/config/ConfigPersister.java | 249 ---------- .../config/ConfigPersisterException.java | 51 --- src/main/java/net/sf/launch4j/config/Jre.java | 235 ---------- .../net/sf/launch4j/config/LdDefaults.java | 62 --- .../java/net/sf/launch4j/config/Messages.java | 78 ---- src/main/java/net/sf/launch4j/config/Msg.java | 111 ----- .../sf/launch4j/config/SingleInstance.java | 74 --- .../java/net/sf/launch4j/config/Splash.java | 103 ----- .../net/sf/launch4j/config/VersionInfo.java | 168 ------- 43 files changed, 245 insertions(+), 5499 deletions(-) delete mode 100644 src/main/java/net/sf/launch4j/Builder.java delete mode 100644 src/main/java/net/sf/launch4j/BuilderException.java delete mode 100644 src/main/java/net/sf/launch4j/ExecException.java delete mode 100644 src/main/java/net/sf/launch4j/FileChooserFilter.java delete mode 100644 src/main/java/net/sf/launch4j/Log.java delete mode 100644 src/main/java/net/sf/launch4j/Messages.java delete mode 100644 src/main/java/net/sf/launch4j/OptionParser.java delete mode 100644 src/main/java/net/sf/launch4j/RcBuilder.java delete mode 100644 src/main/java/net/sf/launch4j/Util.java delete mode 100644 src/main/java/net/sf/launch4j/ant/AntClassPath.java delete mode 100644 src/main/java/net/sf/launch4j/ant/AntConfig.java delete mode 100644 src/main/java/net/sf/launch4j/ant/AntJre.java delete mode 100644 src/main/java/net/sf/launch4j/ant/Launch4jTask.java delete mode 100644 src/main/java/net/sf/launch4j/ant/Messages.java delete mode 100644 src/main/java/net/sf/launch4j/ant/StringWrapper.java delete mode 100644 src/main/java/net/sf/launch4j/binding/Binding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/BindingException.java delete mode 100644 src/main/java/net/sf/launch4j/binding/Bindings.java delete mode 100644 src/main/java/net/sf/launch4j/binding/IValidatable.java delete mode 100644 src/main/java/net/sf/launch4j/binding/InvariantViolationException.java delete mode 100644 src/main/java/net/sf/launch4j/binding/JComboBoxBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/JListBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/JRadioButtonBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/JTextAreaBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/JTextComponentBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/JToggleButtonBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/Messages.java delete mode 100644 src/main/java/net/sf/launch4j/binding/OptComponentBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/OptJTextAreaBinding.java delete mode 100644 src/main/java/net/sf/launch4j/binding/Validator.java delete mode 100644 src/main/java/net/sf/launch4j/config/ClassPath.java delete mode 100644 src/main/java/net/sf/launch4j/config/Config.java delete mode 100644 src/main/java/net/sf/launch4j/config/ConfigPersister.java delete mode 100644 src/main/java/net/sf/launch4j/config/ConfigPersisterException.java delete mode 100644 src/main/java/net/sf/launch4j/config/Jre.java delete mode 100644 src/main/java/net/sf/launch4j/config/LdDefaults.java delete mode 100644 src/main/java/net/sf/launch4j/config/Messages.java delete mode 100644 src/main/java/net/sf/launch4j/config/Msg.java delete mode 100644 src/main/java/net/sf/launch4j/config/SingleInstance.java delete mode 100644 src/main/java/net/sf/launch4j/config/Splash.java delete mode 100644 src/main/java/net/sf/launch4j/config/VersionInfo.java diff --git a/pom.xml b/pom.xml index b57a60d..f402526 100644 --- a/pom.xml +++ b/pom.xml @@ -1,239 +1,212 @@ - + + 4.0.0 + com.akathist.maven.plugins.launch4j + launch4j-maven-plugin + maven-plugin + 1.6-SNAPSHOT + Maven Launch4j Plugin + This plugin creates Windows executables from Java jar files using the Launch4j utility. + + http://9stmaryrd.com/tools/launch4j-maven-plugin/ + + + GNU General Public License + http://www.gnu.org/licenses/gpl.txt + repo + + -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + + scm:git:git@github.com:vorburger/launch4j-maven-plugin.git + HEAD + -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + + + net.sf.launch4j + launch4j + 3.4.0 + core + + + org.apache.maven + maven-plugin-api + 3.0 + + + org.apache.maven + maven-artifact + 2.2.1 + + + org.apache.maven + maven-project + 2.2.1 + + + org.apache.maven + maven-plugin-descriptor + 2.2.0 + + + junit + junit + 4.8.2 + test + + -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ---> - - 4.0.0 - com.akathist.maven.plugins.launch4j - launch4j-maven-plugin - maven-plugin - 1.6-SNAPSHOT - Maven Launch4j Plugin - This plugin creates Windows executables from Java jar files using the Launch4j utility. - - http://9stmaryrd.com/tools/launch4j-maven-plugin/ - - - GNU General Public License - http://www.gnu.org/licenses/gpl.txt - repo - - - - - scm:git:git@github.com:vorburger/launch4j-maven-plugin.git - HEAD - - - - - org.apache.maven - maven-plugin-api - 3.0 - - - org.apache.maven - maven-artifact - 2.2.1 - - - org.apache.maven - maven-project - 2.2.1 - - - org.apache.maven - maven-plugin-descriptor - 2.2.0 - - - commons-beanutils - commons-beanutils - 1.8.3 - - - commons-logging - commons-logging - 1.1.1 - - - org.apache.ant - ant - 1.7.0 - - - foxtrot - foxtrot - 2.0 - - - com.thoughtworks.xstream - xstream - 1.3.1 - - - junit - junit - 4.8.2 - test - - - - - - + + + maven-compiler-plugin 3.1 - 1.7 - 1.7 + 1.6 + 1.6 - - maven-antrun-plugin - - - copy - process-classes - - run - - - - - - - - - - - - maven-assembly-plugin - - - assemble-workdir - package - - attached - - - - src/main/assembly/assemble-linux.xml - src/main/assembly/assemble-win32.xml - src/main/assembly/assemble-mac.xml - src/main/assembly/assemble-solaris.xml - - - - - dist-src - package - - attached - - - - src/main/assembly/src.xml - - - - - - - - - org.apache.maven.wagon - wagon-ftp - 1.0-alpha-6 - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.apache.maven.plugins - - - maven-antrun-plugin - - - [1.3,) - - - run - - - - - false - - - - - - - - - - - + + maven-antrun-plugin + + + copy + process-classes + + run + + + + + + + + + + + + maven-assembly-plugin + + + + + + + + + + + + + + + + + + dist-src + package + + attached + + + + src/main/assembly/src.xml + + + + + + + + + org.apache.maven.wagon + wagon-ftp + 1.0-alpha-6 + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-antrun-plugin + + + [1.3,) + + + run + + + + + false + + + + + + + + + + + - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.3.1 - - - - index - summary - license - dependencies - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - org.apache.maven.plugins - maven-surefire-report-plugin - 2.7.2 - - - + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.3.1 + + + + index + summary + license + dependencies + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.7 + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.7.2 + + + diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java index 806bb35..16855a8 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java @@ -24,7 +24,6 @@ import java.io.InputStream; import java.util.Date; import java.util.Enumeration; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.jar.JarEntry; @@ -41,7 +40,6 @@ import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.model.Plugin; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; @@ -56,6 +54,10 @@ */ public class Launch4jMojo extends AbstractMojo { + private static final String LAUNCH4J_ARTIFACT_ID = "launch4j"; + + private static final String LAUNCH4J_GROUP_ID = "net.sf.launch4j"; + /** * The dependencies required by the project. * @@ -108,6 +110,13 @@ public class Launch4jMojo extends AbstractMojo { * @component */ private ArtifactResolver resolver; + + /** + * The dependencies of this plugin. + * Used to get the Launch4j artifact version. + * + * @parameter default-value="${plugin.artifacts}" */ + private java.util.List pluginArtifacts; /** * The base of the current project. @@ -209,15 +218,7 @@ public class Launch4jMojo extends AbstractMojo { */ private String priority; - /** - * Sets the process name to the executable filename (instead of java) and uses XP-style manifests (if any). - * Using this parameter creates a launch4j-tmp directory inside the JRE, - * so don't use it if your app won't have permission to do that. - * - * @parameter default-value=false - */ - private boolean customProcName; - + /** * If true, the executable waits for the java application to finish before returning its exit code. * Defaults to false for gui applications. Has no effect for console applications, which always wait. @@ -323,8 +324,7 @@ public void execute() throws MojoExecutionException { c.setSupportUrl(supportUrl); c.setCmdLine(cmdLine); c.setChdir(chdir); - c.setPriority(priority); - c.setCustomProcName(customProcName); + c.setPriority(priority); c.setStayAlive(stayAlive); c.setManifest(manifest); c.setIcon(icon); @@ -518,36 +518,11 @@ private Artifact chooseBinaryBits() throws MojoExecutionException { throw new MojoExecutionException("Sorry, Launch4j doesn't support the '" + os + "' OS."); } - return factory.createArtifactWithClassifier("com.akathist.maven.plugins.launch4j", "launch4j-maven-plugin", - getMyVersion(), "jar", "workdir-" + plat); - } - - /** - * All this work just to get the version of the current plugin! - * We want to download the platform-specific bundle whose version matches the plugin's version, - * so we have to figure out what version we are. - */ - private String getMyVersion() throws MojoExecutionException { - /* - getLog().info("version = " + plugin.getVersion()); - return plugin.getVersion(); // plugin was set by ${plugin}, but it doesn't work: getVersion returns null! - */ - Log log = getLog(); - log.debug("searching for launch4j plugin"); - Iterator i = plugins.iterator(); - while (i.hasNext()) { - Plugin p = (Plugin)i.next(); - if (log.isDebugEnabled()) log.debug(p.getGroupId() + " ## " + p.getArtifactId() + " ## " + p.getVersion()); - if ("launch4j-maven-plugin".equals(p.getArtifactId()) && - "com.akathist.maven.plugins.launch4j".equals(p.getGroupId())) { - String v = p.getVersion(); - log.debug("Found launch4j version " + v); - return v; - } - } - throw new MojoExecutionException("Launch4j isn't among this project's plugins. How can that be?"); + return factory.createArtifactWithClassifier(LAUNCH4J_GROUP_ID, LAUNCH4J_ARTIFACT_ID, + getLaunch4jVersion(), "jar", "workdir-" + plat); } + private File getBaseDir() { return basedir; } @@ -567,8 +542,7 @@ private void printState() { log.debug("supportUrl = " + supportUrl); log.debug("cmdLine = " + cmdLine); log.debug("chdir = " + chdir); - log.debug("priority = " + priority); - log.debug("customProcName = " + customProcName); + log.debug("priority = " + priority); log.debug("stayAlive = " + stayAlive); log.debug("icon = " + icon); log.debug("objs = " + objs); @@ -635,4 +609,32 @@ private void printState() { } } + /** + * The Launch4j version used by the plugin. + * We want to download the platform-specific bundle whose version matches the Launch4j version, + * so we have to figure out what version the plugin is using. + * + * @return + * @throws MojoExecutionException + */ + private String getLaunch4jVersion() throws MojoExecutionException{ + String version = null; + + for(Artifact artifact: pluginArtifacts){ + if(LAUNCH4J_GROUP_ID.equals(artifact.getGroupId()) && + LAUNCH4J_ARTIFACT_ID.equals(artifact.getArtifactId()) + && "core".equals(artifact.getClassifier()) ){ + + version = artifact.getVersion(); + getLog().debug("Found launch4j version " + version); + break; + } + } + + if(version==null){ + throw new MojoExecutionException("Impossible to find which Launch4j version to use"); + } + + return version; + } } diff --git a/src/main/java/net/sf/launch4j/Builder.java b/src/main/java/net/sf/launch4j/Builder.java deleted file mode 100644 index d7badc7..0000000 --- a/src/main/java/net/sf/launch4j/Builder.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on 2005-04-24 - */ -package net.sf.launch4j; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; - -import net.sf.launch4j.binding.InvariantViolationException; -import net.sf.launch4j.config.Config; -import net.sf.launch4j.config.ConfigPersister; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class Builder { - private final Log _log; - private final File _basedir; - - public Builder(Log log) { - _log = log; - _basedir = Util.getJarBasedir(); - } - - public Builder(Log log, File basedir) { - _log = log; - _basedir = basedir; - } - - /** - * @return Output file path. - */ - public File build() throws BuilderException { - final Config c = ConfigPersister.getInstance().getConfig(); - try { - c.validate(); - } catch (InvariantViolationException e) { - throw new BuilderException(e.getMessage()); - } - File rc = null; - File ro = null; - File outfile = null; - FileInputStream is = null; - FileOutputStream os = null; - final RcBuilder rcb = new RcBuilder(); - try { - rc = rcb.build(c); - ro = Util.createTempFile("o"); - outfile = ConfigPersister.getInstance().getOutputFile(); - - Cmd resCmd = new Cmd(_basedir); - resCmd.addExe("windres") - .add(Util.WINDOWS_OS ? "--preprocessor=type" : "--preprocessor=cat") - .add("-J rc -O coff -F pe-i386") - .addAbsFile(rc) - .addAbsFile(ro); - _log.append(Messages.getString("Builder.compiling.resources")); - resCmd.exec(_log); - - Cmd ldCmd = new Cmd(_basedir); - ldCmd.addExe("ld") - .add("-mi386pe") - .add("--oformat pei-i386") - .add((c.getHeaderType().equals(Config.GUI_HEADER)) - ? "--subsystem windows" : "--subsystem console") - .add("-s") // strip symbols - .addFiles(c.getHeaderObjects()) - .addAbsFile(ro) - .addFiles(c.getLibs()) - .add("-o") - .addAbsFile(outfile); - _log.append(Messages.getString("Builder.linking")); - ldCmd.exec(_log); - - if (!c.isDontWrapJar()) { - _log.append(Messages.getString("Builder.wrapping")); - int len; - byte[] buffer = new byte[1024]; - is = new FileInputStream(Util.getAbsoluteFile( - ConfigPersister.getInstance().getConfigPath(), c.getJar())); - os = new FileOutputStream(outfile, true); - while ((len = is.read(buffer)) > 0) { - os.write(buffer, 0, len); - } - } - _log.append(Messages.getString("Builder.success") + outfile.getPath()); - return outfile; - } catch (IOException e) { - Util.delete(outfile); - _log.append(e.getMessage()); - throw new BuilderException(e); - } catch (ExecException e) { - Util.delete(outfile); - String msg = e.getMessage(); - if (msg != null && msg.indexOf("windres") != -1) { - if (e.getErrLine() != -1) { - _log.append(Messages.getString("Builder.line.has.errors", - String.valueOf(e.getErrLine()))); - _log.append(rcb.getLine(e.getErrLine())); - } else { - _log.append(Messages.getString("Builder.generated.resource.file")); - _log.append(rcb.getContent()); - } - } - throw new BuilderException(e); - } finally { - Util.close(is); - Util.close(os); - Util.delete(rc); - Util.delete(ro); - } - } -} - -class Cmd { - private final List _cmd = new ArrayList(); - private final File _basedir; - private final File _bindir; - - public Cmd(File basedir) { - _basedir = basedir; - String path = System.getProperty("launch4j.bindir"); - if (path == null) { - _bindir = new File(basedir, "bin"); - } else { - File bindir = new File(path); - _bindir = bindir.isAbsolute() ? bindir : new File(basedir, path); - } - } - - public Cmd add(String s) { - StringTokenizer st = new StringTokenizer(s); - while (st.hasMoreTokens()) { - _cmd.add(st.nextToken()); - } - return this; - } - - public Cmd addAbsFile(File file) { - _cmd.add(file.getPath()); - return this; - } - - public Cmd addFile(String pathname) { - _cmd.add(new File(_basedir, pathname).getPath()); - return this; - } - - public Cmd addExe(String pathname) { - if (Util.WINDOWS_OS) { - pathname += ".exe"; - } - _cmd.add(new File(_bindir, pathname).getPath()); - return this; - } - - public Cmd addFiles(List files) { - for (Iterator iter = files.iterator(); iter.hasNext();) { - addFile((String) iter.next()); - } - return this; - } - - public void exec(Log log) throws ExecException { - String[] cmd = (String[]) _cmd.toArray(new String[_cmd.size()]); - Util.exec(cmd, log); - } -} diff --git a/src/main/java/net/sf/launch4j/BuilderException.java b/src/main/java/net/sf/launch4j/BuilderException.java deleted file mode 100644 index a84c2e2..0000000 --- a/src/main/java/net/sf/launch4j/BuilderException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 13, 2005 - */ -package net.sf.launch4j; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class BuilderException extends Exception { - public BuilderException() {} - - public BuilderException(Throwable t) { - super(t); - } - - public BuilderException(String msg) { - super(msg); - } -} diff --git a/src/main/java/net/sf/launch4j/ExecException.java b/src/main/java/net/sf/launch4j/ExecException.java deleted file mode 100644 index 236ae78..0000000 --- a/src/main/java/net/sf/launch4j/ExecException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 14, 2005 - */ -package net.sf.launch4j; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class ExecException extends Exception { - private final int _errLine; - - public ExecException(Throwable t, int errLine) { - super(t); - _errLine = errLine; - } - - public ExecException(Throwable t) { - this(t, -1); - } - - public ExecException(String msg, int errLine) { - super(msg); - _errLine = errLine; - } - - public ExecException(String msg) { - this(msg, -1); - } - - public int getErrLine() { - return _errLine; - } -} diff --git a/src/main/java/net/sf/launch4j/FileChooserFilter.java b/src/main/java/net/sf/launch4j/FileChooserFilter.java deleted file mode 100644 index 5199a6d..0000000 --- a/src/main/java/net/sf/launch4j/FileChooserFilter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on 2004-01-15 - */ -package net.sf.launch4j; - -import java.io.File; - -import javax.swing.filechooser.FileFilter; - -/** - * @author Copyright (C) 2004 Grzegorz Kowal - */ -public class FileChooserFilter extends FileFilter { - String _description; - String[] _extensions; - - public FileChooserFilter(String description, String extension) { - _description = description; - _extensions = new String[] {extension}; - } - - public FileChooserFilter(String description, String[] extensions) { - _description = description; - _extensions = extensions; - } - - public boolean accept(File f) { - if (f.isDirectory()) { - return true; - } - String ext = Util.getExtension(f); - for (int i = 0; i < _extensions.length; i++) { - if (ext.toLowerCase().equals(_extensions[i].toLowerCase())) { - return true; - } - } - return false; - } - - public String getDescription() { - return _description; - } -} diff --git a/src/main/java/net/sf/launch4j/Log.java b/src/main/java/net/sf/launch4j/Log.java deleted file mode 100644 index c4d591b..0000000 --- a/src/main/java/net/sf/launch4j/Log.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 12, 2005 - */ -package net.sf.launch4j; - -import javax.swing.JTextArea; -import javax.swing.SwingUtilities; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public abstract class Log { - private static final Log _consoleLog = new ConsoleLog(); - private static final Log _antLog = new AntLog(); - - public abstract void clear(); - public abstract void append(String line); - - public static Log getConsoleLog() { - return _consoleLog; - } - - public static Log getAntLog() { - return _antLog; - } - - public static Log getSwingLog(JTextArea textArea) { - return new SwingLog(textArea); - } -} - -class ConsoleLog extends Log { - public void clear() { - System.out.println("\n"); - } - - public void append(String line) { - System.out.println("launch4j: " + line); - } -} - -class AntLog extends Log { - public void clear() { - System.out.println("\n"); - } - - public void append(String line) { - System.out.println(line); - } -} - -class SwingLog extends Log { - private final JTextArea _textArea; - - public SwingLog(JTextArea textArea) { - _textArea = textArea; - } - - public void clear() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - _textArea.setText(""); - }}); - } - - public void append(final String line) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - _textArea.append(line + "\n"); - }}); - } -} diff --git a/src/main/java/net/sf/launch4j/Messages.java b/src/main/java/net/sf/launch4j/Messages.java deleted file mode 100644 index 35d4c89..0000000 --- a/src/main/java/net/sf/launch4j/Messages.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package net.sf.launch4j; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "net.sf.launch4j.messages"; - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - private static final MessageFormat FORMATTER = new MessageFormat(""); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - - public static String getString(String key, String arg0) { - return getString(key, new Object[] {arg0}); - } - - public static String getString(String key, String arg0, String arg1) { - return getString(key, new Object[] {arg0, arg1}); - } - - public static String getString(String key, String arg0, String arg1, String arg2) { - return getString(key, new Object[] {arg0, arg1, arg2}); - } - - public static String getString(String key, Object[] args) { - try { - FORMATTER.applyPattern(RESOURCE_BUNDLE.getString(key)); - return FORMATTER.format(args); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/src/main/java/net/sf/launch4j/OptionParser.java b/src/main/java/net/sf/launch4j/OptionParser.java deleted file mode 100644 index bb2432c..0000000 --- a/src/main/java/net/sf/launch4j/OptionParser.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on 2005-04-24 - */ -package net.sf.launch4j; - -//import net.sf.launch4j.config.Config; - -//import org.apache.commons.cli.CommandLine; -//import org.apache.commons.cli.CommandLineParser; -//import org.apache.commons.cli.HelpFormatter; -//import org.apache.commons.cli.Options; -//import org.apache.commons.cli.ParseException; -//import org.apache.commons.cli.PosixParser; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class OptionParser { - -// private final Options _options; -// -// public OptionParser() { -// _options = new Options(); -// _options.addOption("h", "header", true, "header"); -// } -// -// public Config parse(Config c, String[] args) throws ParseException { -// CommandLineParser parser = new PosixParser(); -// CommandLine cl = parser.parse(_options, args); -// c.setJar(getFile(props, Config.JAR)); -// c.setOutfile(getFile(props, Config.OUTFILE)); -// } -// -// public void printHelp() { -// HelpFormatter formatter = new HelpFormatter(); -// formatter.printHelp("launch4j", _options); -// } -} diff --git a/src/main/java/net/sf/launch4j/RcBuilder.java b/src/main/java/net/sf/launch4j/RcBuilder.java deleted file mode 100644 index dceb7b6..0000000 --- a/src/main/java/net/sf/launch4j/RcBuilder.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on 2005-04-24 - */ -package net.sf.launch4j; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.nio.charset.Charset; -import java.util.List; - -import net.sf.launch4j.config.Config; -import net.sf.launch4j.config.ConfigPersister; -import net.sf.launch4j.config.Jre; -import net.sf.launch4j.config.Msg; -import net.sf.launch4j.config.Splash; -import net.sf.launch4j.config.VersionInfo; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class RcBuilder { - - // winnt.h - public static final int LANG_NEUTRAL = 0; - public static final int SUBLANG_NEUTRAL = 0; - public static final int SUBLANG_DEFAULT = 1; - public static final int SUBLANG_SYS_DEFAULT = 2; - - // MANIFEST - public static final int MANIFEST = 1; - - // ICON - public static final int APP_ICON = 1; - - // BITMAP - public static final int SPLASH_BITMAP = 1; - - // RCDATA - public static final int JRE_PATH = 1; - public static final int JAVA_MIN_VER = 2; - public static final int JAVA_MAX_VER = 3; - public static final int SHOW_SPLASH = 4; - public static final int SPLASH_WAITS_FOR_WINDOW = 5; - public static final int SPLASH_TIMEOUT = 6; - public static final int SPLASH_TIMEOUT_ERR = 7; - public static final int CHDIR = 8; - public static final int SET_PROC_NAME = 9; - public static final int ERR_TITLE = 10; - public static final int GUI_HEADER_STAYS_ALIVE = 11; - public static final int JVM_OPTIONS = 12; - public static final int CMD_LINE = 13; - public static final int JAR = 14; - public static final int MAIN_CLASS = 15; - public static final int CLASSPATH = 16; - public static final int WRAPPER = 17; - public static final int JDK_PREFERENCE = 18; - public static final int ENV_VARIABLES = 19; - public static final int PRIORITY_CLASS = 20; - public static final int DOWNLOAD_URL = 21; - public static final int SUPPORT_URL = 22; - public static final int MUTEX_NAME = 23; - public static final int INSTANCE_WINDOW_TITLE = 24; - public static final int INITIAL_HEAP_SIZE = 25; - public static final int INITIAL_HEAP_PERCENT = 26; - public static final int MAX_HEAP_SIZE = 27; - public static final int MAX_HEAP_PERCENT = 28; - - public static final int STARTUP_ERR = 101; - public static final int BUNDLED_JRE_ERR = 102; - public static final int JRE_VERSION_ERR = 103; - public static final int LAUNCHER_ERR = 104; - public static final int INSTANCE_ALREADY_EXISTS_MSG = 105; - - private final StringBuffer _sb = new StringBuffer(); - - public String getContent() { - return _sb.toString(); - } - - public String getLine(int line) { - return _sb.toString().split("\n")[line - 1]; - } - - public File build(Config c) throws IOException { - _sb.append("LANGUAGE "); - _sb.append(LANG_NEUTRAL); - _sb.append(", "); - _sb.append(SUBLANG_DEFAULT); - _sb.append('\n'); - addVersionInfo(c.getVersionInfo()); - addJre(c.getJre()); - addManifest(MANIFEST, c.getManifest()); - addIcon(APP_ICON, c.getIcon()); - addText(ERR_TITLE, c.getErrTitle()); - addText(DOWNLOAD_URL, c.getDownloadUrl()); - addText(SUPPORT_URL, c.getSupportUrl()); - addText(CMD_LINE, c.getCmdLine()); - addWindowsPath(CHDIR, c.getChdir()); - addText(PRIORITY_CLASS, String.valueOf(c.getPriorityClass())); - addTrue(SET_PROC_NAME, c.isCustomProcName()); - addTrue(GUI_HEADER_STAYS_ALIVE, c.isStayAlive()); - addSplash(c.getSplash()); - addMessages(c); - - if (c.getSingleInstance() != null) { - addText(MUTEX_NAME, c.getSingleInstance().getMutexName()); - addText(INSTANCE_WINDOW_TITLE, c.getSingleInstance().getWindowTitle()); - } - - if (c.getVariables() != null && !c.getVariables().isEmpty()) { - StringBuffer vars = new StringBuffer(); - append(vars, c.getVariables(), "\t"); - addText(ENV_VARIABLES, vars.toString()); - } - - // MAIN_CLASS / JAR - addTrue(WRAPPER, !c.isDontWrapJar()); - if (c.getClassPath() != null) { - addText(MAIN_CLASS, c.getClassPath().getMainClass()); - addWindowsPath(CLASSPATH, c.getClassPath().getPathsString()); - } - if (c.isDontWrapJar() && c.getJar() != null) { - addWindowsPath(JAR, c.getJar().getPath()); - } - - File f = Util.createTempFile("rc"); - Writer fw = new OutputStreamWriter(new FileOutputStream(f), Charset.forName("ISO-8859-1")); - BufferedWriter w = new BufferedWriter(fw); - w.write(_sb.toString()); - w.close(); - return f; - } - - private void addVersionInfo(VersionInfo v) { - if (v == null) { - return; - } - _sb.append("1 VERSIONINFO\n"); - _sb.append("FILEVERSION "); - _sb.append(v.getFileVersion().replaceAll("\\.", ", ")); - _sb.append("\nPRODUCTVERSION "); - _sb.append(v.getProductVersion().replaceAll("\\.", ", ")); - _sb.append("\nFILEFLAGSMASK 0\n" + - "FILEOS 0x40000\n" + - "FILETYPE 1\n" + - "{\n" + - " BLOCK \"StringFileInfo\"\n" + - " {\n" + - " BLOCK \"040904E4\"\n" + // English - " {\n"); - addVerBlockValue("CompanyName", v.getCompanyName()); - addVerBlockValue("FileDescription", v.getFileDescription()); - addVerBlockValue("FileVersion", v.getTxtFileVersion()); - addVerBlockValue("InternalName", v.getInternalName()); - addVerBlockValue("LegalCopyright", v.getCopyright()); - addVerBlockValue("OriginalFilename", v.getOriginalFilename()); - addVerBlockValue("ProductName", v.getProductName()); - addVerBlockValue("ProductVersion", v.getTxtProductVersion()); - _sb.append(" }\n }\nBLOCK \"VarFileInfo\"\n{\nVALUE \"Translation\", 0x0409, 0x04E4\n}\n}"); - } - - private void addJre(Jre jre) { - addWindowsPath(JRE_PATH, jre.getPath()); - addText(JAVA_MIN_VER, jre.getMinVersion()); - addText(JAVA_MAX_VER, jre.getMaxVersion()); - addText(JDK_PREFERENCE, String.valueOf(jre.getJdkPreferenceIndex())); - addInteger(INITIAL_HEAP_SIZE, jre.getInitialHeapSize()); - addInteger(INITIAL_HEAP_PERCENT, jre.getInitialHeapPercent()); - addInteger(MAX_HEAP_SIZE, jre.getMaxHeapSize()); - addInteger(MAX_HEAP_PERCENT, jre.getMaxHeapPercent()); - - StringBuffer options = new StringBuffer(); - if (jre.getOptions() != null && !jre.getOptions().isEmpty()) { - addSpace(options); - append(options, jre.getOptions(), " "); - } - addText(JVM_OPTIONS, options.toString()); - } - - private void addSplash(Splash splash) { - if (splash == null) { - return; - } - addTrue(SHOW_SPLASH, true); - addTrue(SPLASH_WAITS_FOR_WINDOW, splash.getWaitForWindow()); - addText(SPLASH_TIMEOUT, String.valueOf(splash.getTimeout())); - addTrue(SPLASH_TIMEOUT_ERR, splash.isTimeoutErr()); - addBitmap(SPLASH_BITMAP, splash.getFile()); - } - - private void addMessages(Config c) { - Msg msg = c.getMessages(); - if (msg == null) { - msg = new Msg(); - } - addText(STARTUP_ERR, msg.getStartupErr()); - addText(BUNDLED_JRE_ERR, msg.getBundledJreErr()); - addText(JRE_VERSION_ERR, msg.getJreVersionErr()); - addText(LAUNCHER_ERR, msg.getLauncherErr()); - if (c.getSingleInstance() != null) { - addText(INSTANCE_ALREADY_EXISTS_MSG, msg.getInstanceAlreadyExistsMsg()); - } - } - - private void append(StringBuffer sb, List list, String separator) { - for (int i = 0; i < list.size(); i++) { - sb.append(list.get(i)); - if (i < list.size() - 1) { - sb.append(separator); - } - } - } - - private void addText(int id, String text) { - if (text == null || text.equals("")) { - return; - } - _sb.append(id); - _sb.append(" RCDATA BEGIN \""); - _sb.append(escape(text)); - _sb.append("\\0\" END\n"); - } - - private void addTrue(int id, boolean value) { - if (value) { - addText(id, "true"); - } - } - - private void addInteger(int id, Integer value) { - if (value != null) { - addText(id, value.toString()); - } - } - - /** - * Stores path in Windows format with '\' separators. - */ - private void addWindowsPath(int id, String path) { - if (path == null || path.equals("")) { - return; - } - _sb.append(id); - _sb.append(" RCDATA BEGIN \""); - _sb.append(path.replaceAll("\\\\", "\\\\\\\\") - .replaceAll("/", "\\\\\\\\")); - _sb.append("\\0\" END\n"); - } - - private void addManifest(int id, File manifest) { - if (manifest == null || manifest.getPath().equals("")) { - return; - } - _sb.append(id); - _sb.append(" 24 \""); - _sb.append(getPath(Util.getAbsoluteFile( - ConfigPersister.getInstance().getConfigPath(), manifest))); - _sb.append("\"\n"); - } - - private void addIcon(int id, File icon) { - if (icon == null || icon.getPath().equals("")) { - return; - } - _sb.append(id); - _sb.append(" ICON DISCARDABLE \""); - _sb.append(getPath(Util.getAbsoluteFile( - ConfigPersister.getInstance().getConfigPath(), icon))); - _sb.append("\"\n"); - } - - private void addBitmap(int id, File bitmap) { - if (bitmap == null) { - return; - } - _sb.append(id); - _sb.append(" BITMAP \""); - _sb.append(getPath(Util.getAbsoluteFile( - ConfigPersister.getInstance().getConfigPath(), bitmap))); - _sb.append("\"\n"); - } - - private String getPath(File f) { - return f.getPath().replaceAll("\\\\", "\\\\\\\\"); - } - - private void addSpace(StringBuffer sb) { - int len = sb.length(); - if (len-- > 0 && sb.charAt(len) != ' ') { - sb.append(' '); - } - } - - private void addVerBlockValue(String key, String value) { - _sb.append(" VALUE \""); - _sb.append(key); - _sb.append("\", \""); - if (value != null) { - _sb.append(escape(value)); - } - _sb.append("\"\n"); - } - - private String escape(String text) { - return text.replaceAll("\"", "\"\""); - } -} diff --git a/src/main/java/net/sf/launch4j/Util.java b/src/main/java/net/sf/launch4j/Util.java deleted file mode 100644 index 88ff711..0000000 --- a/src/main/java/net/sf/launch4j/Util.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on 2005-04-24 - */ -package net.sf.launch4j; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class Util { - public static final boolean WINDOWS_OS = System.getProperty("os.name") - .toLowerCase().startsWith("windows"); - - private Util() {} - - public static File createTempFile(String suffix) throws IOException { - String tmpdir = System.getProperty("launch4j.tmpdir"); - if (tmpdir != null) { - if (tmpdir.indexOf(' ') != -1) { - throw new IOException(Messages.getString("Util.tmpdir")); - } - return File.createTempFile("launch4j", suffix, new File(tmpdir)); - } else { - return File.createTempFile("launch4j", suffix); - } - } - - /** - * Returns the base directory of a jar file or null if the class is a standalone file. - * @return System specific path - * - * Based on a patch submitted by Josh Elsasser - */ - public static File getJarBasedir() { - String url = Util.class.getClassLoader() - .getResource(Util.class.getName().replace('.', '/') + ".class") - .getFile() - .replaceAll("%20", " "); - if (url.startsWith("file:")) { - String jar = url.substring(5, url.lastIndexOf('!')); - int x = jar.lastIndexOf('/'); - if (x == -1) { - x = jar.lastIndexOf('\\'); - } - String basedir = jar.substring(0, x + 1); - return new File(basedir); - } else { - return new File("."); - } - } - - public static File getAbsoluteFile(File basepath, File f) { - return f.isAbsolute() ? f : new File(basepath, f.getPath()); - } - - public static String getExtension(File f) { - String name = f.getName(); - int x = name.lastIndexOf('.'); - if (x != -1) { - return name.substring(x); - } else { - return ""; - } - } - - public static void exec(String[] cmd, Log log) throws ExecException { - BufferedReader is = null; - try { - if (WINDOWS_OS) { - for (int i = 0; i < cmd.length; i++) { - cmd[i] = cmd[i].replaceAll("/", "\\\\"); - } - } - Process p = Runtime.getRuntime().exec(cmd); - is = new BufferedReader(new InputStreamReader(p.getErrorStream())); - String line; - int errLine = -1; - Pattern pattern = Pattern.compile(":\\d+:"); - while ((line = is.readLine()) != null) { - log.append(line); - Matcher matcher = pattern.matcher(line); - if (matcher.find()) { - errLine = Integer.valueOf( - line.substring(matcher.start() + 1, matcher.end() - 1)) - .intValue(); - if (line.matches("(?i).*unrecognized escape sequence")) { - log.append(Messages.getString("Util.use.double.backslash")); - } - break; - } - } - is.close(); - p.waitFor(); - if (errLine != -1) { - StringBuffer sb = new StringBuffer(Messages.getString("Util.exec.failed")); - AppendCommandLine(sb, cmd); - throw new ExecException(sb.toString(), errLine); - } - if (p.exitValue() != 0) { - StringBuffer sb = new StringBuffer(Messages.getString("Util.exec.failed")); - sb.append(" ("); - sb.append(p.exitValue()); - sb.append(')'); - AppendCommandLine(sb, cmd); - throw new ExecException(sb.toString()); - } - } catch (IOException e) { - close(is); - throw new ExecException(e); - } catch (InterruptedException e) { - close(is); - throw new ExecException(e); - } - } - - private static void AppendCommandLine(StringBuffer sb, String[] cmd) { - sb.append(": "); - for (int i = 0; i < cmd.length; i++) { - sb.append(cmd[i]); - if (i < cmd.length - 1) { - sb.append(' '); - } - } - } - - public static void close(final InputStream o) { - if (o != null) { - try { - o.close(); - } catch (IOException e) { - System.err.println(e); // XXX log - } - } - } - - public static void close(final OutputStream o) { - if (o != null) { - try { - o.close(); - } catch (IOException e) { - System.err.println(e); // XXX log - } - } - } - - public static void close(final Reader o) { - if (o != null) { - try { - o.close(); - } catch (IOException e) { - System.err.println(e); // XXX log - } - } - } - - public static void close(final Writer o) { - if (o != null) { - try { - o.close(); - } catch (IOException e) { - System.err.println(e); // XXX log - } - } - } - - public static boolean delete(File f) { - return (f != null) ? f.delete() : false; - } -} diff --git a/src/main/java/net/sf/launch4j/ant/AntClassPath.java b/src/main/java/net/sf/launch4j/ant/AntClassPath.java deleted file mode 100644 index a67bab9..0000000 --- a/src/main/java/net/sf/launch4j/ant/AntClassPath.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Jul 19, 2006 - */ -package net.sf.launch4j.ant; - -import java.util.ArrayList; -import java.util.List; - -import net.sf.launch4j.config.ClassPath; - -/** - * @author Copyright (C) 2006 Grzegorz Kowal - */ -public class AntClassPath extends ClassPath { - private final List wrappedPaths = new ArrayList(); - - public void setCp(String cp){ - wrappedPaths.add(cp); - } - - public void addCp(StringWrapper cp) { - wrappedPaths.add(cp); - } - - public void unwrap() { - setPaths(StringWrapper.unwrap(wrappedPaths)); - } -} diff --git a/src/main/java/net/sf/launch4j/ant/AntConfig.java b/src/main/java/net/sf/launch4j/ant/AntConfig.java deleted file mode 100644 index 4482436..0000000 --- a/src/main/java/net/sf/launch4j/ant/AntConfig.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 24, 2005 - */ -package net.sf.launch4j.ant; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tools.ant.BuildException; - -import net.sf.launch4j.config.Config; -import net.sf.launch4j.config.Msg; -import net.sf.launch4j.config.SingleInstance; -import net.sf.launch4j.config.Splash; -import net.sf.launch4j.config.VersionInfo; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class AntConfig extends Config { - private final List wrappedHeaderObjects = new ArrayList(); - private final List wrappedLibs = new ArrayList(); - private final List wrappedVariables = new ArrayList(); - - public void setJarPath(String path) { - setJar(new File(path)); - } - - public void addObj(StringWrapper obj) { - wrappedHeaderObjects.add(obj); - } - - public void addLib(StringWrapper lib) { - wrappedLibs.add(lib); - } - - public void addVar(StringWrapper var) { - wrappedVariables.add(var); - } - - // __________________________________________________________________________________ - - public void addSingleInstance(SingleInstance singleInstance) { - checkNull(getSingleInstance(), "singleInstance"); - setSingleInstance(singleInstance); - } - - public void addClassPath(AntClassPath classPath) { - checkNull(getClassPath(), "classPath"); - setClassPath(classPath); - } - - public void addJre(AntJre jre) { - checkNull(getJre(), "jre"); - setJre(jre); - } - - public void addSplash(Splash splash) { - checkNull(getSplash(), "splash"); - setSplash(splash); - } - - public void addVersionInfo(VersionInfo versionInfo) { - checkNull(getVersionInfo(), "versionInfo"); - setVersionInfo(versionInfo); - } - - public void addMessages(Msg messages) { - checkNull(getMessages(), "messages"); - setMessages(messages); - } - - // __________________________________________________________________________________ - - public void unwrap() { - setHeaderObjects(StringWrapper.unwrap(wrappedHeaderObjects)); - setLibs(StringWrapper.unwrap(wrappedLibs)); - setVariables(StringWrapper.unwrap(wrappedVariables)); - if (getClassPath() != null) { - ((AntClassPath) getClassPath()).unwrap(); - } - if (getJre() != null) { - ((AntJre) getJre()).unwrap(); - } - } - - private void checkNull(Object o, String name) { - if (o != null) { - throw new BuildException( - Messages.getString("AntConfig.duplicate.element") - + ": " - + name); - } - } -} diff --git a/src/main/java/net/sf/launch4j/ant/AntJre.java b/src/main/java/net/sf/launch4j/ant/AntJre.java deleted file mode 100644 index b83e3ee..0000000 --- a/src/main/java/net/sf/launch4j/ant/AntJre.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Jul 18, 2006 - */ -package net.sf.launch4j.ant; - -import java.util.ArrayList; -import java.util.List; - -import net.sf.launch4j.config.Jre; - -/** - * @author Copyright (C) 2006 Grzegorz Kowal - */ -public class AntJre extends Jre { - private final List wrappedOptions = new ArrayList(); - - public void addOpt(StringWrapper opt) { - wrappedOptions.add(opt); - } - - public void unwrap() { - setOptions(StringWrapper.unwrap(wrappedOptions)); - } - - /** - * For backwards compatibility. - */ - public void setDontUsePrivateJres(boolean dontUse) { - if (dontUse) { - setJdkPreference(JDK_PREFERENCE_JRE_ONLY); - } - else { - setJdkPreference(JDK_PREFERENCE_PREFER_JRE); - } - } -} diff --git a/src/main/java/net/sf/launch4j/ant/Launch4jTask.java b/src/main/java/net/sf/launch4j/ant/Launch4jTask.java deleted file mode 100644 index a282876..0000000 --- a/src/main/java/net/sf/launch4j/ant/Launch4jTask.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 24, 2005 - */ -package net.sf.launch4j.ant; - -import java.io.File; - -import net.sf.launch4j.Builder; -import net.sf.launch4j.BuilderException; -import net.sf.launch4j.Log; -import net.sf.launch4j.config.Config; -import net.sf.launch4j.config.ConfigPersister; -import net.sf.launch4j.config.ConfigPersisterException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class Launch4jTask extends Task { - private File _configFile; - private AntConfig _config; - - // System properties - private File tmpdir; // launch4j.tmpdir - private File bindir; // launch4j.bindir - - // Override configFile settings - private File jar; - private File outfile; - private String fileVersion; - private String txtFileVersion; - private String productVersion; - private String txtProductVersion; - - public void execute() throws BuildException { - try { - if (tmpdir != null) { - System.setProperty("launch4j.tmpdir", tmpdir.getPath()); - } - if (bindir != null) { - System.setProperty("launch4j.bindir", bindir.getPath()); - } - if (_configFile != null && _config != null) { - throw new BuildException( - Messages.getString("Launch4jTask.specify.config")); - } else if (_configFile != null) { - ConfigPersister.getInstance().load(_configFile); - Config c = ConfigPersister.getInstance().getConfig(); - if (jar != null) { - c.setJar(jar); - } - if (outfile != null) { - c.setOutfile(outfile); - } - if (fileVersion != null) { - c.getVersionInfo().setFileVersion(fileVersion); - } - if (txtFileVersion != null) { - c.getVersionInfo().setTxtFileVersion(txtFileVersion); - } - if (productVersion != null) { - c.getVersionInfo().setProductVersion(productVersion); - } - if (txtProductVersion != null) { - c.getVersionInfo().setTxtProductVersion(txtProductVersion); - } - } else if (_config != null) { - _config.unwrap(); - ConfigPersister.getInstance().setAntConfig(_config, - getProject().getBaseDir()); - } else { - throw new BuildException( - Messages.getString("Launch4jTask.specify.config")); - } - final Builder b = new Builder(Log.getAntLog()); - b.build(); - } catch (ConfigPersisterException e) { - throw new BuildException(e); - } catch (BuilderException e) { - throw new BuildException(e); - } - } - - public void setConfigFile(File configFile) { - _configFile = configFile; - } - - public void addConfig(AntConfig config) { - _config = config; - } - - public void setBindir(File bindir) { - this.bindir = bindir; - } - - public void setTmpdir(File tmpdir) { - this.tmpdir = tmpdir; - } - - public void setFileVersion(String fileVersion) { - this.fileVersion = fileVersion; - } - - public void setJar(File jar) { - this.jar = jar; - } - - public void setJarPath(String path) { - this.jar = new File(path); - } - - public void setOutfile(File outfile) { - this.outfile = outfile; - } - - public void setProductVersion(String productVersion) { - this.productVersion = productVersion; - } - - public void setTxtFileVersion(String txtFileVersion) { - this.txtFileVersion = txtFileVersion; - } - - public void setTxtProductVersion(String txtProductVersion) { - this.txtProductVersion = txtProductVersion; - } -} diff --git a/src/main/java/net/sf/launch4j/ant/Messages.java b/src/main/java/net/sf/launch4j/ant/Messages.java deleted file mode 100644 index 0f823f7..0000000 --- a/src/main/java/net/sf/launch4j/ant/Messages.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package net.sf.launch4j.ant; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "net.sf.launch4j.ant.messages"; - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/src/main/java/net/sf/launch4j/ant/StringWrapper.java b/src/main/java/net/sf/launch4j/ant/StringWrapper.java deleted file mode 100644 index 6d38af1..0000000 --- a/src/main/java/net/sf/launch4j/ant/StringWrapper.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Jul 18, 2006 - */ -package net.sf.launch4j.ant; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * @author Copyright (C) 2006 Grzegorz Kowal - */ -public class StringWrapper { - private String text; - - public static List unwrap(List wrappers) { - if (wrappers.isEmpty()) { - return null; - } - List strings = new ArrayList(wrappers.size()); - for (Iterator iter = wrappers.iterator(); iter.hasNext();) { - strings.add(iter.next().toString()); - } - return strings; - } - - public void addText(String text) { - this.text = text; - } - - public String toString() { - return text; - } -} diff --git a/src/main/java/net/sf/launch4j/binding/Binding.java b/src/main/java/net/sf/launch4j/binding/Binding.java deleted file mode 100644 index 49c9b45..0000000 --- a/src/main/java/net/sf/launch4j/binding/Binding.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 30, 2005 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public interface Binding { - /** Used to mark components with invalid data. */ - public final static Color INVALID_COLOR = Color.PINK; - - /** Java Bean property bound to a component */ - public String getProperty(); - /** Clear component, set it to the default value */ - public void clear(IValidatable bean); - /** Java Bean property -> Component */ - public void put(IValidatable bean); - /** Component -> Java Bean property */ - public void get(IValidatable bean); - /** Mark component as valid */ - public void markValid(); - /** Mark component as invalid */ - public void markInvalid(); - /** Enable or disable the component */ - public void setEnabled(boolean enabled); -} diff --git a/src/main/java/net/sf/launch4j/binding/BindingException.java b/src/main/java/net/sf/launch4j/binding/BindingException.java deleted file mode 100644 index 15dc10c..0000000 --- a/src/main/java/net/sf/launch4j/binding/BindingException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 30, 2005 - */ -package net.sf.launch4j.binding; - -/** - * Signals a runtime error, a missing property in a Java Bean for example. - * - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class BindingException extends RuntimeException { - public BindingException(Throwable t) { - super(t); - } - - public BindingException(String msg) { - super(msg); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/Bindings.java b/src/main/java/net/sf/launch4j/binding/Bindings.java deleted file mode 100644 index 73f507e..0000000 --- a/src/main/java/net/sf/launch4j/binding/Bindings.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 30, 2005 - */ -package net.sf.launch4j.binding; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JRadioButton; -import javax.swing.JTextArea; -import javax.swing.JToggleButton; -import javax.swing.text.JTextComponent; - -import org.apache.commons.beanutils.PropertyUtils; - -/** - * Creates and handles bindings. - * - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class Bindings implements PropertyChangeListener { - private final Map _bindings = new HashMap(); - private final Map _optComponents = new HashMap(); - private boolean _modified = false; - - /** - * Used to track component modifications. - */ - public void propertyChange(PropertyChangeEvent evt) { - String prop = evt.getPropertyName(); - if ("AccessibleValue".equals(prop) - || "AccessibleText".equals(prop) - || "AccessibleVisibleData".equals(prop)) { - _modified = true; - } - } - - /** - * Any of the components modified? - */ - public boolean isModified() { - return _modified; - } - - public Binding getBinding(String property) { - return (Binding) _bindings.get(property); - } - - private void registerPropertyChangeListener(JComponent c) { - c.getAccessibleContext().addPropertyChangeListener(this); - } - - private void registerPropertyChangeListener(JComponent[] cs) { - for (int i = 0; i < cs.length; i++) { - cs[i].getAccessibleContext().addPropertyChangeListener(this); - } - } - - private boolean isPropertyNull(IValidatable bean, Binding b) { - try { - for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) { - String property = (String) iter.next(); - if (b.getProperty().startsWith(property)) { - return PropertyUtils.getProperty(bean, property) == null; - } - } - return false; - } catch (Exception e) { - throw new BindingException(e); - } - } - - /** - * Enables or disables all components bound to properties that begin with given prefix. - */ - public void setComponentsEnabled(String prefix, boolean enabled) { - for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) { - Binding b = (Binding) iter.next(); - if (b.getProperty().startsWith(prefix)) { - b.setEnabled(enabled); - } - } - } - - /** - * Clear all components, set them to their default values. - * Clears the _modified flag. - */ - public void clear(IValidatable bean) { - for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) { - ((Binding) iter.next()).clear(bean); - } - for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) { - ((Binding) iter.next()).clear(bean); - } - _modified = false; - } - - /** - * Copies data from the Java Bean to the UI components. - * Clears the _modified flag. - */ - public void put(IValidatable bean) { - for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) { - ((Binding) iter.next()).put(bean); - } - for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) { - Binding b = (Binding) iter.next(); - if (isPropertyNull(bean, b)) { - b.clear(null); - } else { - b.put(bean); - } - } - _modified = false; - } - - /** - * Copies data from UI components to the Java Bean and checks it's class invariants. - * Clears the _modified flag. - * @throws InvariantViolationException - * @throws BindingException - */ - public void get(IValidatable bean) { - try { - for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) { - ((Binding) iter.next()).get(bean); - } - for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) { - Binding b = (Binding) iter.next(); - if (!isPropertyNull(bean, b)) { - b.get(bean); - } - } - bean.checkInvariants(); - for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) { - String property = (String) iter.next(); - IValidatable component = (IValidatable) PropertyUtils.getProperty(bean, - property); - if (component != null) { - component.checkInvariants(); - } - } - _modified = false; // XXX - } catch (InvariantViolationException e) { - e.setBinding(getBinding(e.getProperty())); - throw e; - } catch (Exception e) { - throw new BindingException(e); - } - } - - private Bindings add(Binding b) { - if (_bindings.containsKey(b.getProperty())) { - throw new BindingException(Messages.getString("Bindings.duplicate.binding")); - } - _bindings.put(b.getProperty(), b); - return this; - } - - /** - * Add an optional (nullable) Java Bean component of type clazz. - */ - public Bindings addOptComponent(String property, Class clazz, JToggleButton c, - boolean enabledByDefault) { - Binding b = new OptComponentBinding(this, property, clazz, c, enabledByDefault); - if (_optComponents.containsKey(property)) { - throw new BindingException(Messages.getString("Bindings.duplicate.binding")); - } - _optComponents.put(property, b); - return this; - } - - /** - * Add an optional (nullable) Java Bean component of type clazz. - */ - public Bindings addOptComponent(String property, Class clazz, JToggleButton c) { - return addOptComponent(property, clazz, c, false); - } - - /** - * Handles JEditorPane, JTextArea, JTextField - */ - public Bindings add(String property, JTextComponent c, String defaultValue) { - registerPropertyChangeListener(c); - return add(new JTextComponentBinding(property, c, defaultValue)); - } - - /** - * Handles JEditorPane, JTextArea, JTextField - */ - public Bindings add(String property, JTextComponent c) { - registerPropertyChangeListener(c); - return add(new JTextComponentBinding(property, c, "")); - } - - /** - * Handles JToggleButton, JCheckBox - */ - public Bindings add(String property, JToggleButton c, boolean defaultValue) { - registerPropertyChangeListener(c); - return add(new JToggleButtonBinding(property, c, defaultValue)); - } - - /** - * Handles JToggleButton, JCheckBox - */ - public Bindings add(String property, JToggleButton c) { - registerPropertyChangeListener(c); - return add(new JToggleButtonBinding(property, c, false)); - } - - /** - * Handles JRadioButton - */ - public Bindings add(String property, JRadioButton[] cs, int defaultValue) { - registerPropertyChangeListener(cs); - return add(new JRadioButtonBinding(property, cs, defaultValue)); - } - - /** - * Handles JRadioButton - */ - public Bindings add(String property, JRadioButton[] cs) { - registerPropertyChangeListener(cs); - return add(new JRadioButtonBinding(property, cs, 0)); - } - - /** - * Handles JTextArea - */ - public Bindings add(String property, JTextArea textArea, String defaultValue) { - registerPropertyChangeListener(textArea); - return add(new JTextComponentBinding(property, textArea, defaultValue)); - } - - /** - * Handles JTextArea lists - */ - public Bindings add(String property, JTextArea textArea) { - registerPropertyChangeListener(textArea); - return add(new JTextAreaBinding(property, textArea)); - } - - /** - * Handles Optional JTextArea lists - */ - public Bindings add(String property, String stateProperty, - JToggleButton button, JTextArea textArea) { - registerPropertyChangeListener(button); - registerPropertyChangeListener(textArea); - return add(new OptJTextAreaBinding(property, stateProperty, button, textArea)); - } - - /** - * Handles JList - */ - public Bindings add(String property, JList list) { - registerPropertyChangeListener(list); - return add(new JListBinding(property, list)); - } - - /** - * Handles JComboBox - */ - public Bindings add(String property, JComboBox combo, int defaultValue) { - registerPropertyChangeListener(combo); - return add(new JComboBoxBinding(property, combo, defaultValue)); - } - - /** - * Handles JComboBox - */ - public Bindings add(String property, JComboBox combo) { - registerPropertyChangeListener(combo); - return add(new JComboBoxBinding(property, combo, 0)); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/IValidatable.java b/src/main/java/net/sf/launch4j/binding/IValidatable.java deleted file mode 100644 index fe0dd48..0000000 --- a/src/main/java/net/sf/launch4j/binding/IValidatable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on 2004-01-30 - */ -package net.sf.launch4j.binding; - -/** - * @author Copyright (C) 2004 Grzegorz Kowal - */ -public interface IValidatable { - public void checkInvariants(); -} diff --git a/src/main/java/net/sf/launch4j/binding/InvariantViolationException.java b/src/main/java/net/sf/launch4j/binding/InvariantViolationException.java deleted file mode 100644 index 2f7f88b..0000000 --- a/src/main/java/net/sf/launch4j/binding/InvariantViolationException.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Jun 23, 2003 - */ -package net.sf.launch4j.binding; - -/** - * @author Copyright (C) 2003 Grzegorz Kowal - */ -public class InvariantViolationException extends RuntimeException { - private final String _property; - private Binding _binding; - - public InvariantViolationException(String msg) { - super(msg); - _property = null; - } - - public InvariantViolationException(String property, String msg) { - super(msg); - _property = property; - } - - public String getProperty() { - return _property; - } - - public Binding getBinding() { - return _binding; - } - - public void setBinding(Binding binding) { - _binding = binding; - } -} diff --git a/src/main/java/net/sf/launch4j/binding/JComboBoxBinding.java b/src/main/java/net/sf/launch4j/binding/JComboBoxBinding.java deleted file mode 100644 index 61b5d6d..0000000 --- a/src/main/java/net/sf/launch4j/binding/JComboBoxBinding.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2007 Ian Roberts - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 10, 2005 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; - -import javax.swing.JComboBox; - -import org.apache.commons.beanutils.PropertyUtils; - -/** - * @author Copyright (C) 2007 Ian Roberts - */ -public class JComboBoxBinding implements Binding { - private final String _property; - private final JComboBox _combo; - private final int _defaultValue; - private final Color _validColor; - - public JComboBoxBinding(String property, JComboBox combo, int defaultValue) { - if (property == null || combo == null) { - throw new NullPointerException(); - } - if (property.equals("") - || combo.getItemCount() == 0 - || defaultValue < 0 || defaultValue >= combo.getItemCount()) { - throw new IllegalArgumentException(); - } - _property = property; - _combo = combo; - _defaultValue = defaultValue; - _validColor = combo.getBackground(); - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - select(_defaultValue); - } - - public void put(IValidatable bean) { - try { - Integer i = (Integer) PropertyUtils.getProperty(bean, _property); - if (i == null) { - throw new BindingException( - Messages.getString("JComboBoxBinding.property.null")); - } - select(i.intValue()); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - PropertyUtils.setProperty(bean, _property, new Integer(_combo.getSelectedIndex())); - return; - } catch (Exception e) { - throw new BindingException(e); - } - } - - private void select(int index) { - if (index < 0 || index >= _combo.getItemCount()) { - throw new BindingException( - Messages.getString("JComboBoxBinding.index.out.of.bounds")); - } - _combo.setSelectedIndex(index); - } - - public void markValid() { - _combo.setBackground(_validColor); - _combo.requestFocusInWindow(); - } - - public void markInvalid() { - _combo.setBackground(Binding.INVALID_COLOR); - } - - public void setEnabled(boolean enabled) { - _combo.setEnabled(enabled); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/JListBinding.java b/src/main/java/net/sf/launch4j/binding/JListBinding.java deleted file mode 100644 index 31dec58..0000000 --- a/src/main/java/net/sf/launch4j/binding/JListBinding.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 1, 2006 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.swing.DefaultListModel; -import javax.swing.JList; - -import org.apache.commons.beanutils.PropertyUtils; - -/** - * @author Copyright (C) 2006 Grzegorz Kowal - */ -public class JListBinding implements Binding { - private final String _property; - private final JList _list; - private final Color _validColor; - - public JListBinding(String property, JList list) { - if (property == null || list == null) { - throw new NullPointerException(); - } - if (property.equals("")) { - throw new IllegalArgumentException(); - } - _property = property; - _list = list; - _validColor = _list.getBackground(); - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - _list.setModel(new DefaultListModel()); - } - - public void put(IValidatable bean) { - try { - DefaultListModel model = new DefaultListModel(); - List list = (List) PropertyUtils.getProperty(bean, _property); - if (list != null) { - for (Iterator iter = list.iterator(); iter.hasNext();) { - model.addElement(iter.next()); - } - } - _list.setModel(model); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - DefaultListModel model = (DefaultListModel) _list.getModel(); - final int size = model.getSize(); - List list = new ArrayList(size); - for (int i = 0; i < size; i++) { - list.add(model.get(i)); - } - PropertyUtils.setProperty(bean, _property, list); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void markValid() { - _list.setBackground(_validColor); - _list.requestFocusInWindow(); - } - - public void markInvalid() { - _list.setBackground(Binding.INVALID_COLOR); - } - - public void setEnabled(boolean enabled) { - _list.setEnabled(enabled); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/JRadioButtonBinding.java b/src/main/java/net/sf/launch4j/binding/JRadioButtonBinding.java deleted file mode 100644 index 9d922be..0000000 --- a/src/main/java/net/sf/launch4j/binding/JRadioButtonBinding.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 10, 2005 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; - -import javax.swing.JRadioButton; - -import org.apache.commons.beanutils.PropertyUtils; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class JRadioButtonBinding implements Binding { - private final String _property; - private final JRadioButton[] _buttons; - private final int _defaultValue; - private final Color _validColor; - - public JRadioButtonBinding(String property, JRadioButton[] buttons, int defaultValue) { - if (property == null || buttons == null) { - throw new NullPointerException(); - } - for (int i = 0; i < buttons.length; i++) { - if (buttons[i] == null) { - throw new NullPointerException(); - } - } - if (property.equals("") - || buttons.length == 0 - || defaultValue < 0 || defaultValue >= buttons.length) { - throw new IllegalArgumentException(); - } - _property = property; - _buttons = buttons; - _defaultValue = defaultValue; - _validColor = buttons[0].getBackground(); - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - select(_defaultValue); - } - - public void put(IValidatable bean) { - try { - Integer i = (Integer) PropertyUtils.getProperty(bean, _property); - if (i == null) { - throw new BindingException( - Messages.getString("JRadioButtonBinding.property.null")); - } - select(i.intValue()); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - for (int i = 0; i < _buttons.length; i++) { - if (_buttons[i].isSelected()) { - PropertyUtils.setProperty(bean, _property, new Integer(i)); - return; - } - } - throw new BindingException( - Messages.getString("JRadioButtonBinding.nothing.selected")); - } catch (Exception e) { - throw new BindingException(e); - } - } - - private void select(int index) { - if (index < 0 || index >= _buttons.length) { - throw new BindingException( - Messages.getString("JRadioButtonBinding.index.out.of.bounds")); - } - _buttons[index].setSelected(true); - } - - public void markValid() { - for (int i = 0; i < _buttons.length; i++) { - if (_buttons[i].isSelected()) { - _buttons[i].setBackground(_validColor); - _buttons[i].requestFocusInWindow(); - return; - } - } - throw new BindingException( - Messages.getString("JRadioButtonBinding.nothing.selected")); - } - - public void markInvalid() { - for (int i = 0; i < _buttons.length; i++) { - if (_buttons[i].isSelected()) { - _buttons[i].setBackground(Binding.INVALID_COLOR); - return; - } - } - throw new BindingException( - Messages.getString("JRadioButtonBinding.nothing.selected")); - } - - public void setEnabled(boolean enabled) { - for (int i = 0; i < _buttons.length; i++) { - _buttons[i].setEnabled(enabled); - } - } -} diff --git a/src/main/java/net/sf/launch4j/binding/JTextAreaBinding.java b/src/main/java/net/sf/launch4j/binding/JTextAreaBinding.java deleted file mode 100644 index d4e8a2c..0000000 --- a/src/main/java/net/sf/launch4j/binding/JTextAreaBinding.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Jun 14, 2006 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JTextArea; - -import org.apache.commons.beanutils.PropertyUtils; - -/** - * @author Copyright (C) 2006 Grzegorz Kowal - */ -public class JTextAreaBinding implements Binding { - private final String _property; - private final JTextArea _textArea; - private final Color _validColor; - - public JTextAreaBinding(String property, JTextArea textArea) { - if (property == null || textArea == null) { - throw new NullPointerException(); - } - if (property.equals("")) { - throw new IllegalArgumentException(); - } - _property = property; - _textArea = textArea; - _validColor = _textArea.getBackground(); - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - put(bean); - } - - public void put(IValidatable bean) { - try { - List list = (List) PropertyUtils.getProperty(bean, _property); - StringBuffer sb = new StringBuffer(); - if (list != null) { - for (int i = 0; i < list.size(); i++) { - sb.append(list.get(i)); - if (i < list.size() - 1) { - sb.append("\n"); - } - } - } - _textArea.setText(sb.toString()); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - String text = _textArea.getText(); - if (!text.equals("")) { - String[] items = text.split("\n"); - List list = new ArrayList(); - for (int i = 0; i < items.length; i++) { - list.add(items[i]); - } - PropertyUtils.setProperty(bean, _property, list); - } else { - PropertyUtils.setProperty(bean, _property, null); - } - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void markValid() { - _textArea.setBackground(_validColor); - _textArea.requestFocusInWindow(); - } - - public void markInvalid() { - _textArea.setBackground(Binding.INVALID_COLOR); - } - - public void setEnabled(boolean enabled) { - _textArea.setEnabled(enabled); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/JTextComponentBinding.java b/src/main/java/net/sf/launch4j/binding/JTextComponentBinding.java deleted file mode 100644 index 6b0dd1b..0000000 --- a/src/main/java/net/sf/launch4j/binding/JTextComponentBinding.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 30, 2005 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; - -import javax.swing.text.JTextComponent; - -import org.apache.commons.beanutils.BeanUtils; - -/** - * Handles JEditorPane, JTextArea, JTextField - * - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class JTextComponentBinding implements Binding { - private final String _property; - private final JTextComponent _textComponent; - private final String _defaultValue; - private final Color _validColor; - - public JTextComponentBinding(String property, JTextComponent textComponent, - String defaultValue) { - if (property == null || textComponent == null || defaultValue == null) { - throw new NullPointerException(); - } - if (property.equals("")) { - throw new IllegalArgumentException(); - } - _property = property; - _textComponent = textComponent; - _defaultValue = defaultValue; - _validColor = _textComponent.getBackground(); - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - _textComponent.setText(_defaultValue); - } - - public void put(IValidatable bean) { - try { - String s = BeanUtils.getProperty(bean, _property); - // XXX displays zeros as blank - _textComponent.setText(s != null && !s.equals("0") ? s : ""); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - BeanUtils.setProperty(bean, _property, _textComponent.getText()); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void markValid() { - _textComponent.setBackground(_validColor); - _textComponent.requestFocusInWindow(); - } - - public void markInvalid() { - _textComponent.setBackground(Binding.INVALID_COLOR); - } - - public void setEnabled(boolean enabled) { - _textComponent.setEnabled(enabled); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/JToggleButtonBinding.java b/src/main/java/net/sf/launch4j/binding/JToggleButtonBinding.java deleted file mode 100644 index a7055cc..0000000 --- a/src/main/java/net/sf/launch4j/binding/JToggleButtonBinding.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 30, 2005 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; - -import javax.swing.JToggleButton; - -import org.apache.commons.beanutils.PropertyUtils; - -/** - * Handles JToggleButton, JCheckBox - * - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class JToggleButtonBinding implements Binding { - private final String _property; - private final JToggleButton _button; - private final boolean _defaultValue; - private final Color _validColor; - - public JToggleButtonBinding(String property, JToggleButton button, - boolean defaultValue) { - if (property == null || button == null) { - throw new NullPointerException(); - } - if (property.equals("")) { - throw new IllegalArgumentException(); - } - _property = property; - _button = button; - _defaultValue = defaultValue; - _validColor = _button.getBackground(); - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - _button.setSelected(_defaultValue); - } - - public void put(IValidatable bean) { - try { - Boolean b = (Boolean) PropertyUtils.getProperty(bean, _property); - _button.setSelected(b != null && b.booleanValue()); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - PropertyUtils.setProperty(bean, _property, - Boolean.valueOf(_button.isSelected())); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void markValid() { - _button.setBackground(_validColor); - _button.requestFocusInWindow(); - } - - public void markInvalid() { - _button.setBackground(Binding.INVALID_COLOR); - } - - public void setEnabled(boolean enabled) { - _button.setEnabled(enabled); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/Messages.java b/src/main/java/net/sf/launch4j/binding/Messages.java deleted file mode 100644 index 91ddff2..0000000 --- a/src/main/java/net/sf/launch4j/binding/Messages.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package net.sf.launch4j.binding; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "net.sf.launch4j.binding.messages"; - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - private static final MessageFormat FORMATTER = new MessageFormat(""); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - - public static String getString(String key, String arg0) { - return getString(key, new Object[] {arg0}); - } - - public static String getString(String key, String arg0, String arg1) { - return getString(key, new Object[] {arg0, arg1}); - } - - public static String getString(String key, String arg0, String arg1, String arg2) { - return getString(key, new Object[] {arg0, arg1, arg2}); - } - - public static String getString(String key, Object[] args) { - try { - FORMATTER.applyPattern(RESOURCE_BUNDLE.getString(key)); - return FORMATTER.format(args); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/src/main/java/net/sf/launch4j/binding/OptComponentBinding.java b/src/main/java/net/sf/launch4j/binding/OptComponentBinding.java deleted file mode 100644 index b573da6..0000000 --- a/src/main/java/net/sf/launch4j/binding/OptComponentBinding.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 11, 2005 - */ -package net.sf.launch4j.binding; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Arrays; - -import javax.swing.JToggleButton; - -import org.apache.commons.beanutils.PropertyUtils; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class OptComponentBinding implements Binding, ActionListener { - private final Bindings _bindings; - private final String _property; - private final Class _clazz; - private final JToggleButton _button; - private final boolean _enabledByDefault; - - public OptComponentBinding(Bindings bindings, String property, Class clazz, - JToggleButton button, boolean enabledByDefault) { - if (property == null || clazz == null || button == null) { - throw new NullPointerException(); - } - if (property.equals("")) { - throw new IllegalArgumentException(); - } - if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) { - throw new IllegalArgumentException( - Messages.getString("OptComponentBinding.must.implement") - + IValidatable.class); - } - _bindings = bindings; - _property = property; - _clazz = clazz; - _button = button; - _button.addActionListener(this); - _enabledByDefault = enabledByDefault; - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - _button.setSelected(_enabledByDefault); - updateComponents(); - } - - public void put(IValidatable bean) { - try { - Object component = PropertyUtils.getProperty(bean, _property); - _button.setSelected(component != null); - updateComponents(); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - PropertyUtils.setProperty(bean, _property, _button.isSelected() - ? _clazz.newInstance() : null); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void markValid() {} - - public void markInvalid() {} - - public void setEnabled(boolean enabled) {} // XXX implement? - - public void actionPerformed(ActionEvent e) { - updateComponents(); - } - - private void updateComponents() { - _bindings.setComponentsEnabled(_property, _button.isSelected()); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/OptJTextAreaBinding.java b/src/main/java/net/sf/launch4j/binding/OptJTextAreaBinding.java deleted file mode 100644 index 3cea776..0000000 --- a/src/main/java/net/sf/launch4j/binding/OptJTextAreaBinding.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Sep 3, 2005 - */ -package net.sf.launch4j.binding; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JTextArea; -import javax.swing.JToggleButton; - -import org.apache.commons.beanutils.BeanUtils; -import org.apache.commons.beanutils.PropertyUtils; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class OptJTextAreaBinding implements Binding, ActionListener { - private final String _property; - private final String _stateProperty; - private final JToggleButton _button; - private final JTextArea _textArea; - private final Color _validColor; - - public OptJTextAreaBinding(String property, String stateProperty, - JToggleButton button, JTextArea textArea) { - if (property == null || button == null || textArea == null) { - throw new NullPointerException(); - } - if (property.equals("")) { - throw new IllegalArgumentException(); - } - _property = property; - _stateProperty = stateProperty; - _button = button; - _textArea = textArea; - _validColor = _textArea.getBackground(); - button.addActionListener(this); - } - - public String getProperty() { - return _property; - } - - public void clear(IValidatable bean) { - put(bean); - } - - public void put(IValidatable bean) { - try { - boolean selected = "true".equals(BeanUtils.getProperty(bean, - _stateProperty)); - _button.setSelected(selected); - _textArea.setEnabled(selected); - List list = (List) PropertyUtils.getProperty(bean, _property); - StringBuffer sb = new StringBuffer(); - if (list != null) { - for (int i = 0; i < list.size(); i++) { - sb.append(list.get(i)); - if (i < list.size() - 1) { - sb.append("\n"); - } - } - } - _textArea.setText(sb.toString()); - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void get(IValidatable bean) { - try { - String text = _textArea.getText(); - if (_button.isSelected() && !text.equals("")) { - String[] items = text.split("\n"); - List list = new ArrayList(); - for (int i = 0; i < items.length; i++) { - list.add(items[i]); - } - PropertyUtils.setProperty(bean, _property, list); - } else { - PropertyUtils.setProperty(bean, _property, null); - } - } catch (Exception e) { - throw new BindingException(e); - } - } - - public void markValid() { - _textArea.setBackground(_validColor); - _textArea.requestFocusInWindow(); - } - - public void markInvalid() { - _textArea.setBackground(Binding.INVALID_COLOR); - } - - public void setEnabled(boolean enabled) { - _textArea.setEnabled(enabled); - } - - public void actionPerformed(ActionEvent e) { - _textArea.setEnabled(_button.isSelected()); - } -} diff --git a/src/main/java/net/sf/launch4j/binding/Validator.java b/src/main/java/net/sf/launch4j/binding/Validator.java deleted file mode 100644 index 88ea67c..0000000 --- a/src/main/java/net/sf/launch4j/binding/Validator.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on 2004-01-30 - */ -package net.sf.launch4j.binding; - -import java.io.File; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -import net.sf.launch4j.Util; -import net.sf.launch4j.config.ConfigPersister; - -/** - * @author Copyright (C) 2004 Grzegorz Kowal - */ -public class Validator { - public static final String ALPHANUMERIC_PATTERN = "[\\w]*?"; - public static final String ALPHA_PATTERN = "[\\w&&\\D]*?"; - public static final String NUMERIC_PATTERN = "[\\d]*?"; - public static final String PATH_PATTERN = "[\\w|[ .,:\\-/\\\\]]*?"; - - public static final int MAX_STR = 128; - public static final int MAX_PATH = 260; - public static final int MAX_BIG_STR = 8192; // or 16384; - public static final int MAX_ARGS = 32767 - 2048; - - private Validator() {} - - public static boolean isEmpty(String s) { - return s == null || s.equals(""); - } - - public static void checkNotNull(Object o, String property, String name) { - if (o == null) { - signalViolation(property, - Messages.getString("Validator.empty.field", name)); - } - } - - public static void checkString(String s, int maxLength, String property, - String name) { - if (s == null || s.length() == 0) { - signalViolation(property, - Messages.getString("Validator.empty.field", name)); - } - if (s.length() > maxLength) { - signalLengthViolation(property, name, maxLength); - } - } - - public static void checkOptStrings(List strings, int maxLength, int totalMaxLength, - String property, String name) { - if (strings == null) { - return; - } - int totalLength = 0; - for (Iterator iter = strings.iterator(); iter.hasNext();) { - String s = (String) iter.next(); - checkString(s, maxLength, property, name); - totalLength += s.length(); - if (totalLength > totalMaxLength) { - signalLengthViolation(property, name, totalMaxLength); - } - } - } - - public static void checkString(String s, int maxLength, String pattern, - String property, String name) { - checkString(s, maxLength, property, name); - if (!s.matches(pattern)) { - signalViolation(property, - Messages.getString("Validator.invalid.data", name)); - } - } - - public static void checkOptStrings(List strings, int maxLength, int totalMaxLength, - String pattern, String property, String name, String msg) { - if (strings == null) { - return; - } - int totalLength = 0; - for (Iterator iter = strings.iterator(); iter.hasNext();) { - String s = (String) iter.next(); - checkString(s, maxLength, property, name); - if (!s.matches(pattern)) { - signalViolation(property, msg != null - ? msg - : Messages.getString("Validator.invalid.data", name)); - } - totalLength += s.length(); - if (totalLength > totalMaxLength) { - signalLengthViolation(property, name, totalMaxLength); - } - } - } - - public static void checkOptString(String s, int maxLength, String property, - String name) { - if (s == null || s.length() == 0) { - return; - } - if (s.length() > maxLength) { - signalLengthViolation(property, name, maxLength); - } - } - - public static void checkOptString(String s, int maxLength, String pattern, - String property, String name) { - if (s == null || s.length() == 0) { - return; - } - if (s.length() > maxLength) { - signalLengthViolation(property, name, maxLength); - } - if (!s.matches(pattern)) { - signalViolation(property, - Messages.getString("Validator.invalid.data", name)); - } - } - - public static void checkRange(int value, int min, int max, - String property, String name) { - if (value < min || value > max) { - signalViolation(property, - Messages.getString("Validator.must.be.in.range", name, - String.valueOf(min), String.valueOf(max))); - } - } - - public static void checkRange(char value, char min, char max, - String property, String name) { - if (value < min || value > max) { - signalViolation(property, Messages.getString("Validator.must.be.in.range", - name, String.valueOf(min), String.valueOf(max))); - } - } - - public static void checkMin(int value, int min, String property, String name) { - if (value < min) { - signalViolation(property, - Messages.getString("Validator.must.be.at.least", name, - String.valueOf(min))); - } - } - - public static void checkIn(String s, String[] strings, String property, - String name) { - if (isEmpty(s)) { - signalViolation(property, - Messages.getString("Validator.empty.field", name)); - } - List list = Arrays.asList(strings); - if (!list.contains(s)) { - signalViolation(property, - Messages.getString("Validator.invalid.option", name, list.toString())); - } - } - - public static void checkTrue(boolean condition, String property, String msg) { - if (!condition) { - signalViolation(property, msg); - } - } - - public static void checkFalse(boolean condition, String property, String msg) { - if (condition) { - signalViolation(property, msg); - } - } - - public static void checkElementsNotNullUnique(Collection c, String property, - String msg) { - if (c.contains(null) - || new HashSet(c).size() != c.size()) { - signalViolation(property, - Messages.getString("Validator.already.exists", msg)); - } - } - - public static void checkElementsUnique(Collection c, String property, String msg) { - if (new HashSet(c).size() != c.size()) { - signalViolation(property, - Messages.getString("Validator.already.exists", msg)); - } - } - - public static void checkFile(File f, String property, String fileDescription) { - File cfgPath = ConfigPersister.getInstance().getConfigPath(); - if (f == null - || f.getPath().equals("") - || (!f.exists() && !Util.getAbsoluteFile(cfgPath, f).exists())) { - signalViolation(property, - Messages.getString("Validator.doesnt.exist", fileDescription)); - } - } - - public static void checkOptFile(File f, String property, String fileDescription) { - if (f != null && f.getPath().length() > 0) { - checkFile(f, property, fileDescription); - } - } - - public static void checkRelativeWinPath(String path, String property, String msg) { - if (path == null - || path.equals("") - || path.startsWith("/") - || path.startsWith("\\") - || path.indexOf(':') != -1) { - signalViolation(property, msg); - } - } - - public static void signalLengthViolation(String property, String name, - int maxLength) { - signalViolation(property, - Messages.getString("Validator.exceeds.max.length", name, - String.valueOf(maxLength))); - } - - public static void signalViolation(String property, String msg) { - throw new InvariantViolationException(property, msg); - } -} diff --git a/src/main/java/net/sf/launch4j/config/ClassPath.java b/src/main/java/net/sf/launch4j/config/ClassPath.java deleted file mode 100644 index da7dbd6..0000000 --- a/src/main/java/net/sf/launch4j/config/ClassPath.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 1, 2006 - */ -package net.sf.launch4j.config; - -import java.util.List; - -import net.sf.launch4j.binding.IValidatable; -import net.sf.launch4j.binding.Validator; - -/** - * @author Copyright (C) 2006 Grzegorz Kowal - */ -public class ClassPath implements IValidatable { - private String mainClass; - private List paths; - - public void checkInvariants() { - Validator.checkString(mainClass, Validator.MAX_PATH, "mainClass", - Messages.getString("ClassPath.mainClass")); - Validator.checkOptStrings(paths, - Validator.MAX_PATH, - Validator.MAX_BIG_STR, - "paths", - Messages.getString("ClassPath.path")); - } - - public String getMainClass() { - return mainClass; - } - - public void setMainClass(String mainClass) { - this.mainClass = mainClass; - } - - public List getPaths() { - return paths; - } - - public void setPaths(List paths) { - this.paths = paths; - } - - public String getPathsString() { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < paths.size(); i++) { - sb.append(paths.get(i)); - if (i < paths.size() - 1) { - sb.append(';'); - } - } - return sb.toString(); - } -} diff --git a/src/main/java/net/sf/launch4j/config/Config.java b/src/main/java/net/sf/launch4j/config/Config.java deleted file mode 100644 index 27633bf..0000000 --- a/src/main/java/net/sf/launch4j/config/Config.java +++ /dev/null @@ -1,396 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 21, 2005 - */ -package net.sf.launch4j.config; - -import java.io.File; -import java.util.Arrays; -import java.util.List; - -import net.sf.launch4j.binding.IValidatable; -import net.sf.launch4j.binding.Validator; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class Config implements IValidatable { - - // 1.x config properties_____________________________________________________________ - public static final String HEADER = "header"; - public static final String JAR = "jar"; - public static final String OUTFILE = "outfile"; - public static final String ERR_TITLE = "errTitle"; - public static final String JAR_ARGS = "jarArgs"; - public static final String CHDIR = "chdir"; - public static final String CUSTOM_PROC_NAME = "customProcName"; - public static final String STAY_ALIVE = "stayAlive"; - public static final String ICON = "icon"; - - // __________________________________________________________________________________ - public static final String DOWNLOAD_URL = "http://java.com/download"; - - public static final String GUI_HEADER = "gui"; - public static final String CONSOLE_HEADER = "console"; - - private static final String[] HEADER_TYPES = new String[] { GUI_HEADER, - CONSOLE_HEADER }; - - private static final String[] PRIORITY_CLASS_NAMES = new String[] { "normal", - "idle", - "high" }; - - private static final int[] PRIORITY_CLASSES = new int[] { 0x00000020, - 0x00000040, - 0x00000080 }; - - private boolean dontWrapJar; - private String headerType = GUI_HEADER; - private List headerObjects; - private List libs; - private File jar; - private File outfile; - - // Runtime header configuration - private String errTitle; - private String cmdLine; - private String chdir; - private String priority; - private String downloadUrl; - private String supportUrl; - private boolean customProcName; - private boolean stayAlive; - private File manifest; - private File icon; - private List variables; - private SingleInstance singleInstance; - private ClassPath classPath; - private Jre jre; - private Splash splash; - private VersionInfo versionInfo; - private Msg messages; - - public void checkInvariants() { - Validator.checkTrue(outfile != null && outfile.getPath().endsWith(".exe"), - "outfile", Messages.getString("Config.specify.output.exe")); - if (dontWrapJar) { - if (jar != null && !jar.getPath().equals("")) { - Validator.checkRelativeWinPath(jar.getPath(), "jar", - Messages.getString("Config.application.jar.path")); - } else { - Validator.checkTrue(classPath != null, "classPath", - Messages.getString("ClassPath.or.jar")); - } - } else { - Validator.checkFile(jar, "jar", - Messages.getString("Config.application.jar")); - } - if (!Validator.isEmpty(chdir)) { - Validator.checkRelativeWinPath(chdir, "chdir", - Messages.getString("Config.chdir.relative")); - Validator.checkFalse(chdir.toLowerCase().equals("true") - || chdir.toLowerCase().equals("false"), - "chdir", Messages.getString("Config.chdir.path")); - } - Validator.checkOptFile(manifest, "manifest", Messages.getString("Config.manifest")); - Validator.checkOptFile(icon, "icon", Messages.getString("Config.icon")); - Validator.checkOptString(cmdLine, Validator.MAX_BIG_STR, "jarArgs", - Messages.getString("Config.jar.arguments")); - Validator.checkOptString(errTitle, Validator.MAX_STR, "errTitle", - Messages.getString("Config.error.title")); - Validator.checkOptString(downloadUrl, 256, - "downloadUrl", Messages.getString("Config.download.url")); - Validator.checkOptString(supportUrl, 256, - "supportUrl", Messages.getString("Config.support.url")); - Validator.checkIn(getHeaderType(), HEADER_TYPES, "headerType", - Messages.getString("Config.header.type")); - Validator.checkFalse(getHeaderType().equals(CONSOLE_HEADER) && splash != null, - "headerType", - Messages.getString("Config.splash.not.impl.by.console.hdr")); - Validator.checkOptStrings(variables, - Validator.MAX_ARGS, - Validator.MAX_ARGS, - "[^=%\t]+=[^=\t]+", - "variables", - Messages.getString("Config.variables"), - Messages.getString("Config.variables.err")); - Validator.checkIn(getPriority(), PRIORITY_CLASS_NAMES, "priority", - Messages.getString("Config.priority")); - jre.checkInvariants(); - } - - public void validate() { - checkInvariants(); - if (classPath != null) { - classPath.checkInvariants(); - } - if (splash != null) { - splash.checkInvariants(); - } - if (versionInfo != null) { - versionInfo.checkInvariants(); - } - } - - /** Change current directory to EXE location. */ - public String getChdir() { - return chdir; - } - - public void setChdir(String chdir) { - this.chdir = chdir; - } - - /** Constant command line arguments passed to the application. */ - public String getCmdLine() { - return cmdLine; - } - - public void setCmdLine(String cmdLine) { - this.cmdLine = cmdLine; - } - - /** Optional, error message box title. */ - public String getErrTitle() { - return errTitle; - } - - public void setErrTitle(String errTitle) { - this.errTitle = errTitle; - } - - /** launch4j header file. */ - public String getHeaderType() { - return headerType.toLowerCase(); - } - - public void setHeaderType(String headerType) { - this.headerType = headerType; - } - - /** launch4j header file index - used by GUI. */ - public int getHeaderTypeIndex() { - int x = Arrays.asList(HEADER_TYPES).indexOf(getHeaderType()); - return x != -1 ? x : 0; - } - - public void setHeaderTypeIndex(int headerTypeIndex) { - headerType = HEADER_TYPES[headerTypeIndex]; - } - - public boolean isCustomHeaderObjects() { - return headerObjects != null && !headerObjects.isEmpty(); - } - - public List getHeaderObjects() { - return isCustomHeaderObjects() ? headerObjects - : getHeaderType().equals(GUI_HEADER) - ? LdDefaults.GUI_HEADER_OBJECTS - : LdDefaults.CONSOLE_HEADER_OBJECTS; - } - - public void setHeaderObjects(List headerObjects) { - this.headerObjects = headerObjects; - } - - public boolean isCustomLibs() { - return libs != null && !libs.isEmpty(); - } - - public List getLibs() { - return isCustomLibs() ? libs : LdDefaults.LIBS; - } - - public void setLibs(List libs) { - this.libs = libs; - } - - /** Wrapper's manifest for User Account Control. */ - public File getManifest() { - return manifest; - } - - public void setManifest(File manifest) { - this.manifest = manifest; - } - - /** ICO file. */ - public File getIcon() { - return icon; - } - - public void setIcon(File icon) { - this.icon = icon; - } - - /** Jar to wrap. */ - public File getJar() { - return jar; - } - - public void setJar(File jar) { - this.jar = jar; - } - - public List getVariables() { - return variables; - } - - public void setVariables(List variables) { - this.variables = variables; - } - - public ClassPath getClassPath() { - return classPath; - } - - public void setClassPath(ClassPath classpath) { - this.classPath = classpath; - } - - /** JRE configuration */ - public Jre getJre() { - return jre; - } - - public void setJre(Jre jre) { - this.jre = jre; - } - - /** Output EXE file. */ - public File getOutfile() { - return outfile; - } - - public void setOutfile(File outfile) { - this.outfile = outfile; - } - - /** Custom process name as the output EXE file name. */ - public boolean isCustomProcName() { - return customProcName; - } - - public void setCustomProcName(boolean customProcName) { - this.customProcName = customProcName; - } - - /** Splash screen configuration. */ - public Splash getSplash() { - return splash; - } - - public void setSplash(Splash splash) { - this.splash = splash; - } - - /** Stay alive after launching the application. */ - public boolean isStayAlive() { - return stayAlive; - } - - public void setStayAlive(boolean stayAlive) { - this.stayAlive = stayAlive; - } - - public VersionInfo getVersionInfo() { - return versionInfo; - } - - public void setVersionInfo(VersionInfo versionInfo) { - this.versionInfo = versionInfo; - } - - public boolean isDontWrapJar() { - return dontWrapJar; - } - - public void setDontWrapJar(boolean dontWrapJar) { - this.dontWrapJar = dontWrapJar; - } - - public int getPriorityIndex() { - int x = Arrays.asList(PRIORITY_CLASS_NAMES).indexOf(getPriority()); - return x != -1 ? x : 0; - } - - public void setPriorityIndex(int x) { - priority = PRIORITY_CLASS_NAMES[x]; - } - - public String getPriority() { - return Validator.isEmpty(priority) ? PRIORITY_CLASS_NAMES[0] : priority; - } - - public void setPriority(String priority) { - this.priority = priority; - } - - public int getPriorityClass() { - return PRIORITY_CLASSES[getPriorityIndex()]; - } - - public String getDownloadUrl() { - return downloadUrl == null ? DOWNLOAD_URL : downloadUrl; - } - - public void setDownloadUrl(String downloadUrl) { - this.downloadUrl = downloadUrl; - } - - public String getSupportUrl() { - return supportUrl; - } - - public void setSupportUrl(String supportUrl) { - this.supportUrl = supportUrl; - } - - public Msg getMessages() { - return messages; - } - - public void setMessages(Msg messages) { - this.messages = messages; - } - - public SingleInstance getSingleInstance() { - return singleInstance; - } - - public void setSingleInstance(SingleInstance singleInstance) { - this.singleInstance = singleInstance; - } -} diff --git a/src/main/java/net/sf/launch4j/config/ConfigPersister.java b/src/main/java/net/sf/launch4j/config/ConfigPersister.java deleted file mode 100644 index 43daf86..0000000 --- a/src/main/java/net/sf/launch4j/config/ConfigPersister.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 22, 2005 - */ -package net.sf.launch4j.config; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import net.sf.launch4j.Util; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.xml.DomDriver; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class ConfigPersister { - - private static final ConfigPersister _instance = new ConfigPersister(); - - private final XStream _xstream; - private Config _config; - private File _configPath; - - private ConfigPersister() { - _xstream = new XStream(new DomDriver()); - _xstream.alias("launch4jConfig", Config.class); - _xstream.alias("classPath", ClassPath.class); - _xstream.alias("jre", Jre.class); - _xstream.alias("splash", Splash.class); - _xstream.alias("versionInfo", VersionInfo.class); - - _xstream.addImplicitCollection(Config.class, "headerObjects", "obj", - String.class); - _xstream.addImplicitCollection(Config.class, "libs", "lib", String.class); - _xstream.addImplicitCollection(Config.class, "variables", "var", String.class); - _xstream.addImplicitCollection(ClassPath.class, "paths", "cp", String.class); - _xstream.addImplicitCollection(Jre.class, "options", "opt", String.class); - } - - public static ConfigPersister getInstance() { - return _instance; - } - - public Config getConfig() { - return _config; - } - - public File getConfigPath() { - return _configPath; - } - - public File getOutputPath() throws IOException { - if (_config.getOutfile().isAbsolute()) { - return _config.getOutfile().getParentFile(); - } - File parent = _config.getOutfile().getParentFile(); - return (parent != null) ? new File(_configPath, parent.getPath()) : _configPath; - } - - public File getOutputFile() throws IOException { - return _config.getOutfile().isAbsolute() - ? _config.getOutfile() - : new File(getOutputPath(), _config.getOutfile().getName()); - } - - public void createBlank() { - _config = new Config(); - _config.setJre(new Jre()); - _configPath = null; - } - - public void setAntConfig(Config c, File basedir) { - _config = c; - _configPath = basedir; - } - - public void load(File f) throws ConfigPersisterException { - try { - FileReader r = new FileReader(f); - char[] buf = new char[(int) f.length()]; - r.read(buf); - r.close(); - // Convert 2.x config to 3.x - String s = String.valueOf(buf) - .replaceAll("0<", "gui<") - .replaceAll("1<", "console<") - .replaceAll("jarArgs>", "cmdLine>") - .replaceAll("", "") - .replaceAll("args>", "opt>") - .replaceAll("", "") - .replaceAll("false", - "" + Jre.JDK_PREFERENCE_PREFER_JRE + "") - .replaceAll("true", - "" + Jre.JDK_PREFERENCE_JRE_ONLY + "") - .replaceAll("0", "") - .replaceAll("0", ""); - _config = (Config) _xstream.fromXML(s); - setConfigPath(f); - } catch (Exception e) { - throw new ConfigPersisterException(e); - } - } - - /** - * Imports launch4j 1.x.x config file. - */ - public void loadVersion1(File f) throws ConfigPersisterException { - try { - Props props = new Props(f); - _config = new Config(); - String header = props.getProperty(Config.HEADER); - _config.setHeaderType(header == null - || header.toLowerCase().equals("guihead.bin") ? Config.GUI_HEADER - : Config.CONSOLE_HEADER); - _config.setJar(props.getFile(Config.JAR)); - _config.setOutfile(props.getFile(Config.OUTFILE)); - _config.setJre(new Jre()); - _config.getJre().setPath(props.getProperty(Jre.PATH)); - _config.getJre().setMinVersion(props.getProperty(Jre.MIN_VERSION)); - _config.getJre().setMaxVersion(props.getProperty(Jre.MAX_VERSION)); - String args = props.getProperty(Jre.ARGS); - if (args != null) { - List jreOptions = new ArrayList(); - jreOptions.add(args); - _config.getJre().setOptions(jreOptions); - } - _config.setCmdLine(props.getProperty(Config.JAR_ARGS)); - _config.setChdir("true".equals(props.getProperty(Config.CHDIR)) - ? "." : null); - _config.setCustomProcName("true".equals( - props.getProperty("setProcName"))); // 1.x - _config.setStayAlive("true".equals(props.getProperty(Config.STAY_ALIVE))); - _config.setErrTitle(props.getProperty(Config.ERR_TITLE)); - _config.setIcon(props.getFile(Config.ICON)); - File splashFile = props.getFile(Splash.SPLASH_FILE); - if (splashFile != null) { - _config.setSplash(new Splash()); - _config.getSplash().setFile(splashFile); - String waitfor = props.getProperty("waitfor"); // 1.x - _config.getSplash().setWaitForWindow(waitfor != null - && !waitfor.equals("")); - String splashTimeout = props.getProperty(Splash.TIMEOUT); - if (splashTimeout != null) { - _config.getSplash().setTimeout(Integer.parseInt(splashTimeout)); - } - _config.getSplash().setTimeoutErr("true".equals( - props.getProperty(Splash.TIMEOUT_ERR))); - } else { - _config.setSplash(null); - } - setConfigPath(f); - } catch (IOException e) { - throw new ConfigPersisterException(e); - } - } - - public void save(File f) throws ConfigPersisterException { - try { - BufferedWriter w = new BufferedWriter(new FileWriter(f)); - _xstream.toXML(_config, w); - w.close(); - setConfigPath(f); - } catch (Exception e) { - throw new ConfigPersisterException(e); - } - } - - private void setConfigPath(File configFile) { - _configPath = configFile.getAbsoluteFile().getParentFile(); - } - - private class Props { - final Properties _properties = new Properties(); - - public Props(File f) throws IOException { - FileInputStream is = null; - try { - is = new FileInputStream(f); - _properties.load(is); - } finally { - Util.close(is); - } - } - - /** - * Get property and remove trailing # comments. - */ - public String getProperty(String key) { - String p = _properties.getProperty(key); - if (p == null) { - return null; - } - int x = p.indexOf('#'); - if (x == -1) { - return p; - } - do { - x--; - } while (x > 0 && (p.charAt(x) == ' ' || p.charAt(x) == '\t')); - return (x == 0) ? "" : p.substring(0, x + 1); - } - - public File getFile(String key) { - String value = getProperty(key); - return value != null ? new File(value) : null; - } - } -} diff --git a/src/main/java/net/sf/launch4j/config/ConfigPersisterException.java b/src/main/java/net/sf/launch4j/config/ConfigPersisterException.java deleted file mode 100644 index 29940b9..0000000 --- a/src/main/java/net/sf/launch4j/config/ConfigPersisterException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 22, 2005 - */ -package net.sf.launch4j.config; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class ConfigPersisterException extends Exception { - - public ConfigPersisterException(String msg, Throwable t) { - super(msg, t); - } - - public ConfigPersisterException(Throwable t) { - super(t); - } -} diff --git a/src/main/java/net/sf/launch4j/config/Jre.java b/src/main/java/net/sf/launch4j/config/Jre.java deleted file mode 100644 index 0df45bb..0000000 --- a/src/main/java/net/sf/launch4j/config/Jre.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 21, 2005 - */ -package net.sf.launch4j.config; - -import java.util.Arrays; -import java.util.List; - -import net.sf.launch4j.binding.IValidatable; -import net.sf.launch4j.binding.Validator; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class Jre implements IValidatable { - - // 1.x config properties_____________________________________________________________ - public static final String PATH = "jrepath"; - public static final String MIN_VERSION = "javamin"; - public static final String MAX_VERSION = "javamax"; - public static final String ARGS = "jvmArgs"; - - // __________________________________________________________________________________ - public static final String VERSION_PATTERN = "(\\d\\.){2}\\d(_\\d+)?"; - - public static final String JDK_PREFERENCE_JRE_ONLY = "jreOnly"; - public static final String JDK_PREFERENCE_PREFER_JRE = "preferJre"; - public static final String JDK_PREFERENCE_PREFER_JDK = "preferJdk"; - public static final String JDK_PREFERENCE_JDK_ONLY = "jdkOnly"; - - private static final String[] JDK_PREFERENCE_NAMES = new String[] { - JDK_PREFERENCE_JRE_ONLY, - JDK_PREFERENCE_PREFER_JRE, - JDK_PREFERENCE_PREFER_JDK, - JDK_PREFERENCE_JDK_ONLY }; - - public static final int DEFAULT_JDK_PREFERENCE_INDEX - = Arrays.asList(JDK_PREFERENCE_NAMES).indexOf(JDK_PREFERENCE_PREFER_JRE); - - private String path; - private String minVersion; - private String maxVersion; - private String jdkPreference; - private Integer initialHeapSize; - private Integer initialHeapPercent; - private Integer maxHeapSize; - private Integer maxHeapPercent; - private List options; - - public void checkInvariants() { - Validator.checkOptString(minVersion, 10, VERSION_PATTERN, - "jre.minVersion", Messages.getString("Jre.min.version")); - Validator.checkOptString(maxVersion, 10, VERSION_PATTERN, - "jre.maxVersion", Messages.getString("Jre.max.version")); - if (Validator.isEmpty(path)) { - Validator.checkFalse(Validator.isEmpty(minVersion), - "jre.minVersion", Messages.getString("Jre.specify.jre.min.version.or.path")); - } else { - Validator.checkString(path, Validator.MAX_PATH, - "jre.path", Messages.getString("Jre.bundled.path")); - } - if (!Validator.isEmpty(maxVersion)) { - Validator.checkFalse(Validator.isEmpty(minVersion), - "jre.minVersion", Messages.getString("Jre.specify.min.version")); - Validator.checkTrue(minVersion.compareTo(maxVersion) < 0, - "jre.maxVersion", Messages.getString("Jre.max.greater.than.min")); - } - Validator.checkTrue(initialHeapSize == null || maxHeapSize != null, - "jre.maxHeapSize", Messages.getString("Jre.initial.and.max.heap")); - Validator.checkTrue(initialHeapSize == null || initialHeapSize.intValue() > 0, - "jre.initialHeapSize", Messages.getString("Jre.initial.heap")); - Validator.checkTrue(maxHeapSize == null || (maxHeapSize.intValue() - >= ((initialHeapSize != null) ? initialHeapSize.intValue() : 1)), - "jre.maxHeapSize", Messages.getString("Jre.max.heap")); - Validator.checkTrue(initialHeapPercent == null || maxHeapPercent != null, - "jre.maxHeapPercent", Messages.getString("Jre.initial.and.max.heap")); - if (initialHeapPercent != null) { - Validator.checkRange(initialHeapPercent.intValue(), 1, 100, - "jre.initialHeapPercent", - Messages.getString("Jre.initial.heap.percent")); - } - if (maxHeapPercent != null) { - Validator.checkRange(maxHeapPercent.intValue(), - initialHeapPercent != null ? initialHeapPercent.intValue() : 1, 100, - "jre.maxHeapPercent", - Messages.getString("Jre.max.heap.percent")); - } - Validator.checkIn(getJdkPreference(), JDK_PREFERENCE_NAMES, - "jre.jdkPreference", Messages.getString("Jre.jdkPreference.invalid")); - Validator.checkOptStrings(options, - Validator.MAX_ARGS, - Validator.MAX_ARGS, - "[^\"]*|([^\"]*\"[^\"]*\"[^\"]*)*", - "jre.options", - Messages.getString("Jre.jvm.options"), - Messages.getString("Jre.jvm.options.unclosed.quotation")); - - // Quoted variable references: "[^%]*|([^%]*\"([^%]*%[^%]+%[^%]*)+\"[^%]*)*" - Validator.checkOptStrings(options, - Validator.MAX_ARGS, - Validator.MAX_ARGS, - "[^%]*|([^%]*([^%]*%[^%]+%[^%]*)+[^%]*)*", - "jre.options", - Messages.getString("Jre.jvm.options"), - Messages.getString("Jre.jvm.options.variable")); - } - - /** JVM options */ - public List getOptions() { - return options; - } - - public void setOptions(List options) { - this.options = options; - } - - /** Max Java version (x.x.x) */ - public String getMaxVersion() { - return maxVersion; - } - - public void setMaxVersion(String maxVersion) { - this.maxVersion = maxVersion; - } - - /** Min Java version (x.x.x) */ - public String getMinVersion() { - return minVersion; - } - - public void setMinVersion(String minVersion) { - this.minVersion = minVersion; - } - - /** Preference for standalone JRE or JDK-private JRE */ - public String getJdkPreference() { - return Validator.isEmpty(jdkPreference) ? JDK_PREFERENCE_PREFER_JRE - : jdkPreference; - } - - public void setJdkPreference(String jdkPreference) { - this.jdkPreference = jdkPreference; - } - - /** Preference for standalone JRE or JDK-private JRE */ - public int getJdkPreferenceIndex() { - int x = Arrays.asList(JDK_PREFERENCE_NAMES).indexOf(getJdkPreference()); - return x != -1 ? x : DEFAULT_JDK_PREFERENCE_INDEX; - } - - public void setJdkPreferenceIndex(int x) { - jdkPreference = JDK_PREFERENCE_NAMES[x]; - } - - /** JRE path */ - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - /** Initial heap size in MB */ - public Integer getInitialHeapSize() { - return initialHeapSize; - } - - public void setInitialHeapSize(Integer initialHeapSize) { - this.initialHeapSize = getInteger(initialHeapSize); - } - - /** Max heap size in MB */ - public Integer getMaxHeapSize() { - return maxHeapSize; - } - - public void setMaxHeapSize(Integer maxHeapSize) { - this.maxHeapSize = getInteger(maxHeapSize); - } - - public Integer getInitialHeapPercent() { - return initialHeapPercent; - } - - public void setInitialHeapPercent(Integer initialHeapPercent) { - this.initialHeapPercent = getInteger(initialHeapPercent); - } - - public Integer getMaxHeapPercent() { - return maxHeapPercent; - } - - public void setMaxHeapPercent(Integer maxHeapPercent) { - this.maxHeapPercent = getInteger(maxHeapPercent); - } - - /** Convert 0 to null */ - private Integer getInteger(Integer i) { - return i != null && i.intValue() == 0 ? null : i; - } -} diff --git a/src/main/java/net/sf/launch4j/config/LdDefaults.java b/src/main/java/net/sf/launch4j/config/LdDefaults.java deleted file mode 100644 index 55f457c..0000000 --- a/src/main/java/net/sf/launch4j/config/LdDefaults.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Sep 3, 2005 - */ -package net.sf.launch4j.config; - -import java.util.Arrays; -import java.util.List; - -public class LdDefaults { - - public static final List GUI_HEADER_OBJECTS = Arrays.asList(new String[] { - "w32api/crt2.o", - "head/guihead.o", - "head/head.o" }); - - public static final List CONSOLE_HEADER_OBJECTS = Arrays.asList(new String[] { - "w32api/crt2.o", - "head/consolehead.o", - "head/head.o"}); - - public static final List LIBS = Arrays.asList(new String[] { - "w32api/libmingw32.a", - "w32api/libgcc.a", - "w32api/libmsvcrt.a", - "w32api/libkernel32.a", - "w32api/libuser32.a", - "w32api/libadvapi32.a", - "w32api/libshell32.a" }); -} diff --git a/src/main/java/net/sf/launch4j/config/Messages.java b/src/main/java/net/sf/launch4j/config/Messages.java deleted file mode 100644 index a3f344e..0000000 --- a/src/main/java/net/sf/launch4j/config/Messages.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package net.sf.launch4j.config; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "net.sf.launch4j.config.messages"; - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - private static final MessageFormat FORMATTER = new MessageFormat(""); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - - public static String getString(String key, String arg0) { - return getString(key, new Object[] {arg0}); - } - - public static String getString(String key, String arg0, String arg1) { - return getString(key, new Object[] {arg0, arg1}); - } - - public static String getString(String key, String arg0, String arg1, String arg2) { - return getString(key, new Object[] {arg0, arg1, arg2}); - } - - public static String getString(String key, Object[] args) { - try { - FORMATTER.applyPattern(RESOURCE_BUNDLE.getString(key)); - return FORMATTER.format(args); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/src/main/java/net/sf/launch4j/config/Msg.java b/src/main/java/net/sf/launch4j/config/Msg.java deleted file mode 100644 index ea3acfa..0000000 --- a/src/main/java/net/sf/launch4j/config/Msg.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Oct 8, 2006 - */ -package net.sf.launch4j.config; - -import net.sf.launch4j.binding.IValidatable; -import net.sf.launch4j.binding.Validator; - -/** - * @author Copyright (C) 2006 Grzegorz Kowal - */ -public class Msg implements IValidatable { - private String startupErr; - private String bundledJreErr; - private String jreVersionErr; - private String launcherErr; - private String instanceAlreadyExistsMsg; - - public void checkInvariants() { - Validator.checkOptString(startupErr, 1024, "startupErr", - Messages.getString("Msg.startupErr")); - Validator.checkOptString(bundledJreErr, 1024, "bundledJreErr", - Messages.getString("Msg.bundledJreErr")); - Validator.checkOptString(jreVersionErr, 1024, "jreVersionErr", - Messages.getString("Msg.jreVersionErr")); - Validator.checkOptString(launcherErr, 1024, "launcherErr", - Messages.getString("Msg.launcherErr")); - Validator.checkOptString(instanceAlreadyExistsMsg, 1024, "instanceAlreadyExistsMsg", - Messages.getString("Msg.instanceAlreadyExistsMsg")); - } - - public String getStartupErr() { - return !Validator.isEmpty(startupErr) ? startupErr - : "An error occurred while starting the application."; - } - - public void setStartupErr(String startupErr) { - this.startupErr = startupErr; - } - - public String getBundledJreErr() { - return !Validator.isEmpty(bundledJreErr) ? bundledJreErr - : "This application was configured to use a bundled Java Runtime" + - " Environment but the runtime is missing or corrupted."; - } - - public void setBundledJreErr(String bundledJreErr) { - this.bundledJreErr = bundledJreErr; - } - - public String getJreVersionErr() { - return !Validator.isEmpty(jreVersionErr) ? jreVersionErr - : "This application requires a Java Runtime Environment"; - } - - public void setJreVersionErr(String jreVersionErr) { - this.jreVersionErr = jreVersionErr; - } - - public String getLauncherErr() { - return !Validator.isEmpty(launcherErr) ? launcherErr - : "The registry refers to a nonexistent Java Runtime Environment" + - " installation or the runtime is corrupted."; - } - - public void setLauncherErr(String launcherErr) { - this.launcherErr = launcherErr; - } - - public String getInstanceAlreadyExistsMsg() { - return !Validator.isEmpty(instanceAlreadyExistsMsg) ? instanceAlreadyExistsMsg - : "An application instance is already running."; - } - - public void setInstanceAlreadyExistsMsg(String instanceAlreadyExistsMsg) { - this.instanceAlreadyExistsMsg = instanceAlreadyExistsMsg; - } -} diff --git a/src/main/java/net/sf/launch4j/config/SingleInstance.java b/src/main/java/net/sf/launch4j/config/SingleInstance.java deleted file mode 100644 index c0a85e6..0000000 --- a/src/main/java/net/sf/launch4j/config/SingleInstance.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** - * Created on 2007-09-16 - */ -package net.sf.launch4j.config; - -import net.sf.launch4j.binding.IValidatable; -import net.sf.launch4j.binding.Validator; - -/** - * @author Copyright (C) 2007 Grzegorz Kowal - */ -public class SingleInstance implements IValidatable { - - private String mutexName; - private String windowTitle; - - public void checkInvariants() { - Validator.checkString(mutexName, Validator.MAX_STR, - "singleInstance.mutexName", - Messages.getString("SingleInstance.mutexName")); - Validator.checkOptString(windowTitle, Validator.MAX_STR, - "singleInstance.windowTitle", - Messages.getString("SingleInstance.windowTitle")); - } - - public String getWindowTitle() { - return windowTitle; - } - - public void setWindowTitle(String appWindowName) { - this.windowTitle = appWindowName; - } - - public String getMutexName() { - return mutexName; - } - - public void setMutexName(String mutexName) { - this.mutexName = mutexName; - } -} diff --git a/src/main/java/net/sf/launch4j/config/Splash.java b/src/main/java/net/sf/launch4j/config/Splash.java deleted file mode 100644 index f736f82..0000000 --- a/src/main/java/net/sf/launch4j/config/Splash.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on Apr 21, 2005 - */ -package net.sf.launch4j.config; - -import java.io.File; - -import net.sf.launch4j.binding.IValidatable; -import net.sf.launch4j.binding.Validator; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class Splash implements IValidatable { - - // 1.x config properties_____________________________________________________________ - public static final String SPLASH_FILE = "splash"; - public static final String WAIT_FOR_TITLE = "waitForTitle"; - public static final String TIMEOUT = "splashTimeout"; - public static final String TIMEOUT_ERR = "splashTimeoutErr"; - - // __________________________________________________________________________________ - private File file; - private boolean waitForWindow = true; - private int timeout = 60; - private boolean timeoutErr = true; - - public void checkInvariants() { - Validator.checkFile(file, "splash.file", - Messages.getString("Splash.splash.file")); - Validator.checkRange(timeout, 1, 60 * 15, "splash.timeout", - Messages.getString("Splash.splash.timeout")); - } - - /** Splash screen in BMP format. */ - public File getFile() { - return file; - } - - public void setFile(File file) { - this.file = file; - } - - /** Splash timeout in seconds. */ - public int getTimeout() { - return timeout; - } - - public void setTimeout(int timeout) { - this.timeout = timeout; - } - - /** Signal error on splash timeout. */ - public boolean isTimeoutErr() { - return timeoutErr; - } - - public void setTimeoutErr(boolean timeoutErr) { - this.timeoutErr = timeoutErr; - } - - /** Hide splash screen when the child process displayes the first window. */ - public boolean getWaitForWindow() { - return waitForWindow; - } - - public void setWaitForWindow(boolean waitForWindow) { - this.waitForWindow = waitForWindow; - } -} diff --git a/src/main/java/net/sf/launch4j/config/VersionInfo.java b/src/main/java/net/sf/launch4j/config/VersionInfo.java deleted file mode 100644 index d719460..0000000 --- a/src/main/java/net/sf/launch4j/config/VersionInfo.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - Launch4j (http://launch4j.sourceforge.net/) - Cross-platform Java application wrapper for creating Windows native executables. - - Copyright (c) 2004, 2007 Grzegorz Kowal - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Launch4j nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Created on May 21, 2005 - */ -package net.sf.launch4j.config; - -import net.sf.launch4j.binding.IValidatable; -import net.sf.launch4j.binding.Validator; - -/** - * @author Copyright (C) 2005 Grzegorz Kowal - */ -public class VersionInfo implements IValidatable { - public static final String VERSION_PATTERN = "(\\d+\\.){3}\\d+"; - - private String fileVersion; - private String txtFileVersion; - private String fileDescription; - private String copyright; - private String productVersion; - private String txtProductVersion; - private String productName; - private String companyName; - private String internalName; - private String originalFilename; - - public void checkInvariants() { - Validator.checkString(fileVersion, 20, VERSION_PATTERN, - "versionInfo.fileVersion", - Messages.getString("VersionInfo.file.version")); - Validator.checkString(txtFileVersion, 50, "versionInfo.txtFileVersion", - Messages.getString("VersionInfo.txt.file.version")); - Validator.checkString(fileDescription, 150, "versionInfo.fileDescription", - Messages.getString("VersionInfo.file.description")); - Validator.checkString(copyright, 150, "versionInfo.copyright", - Messages.getString("VersionInfo.copyright")); - Validator.checkString(productVersion, 20, VERSION_PATTERN, - "versionInfo.productVersion", - Messages.getString("VersionInfo.product.version")); - Validator.checkString(txtProductVersion, 50, "versionInfo.txtProductVersion", - Messages.getString("VersionInfo.txt.product.version")); - Validator.checkString(productName, 150, "versionInfo.productName", - Messages.getString("VersionInfo.product.name")); - Validator.checkOptString(companyName, 150, "versionInfo.companyName", - Messages.getString("VersionInfo.company.name")); - Validator.checkString(internalName, 50, "versionInfo.internalName", - Messages.getString("VersionInfo.internal.name")); - Validator.checkTrue(!internalName.endsWith(".exe"), "versionInfo.internalName", - Messages.getString("VersionInfo.internal.name.not.exe")); - Validator.checkString(originalFilename, 50, "versionInfo.originalFilename", - Messages.getString("VersionInfo.original.filename")); - Validator.checkTrue(originalFilename.endsWith(".exe"), - "versionInfo.originalFilename", - Messages.getString("VersionInfo.original.filename.exe")); - } - - public String getCompanyName() { - return companyName; - } - - public void setCompanyName(String companyName) { - this.companyName = companyName; - } - - public String getCopyright() { - return copyright; - } - - public void setCopyright(String copyright) { - this.copyright = copyright; - } - - public String getFileDescription() { - return fileDescription; - } - - public void setFileDescription(String fileDescription) { - this.fileDescription = fileDescription; - } - - public String getFileVersion() { - return fileVersion; - } - - public void setFileVersion(String fileVersion) { - this.fileVersion = fileVersion; - } - - public String getInternalName() { - return internalName; - } - - public void setInternalName(String internalName) { - this.internalName = internalName; - } - - public String getOriginalFilename() { - return originalFilename; - } - - public void setOriginalFilename(String originalFilename) { - this.originalFilename = originalFilename; - } - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public String getProductVersion() { - return productVersion; - } - - public void setProductVersion(String productVersion) { - this.productVersion = productVersion; - } - - public String getTxtFileVersion() { - return txtFileVersion; - } - - public void setTxtFileVersion(String txtFileVersion) { - this.txtFileVersion = txtFileVersion; - } - - public String getTxtProductVersion() { - return txtProductVersion; - } - - public void setTxtProductVersion(String txtProductVersion) { - this.txtProductVersion = txtProductVersion; - } -} From 51b51f7e201b5f0d839c88c5042323d91c4d3b04 Mon Sep 17 00:00:00 2001 From: Claudio Tasso Date: Tue, 2 Sep 2014 07:01:21 +0200 Subject: [PATCH 04/37] . --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index c6b0aec..0806546 100644 --- a/TODO +++ b/TODO @@ -54,5 +54,5 @@ app-1.0.jar - support bundling the JRE (or figure out what parameters already allow this) - +. From 2236ed33dfdec1fbacf19ffa59e027a277011d31 Mon Sep 17 00:00:00 2001 From: taxone Date: Tue, 2 Sep 2014 12:26:37 +0200 Subject: [PATCH 05/37] Removed commented lines --- pom.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pom.xml b/pom.xml index f402526..80acf6c 100644 --- a/pom.xml +++ b/pom.xml @@ -101,21 +101,6 @@ maven-assembly-plugin - - - - - - - - - - - - - - - dist-src package From 0f4de3a561d944c617de9e4438a68cfeea7ac62a Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 3 Sep 2014 08:14:05 +0200 Subject: [PATCH 06/37] Excludes .idea folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f37f235..e903bb9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ target/* .project .classpath /target +.idea From f6d268546d8b095cd506e97c8a1aacd5c466b797 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 3 Sep 2014 08:58:54 +0200 Subject: [PATCH 07/37] Excludes IBM icu4j to avoid problems with assmbling jar --- pom.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 80acf6c..8fa7671 100644 --- a/pom.xml +++ b/pom.xml @@ -12,14 +12,14 @@ 4.0.0 - com.akathist.maven.plugins.launch4j + com.akathist.maven.plugins.launch4j launch4j-maven-plugin maven-plugin 1.6-SNAPSHOT Maven Launch4j Plugin This plugin creates Windows executables from Java jar files using the Launch4j utility. - http://9stmaryrd.com/tools/launch4j-maven-plugin/ @@ -41,6 +41,12 @@ launch4j 3.4.0 core + + + com.ibm.icu + icu4j + + org.apache.maven From 1ab8e04bcabe2c167f1ad1c1abdbf3528aa9de44 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 3 Sep 2014 08:59:50 +0200 Subject: [PATCH 08/37] Moves files to resources folder and drops custom task --- pom.xml | 18 ------------------ README => src/main/resources/README | 0 TODO => src/main/resources/TODO | 0 3 files changed, 18 deletions(-) rename README => src/main/resources/README (100%) rename TODO => src/main/resources/TODO (100%) diff --git a/pom.xml b/pom.xml index 8fa7671..7de8886 100644 --- a/pom.xml +++ b/pom.xml @@ -86,24 +86,6 @@ 1.6 - - maven-antrun-plugin - - - copy - process-classes - - run - - - - - - - - - - maven-assembly-plugin diff --git a/README b/src/main/resources/README similarity index 100% rename from README rename to src/main/resources/README diff --git a/TODO b/src/main/resources/TODO similarity index 100% rename from TODO rename to src/main/resources/TODO From c74e48bb9ffaddc56afae1962957596cdf544720 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 3 Sep 2014 09:00:33 +0200 Subject: [PATCH 09/37] Performs code cleanup --- .../maven/plugins/launch4j/ClassPath.java | 35 ++++++++++--------- .../akathist/maven/plugins/launch4j/Jre.java | 10 +++--- .../maven/plugins/launch4j/Launch4jMojo.java | 6 ++-- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java b/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java index daac0f7..622d507 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java @@ -18,11 +18,13 @@ */ package com.akathist.maven.plugins.launch4j; -import java.io.*; -import java.util.*; -import org.apache.maven.model.Dependency; import org.apache.maven.artifact.Artifact; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + public class ClassPath { /** @@ -72,7 +74,7 @@ public class ClassPath { */ String postCp; - private void addToCp(List cp, String cpStr) { + private void addToCp(List cp, String cpStr) { cp.addAll(Arrays.asList(cpStr.split("\\s*;\\s*"))); } @@ -80,25 +82,24 @@ net.sf.launch4j.config.ClassPath toL4j(Set dependencies) { net.sf.launch4j.config.ClassPath ret = new net.sf.launch4j.config.ClassPath(); ret.setMainClass(mainClass); - List cp = new ArrayList(); + List cp = new ArrayList(); if (preCp != null) addToCp(cp, preCp); if (addDependencies) { if (jarLocation == null) jarLocation = ""; else if ( ! jarLocation.endsWith("/")) jarLocation += "/"; - Iterator i = dependencies.iterator(); - while (i.hasNext()) { - Artifact dep = (Artifact)i.next(); - if (Artifact.SCOPE_COMPILE.equals(dep.getScope()) || - Artifact.SCOPE_RUNTIME.equals(dep.getScope())) { - - String depFilename; - depFilename = dep.getFile().getName(); - // System.out.println("dep = " + depFilename); - cp.add(jarLocation + depFilename); - } - } + for (Object dependency : dependencies) { + Artifact dep = (Artifact) dependency; + if (Artifact.SCOPE_COMPILE.equals(dep.getScope()) || + Artifact.SCOPE_RUNTIME.equals(dep.getScope())) { + + String depFilename; + depFilename = dep.getFile().getName(); + // System.out.println("dep = " + depFilename); + cp.add(jarLocation + depFilename); + } + } } if (postCp != null) addToCp(cp, postCp); diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java index 2fd941b..9e31eea 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java @@ -114,7 +114,7 @@ public class Jre { * <opt>-Dsettings="%HomeDrive%%HomePath%\\settings.ini"</opt> * */ - List opts; + List opts; net.sf.launch4j.config.Jre toL4j() { net.sf.launch4j.config.Jre ret = new net.sf.launch4j.config.Jre(); @@ -123,10 +123,10 @@ net.sf.launch4j.config.Jre toL4j() { ret.setMinVersion(minVersion); ret.setMaxVersion(maxVersion); ret.setJdkPreference(jdkPreference); - ret.setInitialHeapSize(new Integer(initialHeapSize)); - ret.setInitialHeapPercent(new Integer(initialHeapPercent)); - ret.setMaxHeapSize(new Integer(maxHeapSize)); - ret.setMaxHeapPercent(new Integer(maxHeapPercent)); + ret.setInitialHeapSize(initialHeapSize); + ret.setInitialHeapPercent(initialHeapPercent); + ret.setMaxHeapSize(maxHeapSize); + ret.setMaxHeapPercent(maxHeapPercent); ret.setOptions(opts); return ret; diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java index 16855a8..69df02f 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java @@ -239,21 +239,21 @@ public class Launch4jMojo extends AbstractMojo { * * @parameter */ - private List objs; + private List objs; /** * Win32 libraries to include. Used for custom headers only. * * @parameter */ - private List libs; + private List libs; /** * Variables to set. * * @parameter */ - private List vars; + private List vars; /** * Details about the supported jres. From 29434f610e73579e9db2dcc67ae1ecea9a5e7929 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 3 Sep 2014 09:01:09 +0200 Subject: [PATCH 10/37] Uses Sonatype's parent --- pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7de8886..5325071 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,13 @@ 4.0.0 + + + org.sonatype.oss + oss-parent + 7 + + com.akathist.maven.plugins.launch4j launch4j-maven-plugin maven-plugin @@ -31,7 +38,7 @@ - scm:git:git@github.com:vorburger/launch4j-maven-plugin.git + scm:git:git@github.com:lukaszlenart/launch4j-maven-plugin.git HEAD From 490c0f0c45a6573c71b840e0211888d41b2cd9e6 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 3 Sep 2014 09:01:59 +0200 Subject: [PATCH 11/37] Cleans pom --- pom.xml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 5325071..6891382 100644 --- a/pom.xml +++ b/pom.xml @@ -23,13 +23,12 @@ launch4j-maven-plugin maven-plugin 1.6-SNAPSHOT - Maven Launch4j Plugin + + Maven Launch4j Plugin This plugin creates Windows executables from Java jar files using the Launch4j utility. - http://9stmaryrd.com/tools/launch4j-maven-plugin/ - + + GNU General Public License http://www.gnu.org/licenses/gpl.txt @@ -111,13 +110,6 @@ - - - org.apache.maven.wagon - wagon-ftp - 1.0-alpha-6 - - - + 4.0.0 @@ -22,7 +21,7 @@ com.akathist.maven.plugins.launch4j launch4j-maven-plugin maven-plugin - 1.6-SNAPSHOT + 1.6 Maven Launch4j Plugin This plugin creates Windows executables from Java jar files using the Launch4j utility. From b67eab9a26c767c69346c1332c553eb2123f2e8b Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 27 Sep 2014 09:48:42 +0200 Subject: [PATCH 13/37] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ed7a02..4edc0d4 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.akathist.maven.plugins.launch4j launch4j-maven-plugin maven-plugin - 1.6 + 1.7-SNAPSHOT Maven Launch4j Plugin This plugin creates Windows executables from Java jar files using the Launch4j utility. From d62576a793e5753950cb9a7bbde8b463c194b4ad Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 30 Sep 2014 07:32:14 +0200 Subject: [PATCH 14/37] Drops deprecated release guideline --- HOW-TO-RELEASE | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 HOW-TO-RELEASE diff --git a/HOW-TO-RELEASE b/HOW-TO-RELEASE deleted file mode 100644 index 71c608a..0000000 --- a/HOW-TO-RELEASE +++ /dev/null @@ -1,25 +0,0 @@ -Publish to https://github.com/vorburger/m2p2-repository : - -$ mvn -DdryRun=true clean release:clean release:prepare -$ mvn release:clean - (NOT $ mvn release:rollback) - ---- - -$ mvn release:prepare - -$ mkdir target/local-repo -$ mvn release:stage -DstagingRepository=staging::default::file:../../local-repo/ - INSTEAD of $ mvn release:perform - NOTE: The CWD is target/checkout/target/, that's why ../../ is needed! - -$ mv local-repo/com ../../m2p2-repository/maven/releases/ -$ cd ../../m2p2-repository -$ ./update-directory-index.sh -$ git add . -$ git commit -m "publishing ..." -$ git push - -$ cd - -$ mvn release:clean - From 50087550466de11df73878c3bb3f72b60be6ae55 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 30 Sep 2014 07:32:24 +0200 Subject: [PATCH 15/37] Adds basic readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..21b7d43 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Launch4j Maven Plugin + +Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ + +## Version notes 1.6 +- dropped Launch4j source and based on artifacts from Maven Central +- uses the latest version of Launch4j (3.4.0) From 32b67e43a583d2b002681295e8cb16cd4c311916 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 30 Sep 2014 07:32:33 +0200 Subject: [PATCH 16/37] Adds CI config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dff5f3a --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: java From 335b6813a9dcaccecd0ff45b19039b16101fe15e Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 30 Sep 2014 07:33:29 +0200 Subject: [PATCH 17/37] Adds build status --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 21b7d43..a4a33d4 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ +[![Build Status](https://travis-ci.org/lukaszlenart/launch4j-maven-plugin.svg)](https://travis-ci.org/lukaszlenart/launch4j-maven-plugin) + ## Version notes 1.6 - dropped Launch4j source and based on artifacts from Maven Central - uses the latest version of Launch4j (3.4.0) From e8bb8184f88b85328640286dc165f33ce1c68184 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 30 Sep 2014 10:30:53 +0200 Subject: [PATCH 18/37] Adds info how to solve problem with missing dsol-xml dependency --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index a4a33d4..277ddff 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,18 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ ## Version notes 1.6 - dropped Launch4j source and based on artifacts from Maven Central - uses the latest version of Launch4j (3.4.0) + +# FAQ +Q: I cannot build my project because `dsol-xml` dependency is missing? + +A: Add this repository to your `~/.m2/settings.xml` + +```xml + + + dsol-xml + Simulation @ TU Delft + http://simulation.tudelft.nl/maven/ + + +``` From 82c1c1858392a859d0e53c3a13f6e5b4029d69a1 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 30 Sep 2014 11:56:20 +0200 Subject: [PATCH 19/37] Adds support for runtimeBits --- .../java/com/akathist/maven/plugins/launch4j/Jre.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java index 9e31eea..e33d268 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java @@ -116,6 +116,13 @@ public class Jre { */ List opts; + /** + * Sets JVM version to use: 32 bits, 64 bits or 64/32 bits + * Possible values: 32, 64, 64/32 - it will fallback to default value if different option was used + * Default value is: 64/32 + */ + String runtimeBits; + net.sf.launch4j.config.Jre toL4j() { net.sf.launch4j.config.Jre ret = new net.sf.launch4j.config.Jre(); @@ -128,6 +135,7 @@ net.sf.launch4j.config.Jre toL4j() { ret.setMaxHeapSize(maxHeapSize); ret.setMaxHeapPercent(maxHeapPercent); ret.setOptions(opts); + ret.setRuntimeBits(runtimeBits); return ret; } From 503486dd3a413664639d3870944223adac05f3e9 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 30 Sep 2014 12:17:05 +0200 Subject: [PATCH 20/37] Adds info about SNAPSHOT repo --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 277ddff..7e83ce9 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,22 @@ A: Add this repository to your `~/.m2/settings.xml` ``` +Q: Where can I find -SNAPSHOT builds? + +A: Use the Sonatype OSS repo + +```xml + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + +``` \ No newline at end of file From 922ee3b72d9d94c87127eff29d002bed15491bfc Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 2 Oct 2014 07:03:25 +0200 Subject: [PATCH 21/37] Adds missing slash --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e83ce9..115ba95 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ A: Use the Sonatype OSS repo sonatype-nexus-snapshots Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots/ false @@ -40,4 +40,4 @@ A: Use the Sonatype OSS repo -``` \ No newline at end of file +``` From 92f71def88c51cd2f74fe8e55229b0060c239670 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 10 Oct 2014 08:48:48 +0200 Subject: [PATCH 22/37] Adds runtimeBits @parameter definition and toString for better debugging --- .../akathist/maven/plugins/launch4j/Jre.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java index e33d268..bc0dab6 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Jre.java @@ -120,6 +120,8 @@ public class Jre { * Sets JVM version to use: 32 bits, 64 bits or 64/32 bits * Possible values: 32, 64, 64/32 - it will fallback to default value if different option was used * Default value is: 64/32 + * + * @parameter default-value="64/32" */ String runtimeBits; @@ -140,4 +142,19 @@ net.sf.launch4j.config.Jre toL4j() { return ret; } + @Override + public String toString() { + return "Jre{" + + "path='" + path + '\'' + + ", minVersion='" + minVersion + '\'' + + ", maxVersion='" + maxVersion + '\'' + + ", jdkPreference='" + jdkPreference + '\'' + + ", initialHeapSize=" + initialHeapSize + + ", initialHeapPercent=" + initialHeapPercent + + ", maxHeapSize=" + maxHeapSize + + ", maxHeapPercent=" + maxHeapPercent + + ", opts=" + opts + + ", runtimeBits='" + runtimeBits + '\'' + + '}'; + } } From d705285eaad5c29732916f9053985fdf8c7067cc Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 10 Oct 2014 08:49:11 +0200 Subject: [PATCH 23/37] Adds toString for better debugging --- .../maven/plugins/launch4j/VersionInfo.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/VersionInfo.java b/src/main/java/com/akathist/maven/plugins/launch4j/VersionInfo.java index 0ed5101..36ca7b2 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/VersionInfo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/VersionInfo.java @@ -90,4 +90,19 @@ net.sf.launch4j.config.VersionInfo toL4j() { return ret; } + @Override + public String toString() { + return "VersionInfo{" + + "fileVersion='" + fileVersion + '\'' + + ", txtFileVersion='" + txtFileVersion + '\'' + + ", fileDescription='" + fileDescription + '\'' + + ", copyright='" + copyright + '\'' + + ", productVersion='" + productVersion + '\'' + + ", txtProductVersion='" + txtProductVersion + '\'' + + ", productName='" + productName + '\'' + + ", companyName='" + companyName + '\'' + + ", internalName='" + internalName + '\'' + + ", originalFilename='" + originalFilename + '\'' + + '}'; + } } From 74d3ed5788ed3d492136a7bfdee32ecdb6224172 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 10 Oct 2014 08:49:55 +0200 Subject: [PATCH 24/37] Includes runtime artifacts in final class path, closes #5 --- .../maven/plugins/launch4j/ClassPath.java | 16 +++++++++++++++- .../maven/plugins/launch4j/Launch4jMojo.java | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java b/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java index 622d507..07283a9 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java @@ -78,7 +78,7 @@ private void addToCp(List cp, String cpStr) { cp.addAll(Arrays.asList(cpStr.split("\\s*;\\s*"))); } - net.sf.launch4j.config.ClassPath toL4j(Set dependencies) { + net.sf.launch4j.config.ClassPath toL4j(Set dependencies, List runtimeDependencies) { net.sf.launch4j.config.ClassPath ret = new net.sf.launch4j.config.ClassPath(); ret.setMainClass(mainClass); @@ -89,6 +89,9 @@ net.sf.launch4j.config.ClassPath toL4j(Set dependencies) { if (jarLocation == null) jarLocation = ""; else if ( ! jarLocation.endsWith("/")) jarLocation += "/"; + // Add all runtime dependencies as we need them to run the wrapped jar + dependencies.addAll(runtimeDependencies); + for (Object dependency : dependencies) { Artifact dep = (Artifact) dependency; if (Artifact.SCOPE_COMPILE.equals(dep.getScope()) || @@ -108,4 +111,15 @@ net.sf.launch4j.config.ClassPath toL4j(Set dependencies) { return ret; } + @Override + public String toString() { + return "ClassPath{" + + "mainClass='" + mainClass + '\'' + + ", addDependencies=" + addDependencies + + ", jarLocation='" + jarLocation + '\'' + + ", preCp='" + preCp + '\'' + + ", postCp='" + postCp + '\'' + + '}'; + } + } diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java index 69df02f..a8ea5dc 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java @@ -333,7 +333,7 @@ public void execute() throws MojoExecutionException { c.setVariables(vars); if (classPath != null) { - c.setClassPath(classPath.toL4j(dependencies)); + c.setClassPath(classPath.toL4j(dependencies, project.getRuntimeArtifacts())); } if (jre != null) { c.setJre(jre.toL4j()); From 1dd734eb77aa28a35bf5992f23f4e414b00f5eec Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 11 Oct 2014 09:32:55 +0200 Subject: [PATCH 25/37] Adds info about required Java version --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 115ba95..e7f3aa5 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ ## Version notes 1.6 - dropped Launch4j source and based on artifacts from Maven Central - uses the latest version of Launch4j (3.4.0) +- at least Java 1.7 is required # FAQ Q: I cannot build my project because `dsol-xml` dependency is missing? From 9c5975812563989d5be2efe01e14b2f3a5ec2a3d Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 16 Oct 2014 07:34:16 +0200 Subject: [PATCH 26/37] Upgrades Launch4j version to 3.5.0 --- pom.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4edc0d4..0266465 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,10 @@ This plugin creates Windows executables from Java jar files using the Launch4j utility. http://9stmaryrd.com/tools/launch4j-maven-plugin/ + + 3.5.0 + + GNU General Public License @@ -44,7 +48,7 @@ net.sf.launch4j launch4j - 3.4.0 + ${launch4j.version} core @@ -111,7 +115,7 @@ - org.eclipse.m2e From 53f037d6c6f9fbb78cd3936de57fc910006791b0 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 16 Oct 2014 07:34:42 +0200 Subject: [PATCH 27/37] Changes compiler target to 1.7 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0266465..d064ec5 100644 --- a/pom.xml +++ b/pom.xml @@ -91,8 +91,8 @@ maven-compiler-plugin 3.1 - 1.6 - 1.6 + 1.7 + 1.7 From 52f5ab3b5a08a32511eeeabe734c1aad173a0671 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 16 Oct 2014 07:34:59 +0200 Subject: [PATCH 28/37] Drops failing plugin --- pom.xml | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/pom.xml b/pom.xml index d064ec5..5ba8527 100644 --- a/pom.xml +++ b/pom.xml @@ -113,45 +113,6 @@ - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.apache.maven.plugins - - - maven-antrun-plugin - - - [1.3,) - - - run - - - - - false - - - - - - - - - - From f18cea1386caa0cc938f94e2290306308c1b1eb5 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 17 Oct 2014 07:54:58 +0200 Subject: [PATCH 29/37] [maven-release-plugin] prepare release launch4j-maven-plugin-1.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ba8527..a25069a 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.akathist.maven.plugins.launch4j launch4j-maven-plugin maven-plugin - 1.7-SNAPSHOT + 1.7 Maven Launch4j Plugin This plugin creates Windows executables from Java jar files using the Launch4j utility. From 122fad9c4091622158a0066a6fca1916372a6f12 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 17 Oct 2014 07:55:05 +0200 Subject: [PATCH 30/37] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a25069a..a26eaa8 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ com.akathist.maven.plugins.launch4j launch4j-maven-plugin maven-plugin - 1.7 + 1.8-SNAPSHOT Maven Launch4j Plugin This plugin creates Windows executables from Java jar files using the Launch4j utility. From 32319cf688a4278ab88a297327a49a50bcab8208 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 17 Oct 2014 08:07:24 +0200 Subject: [PATCH 31/37] Updates version notes for 1.7 --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7f3aa5..9b9246d 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,13 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ [![Build Status](https://travis-ci.org/lukaszlenart/launch4j-maven-plugin.svg)](https://travis-ci.org/lukaszlenart/launch4j-maven-plugin) +## Version notes 1.7 +- uses the latest version of Launch4j (3.5.0) +- contains support for `runtimeBits`, see #6 +- fixes problem with including dependencies in scope `runtime`, see #5 + ## Version notes 1.6 -- dropped Launch4j source and based on artifacts from Maven Central +- dropped Launch4j source and based on artifacts from Maven Central, see #8 - uses the latest version of Launch4j (3.4.0) - at least Java 1.7 is required From 0bade867f8436b18e8aae1fe30bca7240da66277 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 17 Oct 2014 08:25:47 +0200 Subject: [PATCH 32/37] Converts into links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9b9246d..0da861c 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ ## Version notes 1.7 - uses the latest version of Launch4j (3.5.0) -- contains support for `runtimeBits`, see #6 -- fixes problem with including dependencies in scope `runtime`, see #5 +- contains support for `runtimeBits`, see [#6](issues/6) +- fixes problem with including dependencies in scope `runtime`, see [#5](issues/5) ## Version notes 1.6 -- dropped Launch4j source and based on artifacts from Maven Central, see #8 +- dropped Launch4j source and based on artifacts from Maven Central, see [#8](issues/8) - uses the latest version of Launch4j (3.4.0) - at least Java 1.7 is required From 940a3e208e86c3edc6be6ee232e9ef5fe4286221 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 17 Oct 2014 08:27:05 +0200 Subject: [PATCH 33/37] Adds proper path --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0da861c..4137fcc 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ ## Version notes 1.7 - uses the latest version of Launch4j (3.5.0) -- contains support for `runtimeBits`, see [#6](issues/6) -- fixes problem with including dependencies in scope `runtime`, see [#5](issues/5) +- contains support for `runtimeBits`, see [#6](../issues/6) +- fixes problem with including dependencies in scope `runtime`, see [#5](../issues/5) ## Version notes 1.6 -- dropped Launch4j source and based on artifacts from Maven Central, see [#8](issues/8) +- dropped Launch4j source and based on artifacts from Maven Central, see [#8](../issues/8) - uses the latest version of Launch4j (3.4.0) - at least Java 1.7 is required From 07a7b1f1866e352ee8b9be98a8c2017f240525f6 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 17 Oct 2014 08:27:44 +0200 Subject: [PATCH 34/37] Adds one more level to path --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4137fcc..63c5d77 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Originally hosted at http://9stmaryrd.com/tools/launch4j-maven-plugin/ ## Version notes 1.7 - uses the latest version of Launch4j (3.5.0) -- contains support for `runtimeBits`, see [#6](../issues/6) -- fixes problem with including dependencies in scope `runtime`, see [#5](../issues/5) +- contains support for `runtimeBits`, see [#6](../../issues/6) +- fixes problem with including dependencies in scope `runtime`, see [#5](../../issues/5) ## Version notes 1.6 -- dropped Launch4j source and based on artifacts from Maven Central, see [#8](../issues/8) +- dropped Launch4j source and based on artifacts from Maven Central, see [#8](../../issues/8) - uses the latest version of Launch4j (3.4.0) - at least Java 1.7 is required From f867ce54f0d0dd7b9fd337b3dced8228b529d617 Mon Sep 17 00:00:00 2001 From: Thomas Scheithauer Date: Sun, 12 Mar 2017 14:04:49 +0100 Subject: [PATCH 35/37] Refine the selection of the platform specific binary bundle for macOS --- .../maven/plugins/launch4j/Launch4jMojo.java | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java index 0cae47f..076aaef 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java @@ -18,45 +18,34 @@ */ package com.akathist.maven.plugins.launch4j; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.Date; -import java.util.Enumeration; -import java.util.List; -import java.util.Set; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - import net.sf.launch4j.Builder; import net.sf.launch4j.BuilderException; import net.sf.launch4j.config.Config; import net.sf.launch4j.config.ConfigPersister; - import net.sf.launch4j.config.ConfigPersisterException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactCollector; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugins.annotations.Component; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.annotations.*; import org.apache.maven.project.MavenProject; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.*; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + /** * Wraps a jar in a Windows executable. */ @@ -462,6 +451,8 @@ private File unpackWorkDir(Artifact a) throws MojoExecutionException { File platJar = a.getFile(); File dest = platJar.getParentFile(); File marker = new File(dest, platJar.getName() + ".unpacked"); + String n = platJar.getName(); + File workdir = new File(dest, n.substring(0, n.length() - 4)); // If the artifact is a SNAPSHOT, then a.getVersion() will report the long timestamp, // but getFile() will be 1.1-SNAPSHOT. @@ -469,7 +460,7 @@ private File unpackWorkDir(Artifact a) throws MojoExecutionException { // Therefore we need to expand the jar every time, if the marker file is stale. if (marker.exists() && marker.lastModified() > platJar.lastModified()) { // if (marker.exists() && marker.platJar.getName().indexOf("SNAPSHOT") == -1) { - getLog().info("Platform-specific work directory already exists: " + dest.getAbsolutePath()); + getLog().info("Platform-specific work directory already exists: " + workdir.getAbsolutePath()); } else { JarFile jf = null; try { @@ -526,8 +517,6 @@ private File unpackWorkDir(Artifact a) throws MojoExecutionException { } } - String n = platJar.getName(); - File workdir = new File(dest, n.substring(0, n.length() - 4)); setPermissions(workdir); return workdir; } @@ -608,7 +597,7 @@ private Artifact chooseBinaryBits() throws MojoExecutionException { } else if ("Solaris".equals(os) || "SunOS".equals(os)) { plat = "solaris"; } else if ("Mac OS X".equals(os) || "Darwin".equals(os)) { - plat = "mac"; + plat = (isBelow10_8(System.getProperty("os.version"))) ? "mac" : "osx"; } else { throw new MojoExecutionException("Sorry, Launch4j doesn't support the '" + os + "' OS."); } @@ -617,6 +606,16 @@ private Artifact chooseBinaryBits() throws MojoExecutionException { getLaunch4jVersion(), "jar", "workdir-" + plat); } + private static boolean isBelow10_8(String version) { + String[] parts = version.split("\\."); + try { + int major = Integer.parseInt(parts[0]); + int minor = Integer.parseInt(parts[1]); + return (major < 10) || (major == 10) && (minor < 8); + } catch (NumberFormatException e) { + return false; + } + } private File getBaseDir() { return basedir; @@ -739,4 +738,4 @@ private String getLaunch4jVersion() throws MojoExecutionException { return version; } -} \ No newline at end of file +} From cd9ae03dbe11494cd995a29bf334edd1e8a27ba2 Mon Sep 17 00:00:00 2001 From: Thomas Scheithauer Date: Sun, 12 Mar 2017 14:48:56 +0100 Subject: [PATCH 36/37] Removed outdated README file --- src/main/resources/README | 258 -------------------------------------- 1 file changed, 258 deletions(-) delete mode 100644 src/main/resources/README diff --git a/src/main/resources/README b/src/main/resources/README deleted file mode 100644 index a526344..0000000 --- a/src/main/resources/README +++ /dev/null @@ -1,258 +0,0 @@ -Maven Launch4j Plugin 1.0 -A plugin for using Launch4j in Maven projects. -Copyright (c) 2006 Paul Jungwirth -16 October 2006 - -Launch4j by Grzegorz Kowal (http://launch4j.sourceforge.net/) wraps a jar file -in a Windows executable to ease deployment of Java desktop applications. You -can either bundle a JRE or tell Launch4j to search the hard drive for an -existing one. If none is found, then Launch4j will show the user a download -page. Launch4j has many features. You can create either GUI or console -applications. You can show a splash screen while the JRE loads, give your -application a custom icon in the Windows task bar, set a more descriptive -process name (other than "java"), and set a variety of other process attributes. - -You can run Launch4j on Windows, Linux, Solaris, or OS X. You specify the -configuration through an XML file. Please see the Launch4j site for more -information on this file. You can also set your configuration via the Launch4j -GUI. - -The Maven plugin for Launch4j lets you generate the Launch4j executable as part -of the Maven build process. It supports Maven 2.0.4 and Launch4j 3.0.0-pre1. -You don't have to download Launch4j; all the necessary files are included in -the plugin. (The plugin does not include Launch4j's GUI option.) Depending on -your operating system, the plugin will download an additional artifact -containing platform-specific binaries that Launch4j uses to create the -executable. This artifact is treated like any other Maven dependency, so it is -only downloaded the first time you need it. - -Using the Maven plugin, you specify the Launch4j configuration in your POM. I -hope to add support for external configuration files, but right now you have to -use the POM. The format of this configuration is very similar to the standard -Launch4j XML format. There are two main differences. First, any lists of -like-named elements must appear in a wrapper element. For example, you can't -say: - - logo.bin - this=that - foo=bar - blep=blurp - -You must say: - - logo.bin - - this=that - foo=bar - blep=blurp - - -Likewise for and elements. - -Second, the sub-elements of the element are a little different. -This is so you can set the classpath based on your depedencies. -still takes a element, but it does not take . Instead, it -supports these children: - - If you set this to "true," the plugin will build your - classpath based on all dependencies in the runtime and - compile scopes. This is on by default. - - If you are using the addDependencies feature, you can - use this option to add a prefix before each jar's name. - This is useful if you are bundling your app with the - executable alongside a lib directory that contains all - your jars. If that's what you're doing, you would specify - lib/. - - Use this to add classpath entries before the automatically- - generated list. This element functions whether you have - enabled or not. Entries in the list should - be separated by semicolons, as in a Windows-style CLASSPATH - variable. - - Use this to add classpath entries after the automatically- - generated list. This element functions whether you have - enabled or not. Entries in the list should - be separated by semicolons, as in a Windows-style CLASSPATH - variable. - -Other than these changes, the XML format is just like Launch4j's standard -format. - -By default, the Launch4j plugin is bound to the package phase. Suppose you have -a single-module project named encc. It is a console application, not a GUI. It -is packaged as a jar, so the jarring runs automatically during the package -phase before anything else. You want to use launch4j to create an executable -and then use the assmebly plugin to bundle everything up. You could bind both -launch4j and assembly to the package phase with a POM like this: - - - - . . . - com.akathist.encc - encc - jar - . . . - - - - com.akathist.maven.plugins.launch4j - launch4j-maven-plugin - - - l4j-clui - package - launch4j - - console - target/encc.exe - target/encc-1.0.jar - encc - - com.akathist.encc.Clui - false - anything - - - 1.5.0 - - - 1.2.3.4 - txt file version? - a description - my copyright - 4.3.2.1 - txt product version - E-N-C-C - ccne - original.exe - - - - - - - maven-assembly-plugin - - - assembly - package - attached - - - assembly.xml - - - - - - - - . . . - - - -Note that when you bind the assembly plugin to a phase, you must use -assembly:attached, not assembly:assembly, to prevent its forking a parallel -lifecycle and running everything twice. - -Or suppose your application can run in either GUI or console mode, and you want -to create separate executables for each. Then your POM would look like this: - - - - . . . - com.akathist.encc - encc - jar - . . . - - - - com.akathist.maven.plugins.launch4j - launch4j-maven-plugin - - - l4j-clui - package - launch4j - - console - target/encc.exe - target/encc-1.0.jar - encc - - com.akathist.encc.Clui - false - anything - - - 1.5.0 - - - 1.2.3.4 - txt file version? - a description - my copyright - 4.3.2.1 - txt product version - E-N-C-C - ccne - original.exe - - - - - l4j-gui - package - launch4j - - gui - target/enccg.exe - target/encc-1.0.jar - enccg - - com.akathist.encc.Gui - - - 1.5.0 - - - 1.2.3.4 - txt file version? - a description - my copyright - 4.3.2.1 - txt product version - E-N-C-C - ccne - original.exe - - - - - - - maven-assembly-plugin - - - assembly - package - attached - - - assembly.xml - - - - - - - - . . . - - - -If you have any questions, you can send a note to maven {a} 9stmaryrd * com. - From 0fc105aa3a5626d022c4f45929445c42736c0c19 Mon Sep 17 00:00:00 2001 From: Thomas Scheithauer Date: Mon, 13 Mar 2017 11:06:36 +0100 Subject: [PATCH 37/37] Refactored macOS system version detection --- .../com/akathist/maven/plugins/launch4j/Launch4jMojo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java index 076aaef..a391e69 100644 --- a/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java +++ b/src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java @@ -597,7 +597,7 @@ private Artifact chooseBinaryBits() throws MojoExecutionException { } else if ("Solaris".equals(os) || "SunOS".equals(os)) { plat = "solaris"; } else if ("Mac OS X".equals(os) || "Darwin".equals(os)) { - plat = (isBelow10_8(System.getProperty("os.version"))) ? "mac" : "osx"; + plat = isBelowMacOSX_10_8() ? "mac" : "osx"; } else { throw new MojoExecutionException("Sorry, Launch4j doesn't support the '" + os + "' OS."); } @@ -606,8 +606,8 @@ private Artifact chooseBinaryBits() throws MojoExecutionException { getLaunch4jVersion(), "jar", "workdir-" + plat); } - private static boolean isBelow10_8(String version) { - String[] parts = version.split("\\."); + private static boolean isBelowMacOSX_10_8() { + String[] parts = System.getProperty("os.version").split("\\."); try { int major = Integer.parseInt(parts[0]); int minor = Integer.parseInt(parts[1]);