├── src
└── main
│ ├── resources
│ ├── bin
│ │ ├── linux
│ │ │ ├── ld
│ │ │ ├── windres
│ │ │ └── COPYING
│ │ ├── mac
│ │ │ ├── ld
│ │ │ ├── windres
│ │ │ └── COPYING
│ │ └── windows
│ │ │ ├── ld.exe
│ │ │ ├── windres.exe
│ │ │ └── COPYING
│ ├── head
│ │ ├── head.o
│ │ ├── guihead.o
│ │ └── consolehead.o
│ ├── w32api
│ │ ├── crt2.o
│ │ ├── libgcc.a
│ │ ├── libmingw32.a
│ │ ├── libmsvcrt.a
│ │ ├── libshell32.a
│ │ ├── libuser32.a
│ │ ├── libadvapi32.a
│ │ ├── libkernel32.a
│ │ └── MinGW.LICENSE.txt
│ └── logback.xml
│ └── java
│ ├── GUIMavenCapsule.java
│ ├── capsule
│ ├── GUIDependencyManager.java
│ └── GUIListener.java
│ ├── GUICapsule.java
│ ├── co
│ └── paralleluniverse
│ │ └── desktop
│ │ └── Icons.java
│ └── NativeCapsule.java
├── .gitignore
├── settings.gradle
└── README.md
/src/main/resources/bin/linux/ld:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/bin/linux/ld
--------------------------------------------------------------------------------
/src/main/resources/bin/mac/ld:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/bin/mac/ld
--------------------------------------------------------------------------------
/src/main/resources/head/head.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/head/head.o
--------------------------------------------------------------------------------
/src/main/resources/head/guihead.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/head/guihead.o
--------------------------------------------------------------------------------
/src/main/resources/w32api/crt2.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/crt2.o
--------------------------------------------------------------------------------
/src/main/resources/bin/linux/windres:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/bin/linux/windres
--------------------------------------------------------------------------------
/src/main/resources/bin/mac/windres:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/bin/mac/windres
--------------------------------------------------------------------------------
/src/main/resources/w32api/libgcc.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/libgcc.a
--------------------------------------------------------------------------------
/src/main/resources/bin/windows/ld.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/bin/windows/ld.exe
--------------------------------------------------------------------------------
/src/main/resources/head/consolehead.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/head/consolehead.o
--------------------------------------------------------------------------------
/src/main/resources/w32api/libmingw32.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/libmingw32.a
--------------------------------------------------------------------------------
/src/main/resources/w32api/libmsvcrt.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/libmsvcrt.a
--------------------------------------------------------------------------------
/src/main/resources/w32api/libshell32.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/libshell32.a
--------------------------------------------------------------------------------
/src/main/resources/w32api/libuser32.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/libuser32.a
--------------------------------------------------------------------------------
/src/main/resources/w32api/libadvapi32.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/libadvapi32.a
--------------------------------------------------------------------------------
/src/main/resources/w32api/libkernel32.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/w32api/libkernel32.a
--------------------------------------------------------------------------------
/src/main/resources/bin/windows/windres.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/puniverse/capsule-desktop/HEAD/src/main/resources/bin/windows/windres.exe
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /dist/
3 | /out/
4 | _site/
5 | /docs/javadoc/
6 | .idea/
7 | *.iml
8 | /artifacts
9 | /nbproject/private/
10 | /.nb-gradle
11 | /build
12 | .gradle/
13 | .nb-gradle-properties
14 | Gemfile.lock
15 |
--------------------------------------------------------------------------------
/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d %level %logger - %m%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This settings file was auto generated by the Gradle buildInit task
3 | * by 'pron' at '11/27/14 3:06 PM' with Gradle 2.2.1
4 | *
5 | * The settings file is used to specify which projects to include in your build.
6 | * In a single project build this file can be empty or even removed.
7 | *
8 | * Detailed information about configuring a multi-project build in Gradle can be found
9 | * in the user guide at http://gradle.org/docs/2.2.1/userguide/multi_project_builds.html
10 | */
11 |
12 | /*
13 | // To declare projects as part of a multi-project build use the 'include' method
14 | include 'shared'
15 | include 'api'
16 | include 'services:webservice'
17 | */
18 |
19 | rootProject.name = 'capsule-desktop'
20 |
--------------------------------------------------------------------------------
/src/main/resources/w32api/MinGW.LICENSE.txt:
--------------------------------------------------------------------------------
1 | MinGW - Licensing Terms
2 |
3 | Various pieces distributed with MinGW come with its own copyright and license:
4 |
5 | Basic MinGW runtime
6 | MinGW base runtime package is uncopyrighted and placed in the public domain.
7 | This basically means that you can do what you want with the code.
8 |
9 | w32api
10 | You are free to use, modify and copy this package.
11 | No restrictions are imposed on programs or object files compiled with this library.
12 | You may not restrict the the usage of this library.
13 | You may distribute this library as part of another package or as a modified package
14 | if and only if you do not restrict the usage of the portions consisting
15 | of this (optionally modified) library.
16 | If distributed as a modified package then this file must be included.
17 |
18 | This library is distributed in the hope that it will be useful,
19 | but WITHOUT ANY WARRANTY; without even the implied warranty
20 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 |
22 | MinGW profiling code
23 | MinGW profiling code is distributed under the GNU General Public License.
24 |
25 | The development tools such as GCC, GDB, GNU Make, etc all covered by GNU General Public License.
26 |
--------------------------------------------------------------------------------
/src/main/java/GUIMavenCapsule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014-2015, Parallel Universe Software Co. and Contributors. All rights reserved.
3 | *
4 | * This program and the accompanying materials are licensed under the terms
5 | * of the Eclipse Public License v1.0, available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 |
9 | import capsule.DependencyManager;
10 | import capsule.GUIDependencyManager;
11 | import capsule.GUIListener;
12 |
13 | import java.nio.file.Path;
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | /**
18 | *
19 | * @author pron
20 | */
21 | public class GUIMavenCapsule extends MavenCapsule {
22 |
23 | protected static final Map.Entry ATTR_ICON = ATTRIBUTE("Icon", T_STRING(), null, true, "The path of the application's icon file(s), with no suffix, relative to the capsule root");
24 |
25 | public GUIMavenCapsule(Path jarFile) {
26 | super(jarFile);
27 | }
28 |
29 | public GUIMavenCapsule(Capsule pred) {
30 | super(pred);
31 | }
32 |
33 | private GUIListener listener;
34 |
35 | @Override
36 | protected ProcessBuilder prelaunch(List args, List jvmArgs) {
37 | this.listener = new GUIListener(getAttribute(ATTR_APP_NAME), getAttribute(ATTR_ICON));
38 | try {
39 | return super.prelaunch(args, jvmArgs);
40 | } finally {
41 | listener.dispose();
42 | }
43 | }
44 |
45 | @Override
46 | protected DependencyManager createDependencyManager(Path localRepo, boolean reset, int logLevel) {
47 | return new GUIDependencyManager(listener, localRepo, reset, logLevel);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/capsule/GUIDependencyManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014-2015, Parallel Universe Software Co. and Contributors. All rights reserved.
3 | *
4 | * This program and the accompanying materials are licensed under the terms
5 | * of the Eclipse Public License v1.0, available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 | package capsule;
9 |
10 | import capsule.org.eclipse.aether.AbstractForwardingRepositorySystemSession;
11 | import capsule.org.eclipse.aether.DefaultRepositorySystemSession;
12 | import capsule.org.eclipse.aether.RepositoryListener;
13 | import capsule.org.eclipse.aether.RepositorySystem;
14 | import capsule.org.eclipse.aether.RepositorySystemSession;
15 | import capsule.org.eclipse.aether.repository.LocalRepository;
16 | import capsule.org.eclipse.aether.transfer.TransferListener;
17 | import java.nio.file.Path;
18 |
19 | /**
20 | *
21 | * @author pron
22 | */
23 | public class GUIDependencyManager extends DependencyManager {
24 | private final GUIListener listener;
25 |
26 | public GUIDependencyManager(GUIListener listener, Path localRepoPath, boolean forceRefresh, int logLevel) {
27 | super(localRepoPath, forceRefresh, logLevel);
28 | this.listener = listener;
29 | }
30 |
31 | @Override
32 | protected RepositorySystemSession newRepositorySession(RepositorySystem system, LocalRepository localRepo) {
33 | final RepositorySystemSession s = super.newRepositorySession(system, localRepo);
34 |
35 | if (s instanceof DefaultRepositorySystemSession) {
36 | ((DefaultRepositorySystemSession) s).setTransferListener(listener.getTransferListener());
37 | ((DefaultRepositorySystemSession) s).setRepositoryListener(listener.getRepositoryListener());
38 | } else {
39 | return new AbstractForwardingRepositorySystemSession() {
40 | @Override
41 | protected RepositorySystemSession getSession() {
42 | return s;
43 | }
44 |
45 | @Override
46 | public TransferListener getTransferListener() {
47 | return listener.getTransferListener();
48 | }
49 |
50 | @Override
51 | public RepositoryListener getRepositoryListener() {
52 | return listener.getRepositoryListener();
53 | }
54 | };
55 | }
56 | return s;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/GUICapsule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014-2015, Parallel Universe Software Co. and Contributors. All rights reserved.
3 | *
4 | * This program and the accompanying materials are licensed under the terms
5 | * of the Eclipse Public License v1.0, available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 |
9 | import java.io.PrintWriter;
10 | import java.io.StringWriter;
11 | import java.nio.file.Path;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 | import java.util.Map.Entry;
15 | import javax.swing.JOptionPane;
16 |
17 | public class GUICapsule extends Capsule {
18 | protected static final Entry ATTR_SPLASH = ATTRIBUTE("Splash-Image", T_STRING(), null, true, "The path of the application's splash image, with no suffix, relative to the capsule root");
19 |
20 | protected static final Entry ATTR_GUI = ATTRIBUTE("GUI", T_BOOL(), false, true, "Whether or not this Capsule uses a GUI");
21 |
22 | public GUICapsule(Capsule pred) {
23 | super(pred);
24 | }
25 |
26 | public GUICapsule(Path jarFile) {
27 | super(jarFile);
28 | }
29 |
30 | boolean isGUI() {
31 | return getAttribute(ATTR_GUI);
32 | }
33 |
34 | @Override
35 | protected void onError(Throwable t) {
36 | final StringBuilder sb = new StringBuilder();
37 | sb.append("CAPSULE EXCEPTION: ").append(t.getMessage()).append('\n');
38 |
39 | final StringWriter stackTrace = new StringWriter();
40 | t.printStackTrace(new PrintWriter(stackTrace));
41 |
42 | sb.append('\n').append(stackTrace).append("\n");
43 | JOptionPane.showMessageDialog(null, sb, "Capsule Error", JOptionPane.ERROR_MESSAGE);
44 | }
45 |
46 | @Override
47 | protected Path getJavaExecutable() {
48 | final Path p = super.getJavaExecutable();
49 | return isWindows() ? p.getParent().resolve(p.getFileName().toString().replace("java.exe", "javaw.exe")) : p;
50 | }
51 |
52 | @Override
53 | protected Process postlaunch(Process child) {
54 | return null; // don't wait for child process
55 | }
56 |
57 |
58 | @Override
59 | @SuppressWarnings("unchecked")
60 | protected T attribute(Entry attr) {
61 | if (ATTR_JVM_ARGS == attr) {
62 | if (hasAttribute(ATTR_SPLASH)) {
63 | final List args = new ArrayList<>(super.attribute(ATTR_JVM_ARGS));
64 | args.add("-splash:" + getWritableAppCache().resolve(getAttribute(ATTR_SPLASH)));
65 | return (T) args;
66 | }
67 | }
68 | return super.attribute(attr);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Capsule Desktop
2 |
3 | This application will build Mac OS X, Linux and/or Windows native executables for a [capsule](https://github.com/puniverse/capsule).
4 |
5 | ## Usage
6 |
7 | `capsule-desktop` is itself distributed as a capsule. Run it with the `-?` option to print the usage information:
8 |
9 | ```
10 | Option Description
11 | ------ -----------
12 | -?, -h, --help Show help
13 | -c, --capsule
16 | -l, --loglevel
18 | -m, --macosx Build Mac OS X binary
19 | -o, --output
22 | -u, --unix Build Unix binary
23 | -w, --windows Build Windows binary
24 | ```
25 |
26 | `capsule-desktop` can be run both against plain (e.g. "fat") capsules and [Maven-based](https://github.com/puniverse/capsule-desktop) ones.
27 |
28 | An [example Java Swing application is available](https://github.com/puniverse/capsule-gui-demo) that can conveniently be used to try out `capsule-desktop`.
29 |
30 | The following section explains additional application-specific manifest entries that `capsule-desktop` can use.
31 |
32 | ## Additional Capsule manifest entries
33 |
34 | * `GUI`: whether the `GUIMavenCapsule` caplet should be used instead of `MavenCapsule`. The former will launch a basic Swing-based window displaying dependencies retrieval progress. In addition, when this option is active, Capsule won't wait for the application JVM process to complete before exiting.
35 | * `Icon`: the icon to be used for the desktop application.
36 | * `Single-Instance`: if `true` will enforce a single-instance run policy for the native application built by `capsule-desktop`. It currently only works on Mac OS X and Windows.
37 | * `Implementation-Vendor`, `Native-Description`, `Copyright` and `Internal-Name`: if any of these native metadata entries is present then the other ones must be present as well. Native metadata is currently only supported on Windows
38 |
39 | ## License
40 |
41 | Copyright (c) 2014-2015, Parallel Universe Software Co. and Contributors. All rights reserved.
42 |
43 | This program and the accompanying materials are licensed under the terms
44 | of the Eclipse Public License v1.0 as published by the Eclipse Foundation.
45 |
46 | http://www.eclipse.org/legal/epl-v10.html
47 |
--------------------------------------------------------------------------------
/src/main/java/co/paralleluniverse/desktop/Icons.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014-2015, Parallel Universe Software Co. and Contributors. All rights reserved.
3 | *
4 | * This program and the accompanying materials are licensed under the terms
5 | * of the Eclipse Public License v1.0, available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 | package co.paralleluniverse.desktop;
9 |
10 | //import java.awt.image.BufferedImage;
11 | //import java.io.FileNotFoundException;
12 | //import java.io.IOException;
13 | //import java.io.InputStream;
14 | //import java.io.OutputStream;
15 | //import java.util.List;
16 | //import org.apache.commons.imaging.ImageFormat;
17 | //import org.apache.commons.imaging.ImageFormats;
18 | //import org.apache.commons.imaging.Imaging;
19 | //import org.apache.commons.imaging.ImagingException;
20 | //import org.apache.commons.io.IOUtils;
21 |
22 |
23 |
24 | /**
25 | *
26 | * @author pron
27 | */
28 | public class Icons {
29 | // public enum Type {
30 | // ICO, ICNS, PNG
31 | // };
32 | //
33 | // public static void getIcon(String resource, Type outputType, OutputStream os) throws IOException {
34 | // String filename = resource + toSuffix(outputType);
35 | // try (InputStream is = Icons.class.getClassLoader().getResourceAsStream(filename)) {
36 | // if (is != null) {
37 | // IOUtils.copy(is, os);
38 | // return;
39 | // }
40 | // }
41 | // throw new FileNotFoundException(filename);
42 |
43 | // Unfortunately Commons Imaging doesn't support writing multiple icon images into the same file (but it does support reading)
44 | // try {
45 | // for (Type t : Type.values()) {
46 | // if (t != outputType) {
47 | // filename = resource + toSuffix(t);
48 | // try (InputStream is = Icons.class.getClassLoader().getResourceAsStream(filename)) {
49 | // if (is != null) {
50 | // final List icons = Imaging.getAllBufferedImages(is, filename);
51 | // Imaging.writeImage(icons???, os, toImageFormat(outputType), null);
52 | // }
53 | // }
54 | // }
55 | // }
56 | // } catch (ImagingException e) {
57 | // throw new RuntimeException(e);
58 | // }
59 | // }
60 | //
61 | // private static ImageFormat toImageFormat(Type iconType) {
62 | // switch (iconType) {
63 | // case ICNS:
64 | // return ImageFormats.ICNS;
65 | // case ICO:
66 | // return ImageFormats.ICO;
67 | // case PNG:
68 | // return ImageFormats.PNG;
69 | // default:
70 | // throw new IllegalArgumentException("Icon type: " + iconType);
71 | // }
72 | // }
73 | //
74 | // private static String toSuffix(Type iconType) {
75 | // switch (iconType) {
76 | // case ICNS:
77 | // return ".icns";
78 | // case ICO:
79 | // return ".ico";
80 | // case PNG:
81 | // return ".png";
82 | // default:
83 | // throw new IllegalArgumentException("Icon type: " + iconType);
84 | // }
85 | // }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/capsule/GUIListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014-2015, Parallel Universe Software Co. and Contributors. All rights reserved.
3 | *
4 | * This program and the accompanying materials are licensed under the terms
5 | * of the Eclipse Public License v1.0, available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 | package capsule;
9 |
10 | import capsule.org.eclipse.aether.RepositoryListener;
11 | import capsule.org.eclipse.aether.transfer.AbstractTransferListener;
12 | import capsule.org.eclipse.aether.transfer.TransferCancelledException;
13 | import capsule.org.eclipse.aether.transfer.TransferEvent;
14 | import capsule.org.eclipse.aether.transfer.TransferListener;
15 | import java.awt.BorderLayout;
16 | import java.awt.Insets;
17 | import java.io.OutputStream;
18 | import java.io.PrintStream;
19 | import javax.swing.BorderFactory;
20 | import javax.swing.ImageIcon;
21 | import javax.swing.JFrame;
22 | import javax.swing.JPanel;
23 | import javax.swing.JProgressBar;
24 | import javax.swing.JScrollPane;
25 | import javax.swing.JTextArea;
26 | import javax.swing.SwingUtilities;
27 | import javax.swing.UIManager;
28 | import javax.swing.UnsupportedLookAndFeelException;
29 |
30 | /**
31 | *
32 | * @author pron
33 | */
34 | public class GUIListener {
35 | private final long start;
36 |
37 | private volatile JFrame frame;
38 | private JPanel content;
39 | private JProgressBar progress;
40 | private final JTextArea text;
41 | private final String name;
42 | private final String icon;
43 | private final RepositoryListener repositoryListener;
44 | private final TransferListener transferListener;
45 | private volatile boolean disposed;
46 |
47 | public GUIListener(String name, String icon) {
48 | this.start = System.nanoTime();
49 | this.name = name;
50 | this.icon = icon;
51 |
52 | this.text = new JTextArea(5, 20);
53 | text.setMargin(new Insets(5, 5, 5, 5));
54 | text.setEditable(false);
55 |
56 | progress = new JProgressBar(0, 100);
57 | progress.setValue(0);
58 | progress.setStringPainted(true);
59 |
60 | this.repositoryListener = new ConsoleRepositoryListener(false, new PrintStream(new TextAreaOutputStream(text)));
61 | this.transferListener = new AbstractTransferListener() {
62 |
63 | @Override
64 | public void transferInitiated(TransferEvent te) throws TransferCancelledException {
65 | init();
66 | progress.setIndeterminate(true);
67 | }
68 |
69 | @Override
70 | public void transferStarted(TransferEvent event) throws TransferCancelledException {
71 | init();
72 | progress.setIndeterminate(false);
73 | progress.setMaximum(100);
74 | }
75 |
76 | @Override
77 | public void transferProgressed(TransferEvent te) throws TransferCancelledException {
78 | init();
79 | progress.setValue((int) (100.0 * (double) te.getTransferredBytes() / (double) te.getResource().getContentLength()));
80 | }
81 |
82 | @Override
83 | public void transferSucceeded(TransferEvent te) {
84 | progress.setValue(100);
85 | }
86 | };
87 | }
88 |
89 | private long elapsedMillis() {
90 | return (System.nanoTime() - start) / 1000000;
91 | }
92 |
93 | private void init() {
94 | if (!disposed && frame == null && elapsedMillis() > 1000) {
95 | try {
96 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
97 | } catch (ReflectiveOperationException | UnsupportedLookAndFeelException ex) {
98 | }
99 |
100 | SwingUtilities.invokeLater(new Runnable() {
101 | @Override
102 | public void run() {
103 | frame = new JFrame(name);
104 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
105 |
106 | if (icon != null)
107 | frame.setIconImage(new ImageIcon(iconFile(icon)).getImage());
108 |
109 | createContent();
110 | content.setOpaque(true);
111 | frame.setContentPane(content);
112 |
113 | frame.pack();
114 | frame.setVisible(true);
115 | }
116 | });
117 | }
118 | }
119 |
120 | private static String iconFile(String icon) {
121 | if (icon == null)
122 | return null;
123 | if (isWindows())
124 | return icon + ".ico";
125 | if (isMac())
126 | return icon + ".icns";
127 | return icon + ".png";
128 | }
129 |
130 | private void createContent() {
131 | content = new JPanel(new BorderLayout());
132 |
133 | final JPanel panel = new JPanel();
134 | panel.add(progress);
135 | // panel.add(label);
136 |
137 | content.add(panel, BorderLayout.PAGE_START);
138 | content.add(new JScrollPane(text), BorderLayout.CENTER);
139 | content.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
140 | }
141 |
142 | public void dispose() {
143 | this.disposed = true;
144 | if (frame != null) {
145 | frame.setVisible(false);
146 | frame.dispose();
147 | }
148 | }
149 |
150 | public TransferListener getTransferListener() {
151 | return transferListener;
152 | }
153 |
154 | public RepositoryListener getRepositoryListener() {
155 | return repositoryListener;
156 | }
157 |
158 | private static class TextAreaOutputStream extends OutputStream {
159 | private final JTextArea textArea;
160 |
161 | public TextAreaOutputStream(JTextArea textArea) {
162 | this.textArea = textArea;
163 | }
164 |
165 | @Override
166 | public void write(int b) {
167 | textArea.append(String.valueOf((char) b));
168 | textArea.setCaretPosition(textArea.getDocument().getLength());
169 | }
170 | }
171 |
172 | protected static final boolean isWindows() {
173 | return System.getProperty("os.name").toLowerCase().startsWith("windows");
174 | }
175 |
176 | protected static final boolean isMac() {
177 | return System.getProperty("os.name").toLowerCase().startsWith("mac");
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/src/main/resources/bin/mac/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C) 19yy
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License
307 | along with this program; if not, write to the Free Software
308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309 |
310 |
311 | Also add information on how to contact you by electronic and paper mail.
312 |
313 | If the program is interactive, make it output a short notice like this
314 | when it starts in an interactive mode:
315 |
316 | Gnomovision version 69, Copyright (C) 19yy name of author
317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 | This is free software, and you are welcome to redistribute it
319 | under certain conditions; type `show c' for details.
320 |
321 | The hypothetical commands `show w' and `show c' should show the appropriate
322 | parts of the General Public License. Of course, the commands you use may
323 | be called something other than `show w' and `show c'; they could even be
324 | mouse-clicks or menu items--whatever suits your program.
325 |
326 | You should also get your employer (if you work as a programmer) or your
327 | school, if any, to sign a "copyright disclaimer" for the program, if
328 | necessary. Here is a sample; alter the names:
329 |
330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
332 |
333 | , 1 April 1989
334 | Ty Coon, President of Vice
335 |
336 | This General Public License does not permit incorporating your program into
337 | proprietary programs. If your program is a subroutine library, you may
338 | consider it more useful to permit linking proprietary applications with the
339 | library. If this is what you want to do, use the GNU Library General
340 | Public License instead of this License.
341 |
--------------------------------------------------------------------------------
/src/main/resources/bin/linux/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C) 19yy
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License
307 | along with this program; if not, write to the Free Software
308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309 |
310 |
311 | Also add information on how to contact you by electronic and paper mail.
312 |
313 | If the program is interactive, make it output a short notice like this
314 | when it starts in an interactive mode:
315 |
316 | Gnomovision version 69, Copyright (C) 19yy name of author
317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 | This is free software, and you are welcome to redistribute it
319 | under certain conditions; type `show c' for details.
320 |
321 | The hypothetical commands `show w' and `show c' should show the appropriate
322 | parts of the General Public License. Of course, the commands you use may
323 | be called something other than `show w' and `show c'; they could even be
324 | mouse-clicks or menu items--whatever suits your program.
325 |
326 | You should also get your employer (if you work as a programmer) or your
327 | school, if any, to sign a "copyright disclaimer" for the program, if
328 | necessary. Here is a sample; alter the names:
329 |
330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
332 |
333 | , 1 April 1989
334 | Ty Coon, President of Vice
335 |
336 | This General Public License does not permit incorporating your program into
337 | proprietary programs. If your program is a subroutine library, you may
338 | consider it more useful to permit linking proprietary applications with the
339 | library. If this is what you want to do, use the GNU Library General
340 | Public License instead of this License.
341 |
--------------------------------------------------------------------------------
/src/main/resources/bin/windows/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C) 19yy
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License
307 | along with this program; if not, write to the Free Software
308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309 |
310 |
311 | Also add information on how to contact you by electronic and paper mail.
312 |
313 | If the program is interactive, make it output a short notice like this
314 | when it starts in an interactive mode:
315 |
316 | Gnomovision version 69, Copyright (C) 19yy name of author
317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 | This is free software, and you are welcome to redistribute it
319 | under certain conditions; type `show c' for details.
320 |
321 | The hypothetical commands `show w' and `show c' should show the appropriate
322 | parts of the General Public License. Of course, the commands you use may
323 | be called something other than `show w' and `show c'; they could even be
324 | mouse-clicks or menu items--whatever suits your program.
325 |
326 | You should also get your employer (if you work as a programmer) or your
327 | school, if any, to sign a "copyright disclaimer" for the program, if
328 | necessary. Here is a sample; alter the names:
329 |
330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
332 |
333 | , 1 April 1989
334 | Ty Coon, President of Vice
335 |
336 | This General Public License does not permit incorporating your program into
337 | proprietary programs. If your program is a subroutine library, you may
338 | consider it more useful to permit linking proprietary applications with the
339 | library. If this is what you want to do, use the GNU Library General
340 | Public License instead of this License.
341 |
--------------------------------------------------------------------------------
/src/main/java/NativeCapsule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014-2015, Parallel Universe Software Co. and Contributors. All rights reserved.
3 | *
4 | * This program and the accompanying materials are licensed under the terms
5 | * of the Eclipse Public License v1.0, available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 |
9 | import capsule.GUIListener;
10 | import ch.qos.logback.classic.Level;
11 | import co.paralleluniverse.capsule.*;
12 | import net.sf.launch4j.Builder;
13 | import net.sf.launch4j.Log;
14 | import net.sf.launch4j.config.*;
15 |
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 | import java.io.OutputStream;
19 | import java.io.PrintWriter;
20 | import java.net.URI;
21 | import java.net.URISyntaxException;
22 | import java.net.URL;
23 | import java.net.URLClassLoader;
24 | import java.nio.charset.Charset;
25 | import java.nio.file.*;
26 | import java.nio.file.attribute.PosixFilePermission;
27 | import java.util.*;
28 |
29 | import joptsimple.OptionParser;
30 | import joptsimple.OptionSet;
31 | import joptsimple.OptionSpec;
32 | import org.slf4j.Logger;
33 | import org.slf4j.LoggerFactory;
34 |
35 | import static java.util.Arrays.*;
36 |
37 | /**
38 | * Wrapping capsule that will build and launch a native desktop GUI or non-GUI app.
39 | *
40 | * @author pron
41 | * @author circlespainter
42 | */
43 | public class NativeCapsule {
44 |
45 | protected static final String ATTR_GUI = "GUI";
46 | protected static final String ATTR_ICON = "Icon";
47 | protected static final String ATTR_SINGLE_INSTANCE = "Single-Instance";
48 |
49 | protected static final String ATTR_IMPLEMENTATION_VENDOR = "Implementation-Vendor";
50 |
51 | protected static final String ATTR_NATIVE_DESCRIPTION = "Native-Description";
52 | protected static final String ATTR_COPYRIGHT = "Copyright";
53 | protected static final String ATTR_INTERNAL_NAME = "Internal-Name";
54 |
55 | private static final String GUI_CAPSULE_NAME = "GUICapsule";
56 | private static final String MAVEN_CAPSULE_NAME = "MavenCapsule";
57 | private static final String GUI_MAVEN_CAPSULE_NAME = "GUIMavenCapsule";
58 |
59 | private static Logger log = LoggerFactory.getLogger(NativeCapsule.class);
60 |
61 | private static List tmpFiles = new ArrayList<>();
62 | private static Path inCapsulePath;
63 | private static String outBasePath;
64 | private static co.paralleluniverse.capsule.Capsule inCapsule;
65 | private static boolean buildMac, buildUnix, buildWindows;
66 |
67 | public static void main(String[] args) throws IOException {
68 | final OptionParser parser = new OptionParser();
69 | final OptionSpec c = parser.acceptsAll(asList("c", "capsule")).withRequiredArg().ofType(String.class).describedAs("A single capsule pathname to build native binaries for");
70 | final OptionSpec o = parser.acceptsAll(asList("o", "output")).withRequiredArg().ofType(String.class).describedAs("The base output pathname of built binaries (default = the capsule pathname)");
71 | final OptionSpec l = parser.acceptsAll(asList("l", "loglevel")).withRequiredArg().ofType(String.class).describedAs("Log level (default = INFO)");
72 | parser.acceptsAll(asList("m", "macosx"), "Build Mac OS X binary");
73 | parser.acceptsAll(asList("u", "unix"), "Build Unix binary");
74 | parser.acceptsAll(asList("w", "windows"), "Build Windows binary");
75 | parser.acceptsAll(asList("h", "?", "help"), "Show help").forHelp();
76 | final OptionSet options = parser.parse(args);
77 |
78 | if (!options.has(c) || options.valuesOf(c).size() != 1 || options.valuesOf(o).size() > 1 || options.valuesOf(l).size() > 1) {
79 | log.error("Command-line validation failed");
80 | parser.printHelpOn(System.err);
81 | System.exit(-1);
82 | }
83 |
84 | if (options.has(l))
85 | ((ch.qos.logback.classic.Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.toLevel(options.valueOf(l), Level.INFO));
86 |
87 | inCapsulePath = Paths.get(options.valueOf(c));
88 | log.debug("Input capsule: {}", inCapsulePath.toAbsolutePath().normalize().toString());
89 | inCapsule = new CapsuleLauncher(inCapsulePath).newCapsule();
90 | outBasePath = options.valuesOf(o).size() == 1 ? options.valueOf(o) : getOutputBase();
91 | log.debug("Output binary prefix: {}", outBasePath);
92 | buildMac = options.has("m") || options.has("macosx");
93 | buildUnix = options.has("u") || options.has("unix");
94 | buildWindows = options.has("w") || options.has("windows");
95 |
96 | buildNative();
97 |
98 | log.debug("Removing temp files");
99 | for (final Path p : tmpFiles)
100 | Capsule.delete(p);
101 | }
102 |
103 | private static String getOutputBase() {
104 | return getOutputBase(null);
105 | }
106 |
107 | private static String getOutputBase(String outBase) {
108 | if (outBase == null) {
109 | outBase = inCapsulePath.toAbsolutePath().normalize().toString();
110 | if (outBase.toLowerCase().endsWith(".jar"))
111 | outBase = outBase.substring(0, outBase.indexOf(".jar"));
112 | }
113 | return outBase;
114 | }
115 |
116 | private static void buildNative() {
117 | final String outBase = getOutputBase(outBasePath);
118 | try {
119 | final List platforms = new ArrayList<>();
120 | if (buildMac)
121 | platforms.add(Platform.OS_MACOS);
122 | if (buildUnix)
123 | platforms.add(Platform.OS_UNIX);
124 | if (buildWindows)
125 | platforms.add(Platform.OS_WINDOWS);
126 |
127 | if (platforms.isEmpty())
128 | platforms.add("CURRENT"); // Default
129 |
130 | log.debug("Building native binaries for the following platforms: {}", platforms.toString());
131 |
132 | for (final String p : platforms)
133 | buildApp(p, Paths.get(outBase));
134 | } catch (IOException e) {
135 | throw new RuntimeException(e);
136 | }
137 | }
138 |
139 | private static void buildApp(String platform, Path out) throws IOException {
140 | if (Platform.OS_MACOS.equals(platform))
141 | buildMacApp(out);
142 | else if (Platform.OS_UNIX.equals(platform))
143 | buildUnixApp(out);
144 | else if (Platform.OS_WINDOWS.equals(platform))
145 | buildWindowsApp(out);
146 | else if ("CURRENT".equals(platform))
147 | buildApp(Platform.myPlatform().getOS(), out);
148 | else
149 | throw new RuntimeException("Platform \"" + platform + "\" is unsupported");
150 | }
151 |
152 | private static String getSimpleCapsuleName() {
153 | final String filename = inCapsulePath.getFileName().toString();
154 | return filename.endsWith(".jar") ? filename.substring(0, filename.length() - 4) : filename;
155 | }
156 |
157 | private static Jar createJar(Path out) throws IOException {
158 | final Jar jar = new Jar(inCapsulePath);
159 | if (out != null) {
160 | log.debug("Creating JAR for native app: {}", out.toAbsolutePath().normalize().toString());
161 | jar.setOutput(out);
162 | }
163 | return jar;
164 | }
165 |
166 | private static boolean isGUIApp() {
167 | if (inCapsule.hasAttribute(Attribute.named(ATTR_GUI))) {
168 | try {
169 | return Boolean.parseBoolean(inCapsule.getAttribute(Attribute.named(ATTR_GUI)));
170 | } catch (Throwable ignored) {}
171 | }
172 | return false;
173 | }
174 |
175 | private static Path buildWindowsApp(Path out) throws IOException {
176 | log.debug("Building native Windows app: {}", out.toAbsolutePath().normalize().toString());
177 |
178 | setLaunch4JBinDir();
179 | setLaunch4JLibDir();
180 | setLaunch4JHeadDir();
181 | setLaunch4JTmpDir();
182 |
183 | Path tmpJar = null;
184 | Path icon = null;
185 | try {
186 | if (isGUIApp()) {
187 | tmpJar = Files.createTempFile("native-capsule-", ".jar");
188 | log.debug("Creating Windows temp jar {}", tmpJar.toFile().toString());
189 | Jar j = createJar(tmpJar);
190 | makeGUICapsule(j);
191 | j.close();
192 | }
193 | final Path jar = tmpJar != null ? tmpJar : inCapsulePath;
194 |
195 | ConfigPersister.getInstance().createBlank();
196 | final Config c = ConfigPersister.getInstance().getConfig();
197 | final String head = isGUIApp() ? Config.GUI_HEADER : Config.CONSOLE_HEADER;
198 | log.debug("Windows: using head type {}", head);
199 | c.setHeaderType(head);
200 | c.setOutfile(withSuffix(out, ".exe").toFile());
201 | log.debug("Windows: using jar {}", jar.toAbsolutePath().normalize().toString());
202 | log.debug("Windows: writing to {}", c.getOutfile().toString());
203 | c.setJar(jar.toFile());
204 |
205 | if (inCapsule.hasAttribute(Attribute.named(Capsule.ATTR_MIN_JAVA_VERSION.getKey()))) {
206 | final String minJavaVersion = inCapsule.getAttribute(Attribute.named(Capsule.ATTR_MIN_JAVA_VERSION.getKey()));
207 | log.debug("Windows: requiring minumum Java version {}", minJavaVersion);
208 | c.getJre().setMinVersion(minJavaVersion);
209 | }
210 | if (inCapsule.hasAttribute(Attribute.named(Capsule.ATTR_JAVA_VERSION.getKey()))) {
211 | final String maxJavaVersion = inCapsule.getAttribute(Attribute.named(Capsule.ATTR_JAVA_VERSION.getKey()));
212 | log.debug("Windows: requiring maximum Java version {}", maxJavaVersion);
213 | c.getJre().setMaxVersion(maxJavaVersion);
214 | }
215 | if (inCapsule.hasAttribute(Attribute.named(Capsule.ATTR_JDK_REQUIRED.getKey()))) {
216 | final String jdkPreference = inCapsule.getAttribute(Attribute.named(Capsule.ATTR_JDK_REQUIRED.getKey())) ?
217 | Jre.JDK_PREFERENCE_JDK_ONLY : null;
218 | log.debug("Windows: JDK preferred = {}", Jre.JDK_PREFERENCE_JDK_ONLY.equals(jdkPreference) ? "true" : "false");
219 | c.getJre().setJdkPreference(jdkPreference);
220 | }
221 |
222 | if (inCapsule.hasAttribute(Attribute.named(ATTR_SINGLE_INSTANCE))) {
223 | boolean singleInstance = false;
224 | try {
225 | singleInstance = Boolean.parseBoolean(inCapsule.getAttribute(Attribute.named(ATTR_SINGLE_INSTANCE)));
226 | } catch (Throwable ignored) {}
227 | if (singleInstance) {
228 | log.debug("Windows: restricting to single instance as requested");
229 | final SingleInstance si = new SingleInstance();
230 | si.setWindowTitle(inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_NAME.getKey())));
231 | si.setMutexName(inCapsule.getAppId());
232 | c.setSingleInstance(si);
233 | }
234 | }
235 |
236 | if (inCapsule.getAttribute(Attribute.named(ATTR_IMPLEMENTATION_VENDOR)) != null
237 | || inCapsule.getAttribute(Attribute.named(ATTR_NATIVE_DESCRIPTION)) != null
238 | || inCapsule.getAttribute(Attribute.named(ATTR_COPYRIGHT)) != null
239 | || inCapsule.getAttribute(Attribute.named(ATTR_INTERNAL_NAME)) != null) {
240 | log.debug("Windows: detected metadata attributes, setting them");
241 |
242 | final VersionInfo versionInfo = new VersionInfo();
243 | versionInfo.setCompanyName(inCapsule.getAttribute(Attribute.named(ATTR_IMPLEMENTATION_VENDOR)));
244 | versionInfo.setProductName(inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_NAME.getKey())));
245 | versionInfo.setFileVersion(versionToWindowsVersion(inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_VERSION.getKey()))));
246 | versionInfo.setFileDescription(inCapsule.getAttribute(Attribute.named(ATTR_NATIVE_DESCRIPTION)));
247 | versionInfo.setCopyright(inCapsule.getAttribute(Attribute.named(ATTR_COPYRIGHT)));
248 | versionInfo.setInternalName(inCapsule.getAttribute(Attribute.named(ATTR_INTERNAL_NAME)));
249 | versionInfo.setOriginalFilename(withSuffix(out, ".exe").toFile().getName());
250 | versionInfo.setProductVersion(versionToWindowsVersion(inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_VERSION.getKey()))));
251 | versionInfo.setTxtFileVersion(inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_VERSION.getKey())));
252 | versionInfo.setTxtProductVersion(inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_VERSION.getKey())));
253 | c.setVersionInfo(versionInfo);
254 | }
255 |
256 | if (inCapsule.hasAttribute(Attribute.named(ATTR_ICON))) {
257 | final URLClassLoader urlClassLoader = new URLClassLoader( new URL[] { inCapsulePath.toUri().toURL() } );
258 | InputStream input = null;
259 | String resName = null;
260 | try {
261 | resName = inCapsule.getAttribute(Attribute.named(ATTR_ICON)) + ".ico";
262 | log.debug("Windows: attempting to use icon {}", resName);
263 | input = urlClassLoader.getResourceAsStream(resName);
264 | } catch (Throwable ignored) {
265 | log.info("Windows: icon resource {} can't be opened, omitting", resName);
266 | }
267 | if (input != null) {
268 | boolean success = false;
269 | long copied;
270 | try {
271 | icon = Files.createTempFile("", ".ico");
272 | log.debug("Windows: copying icon resource to {} and setting launch4j icon", icon.toString());
273 | copied = Files.copy(input, icon, StandardCopyOption.REPLACE_EXISTING);
274 | if (copied > 0) {
275 | log.debug("Windows: icon copied successfully to resource to {}, bytes {}", icon.toString(), copied);
276 | success = true;
277 | }
278 | } catch (IOException ioe) {
279 | log.info("Windows: icon resource can't be copied successfully to {}, error: {}", resName, ioe.getMessage());
280 | } finally {
281 | input.close();
282 | if (success)
283 | c.setIcon(icon.toFile());
284 | else
285 | log.info("Windows: icon resource {} can't be read, omitting", resName);
286 | }
287 | } else {
288 | log.info("Windows: icon resource {} can't be found, omitting", resName);
289 | }
290 | }
291 |
292 | final Builder builder = new Builder(Log.getConsoleLog(), findOwnJarFile(NativeCapsule.class).toAbsolutePath().getParent().toFile());
293 | builder.build();
294 |
295 | log.debug("Windows native app build complete");
296 |
297 | return out;
298 | } catch (Exception e) {
299 | throw new RuntimeException(e);
300 | } finally {
301 | if (tmpJar != null)
302 | Files.delete(tmpJar);
303 | if (icon != null)
304 | Files.delete(icon);
305 | }
306 | }
307 |
308 | private static String versionToWindowsVersion(String version) {
309 | for (int count = version.split("\\.").length; count < 4; count++)
310 | version += ".0";
311 | return version;
312 | }
313 |
314 | private static Path setLaunch4JTmpDir() {
315 | try {
316 | final Path tmpDir = addTempFile(Files.createTempDirectory("capsule-launch4j-tmp-"));
317 | log.debug("Creating and setting launch4j temp dir {}", tmpDir.toAbsolutePath().normalize().toString());
318 | System.setProperty("launch4j.tmpdir", tmpDir.toString());
319 | return tmpDir;
320 | } catch (IOException e) {
321 | throw new RuntimeException("Could not create temporary directory necessary for building a Windows executable", e);
322 | }
323 | }
324 |
325 | private static Path setLaunch4JLibDir() {
326 | try {
327 | final Path libDir = findOwnJarFile(NativeCapsule.class).toAbsolutePath().getParent().resolve("w32api");
328 | final String[] linkFiles = new String[] {
329 | "crt2.o", "libadvapi32.a", "libgcc.a", "libkernel32.a", "libmingw32.a",
330 | "libmsvcrt.a", "libshell32.a", "libuser32.a"
331 | };
332 | log.debug("Copying launch4j w32api linkfiles {} to {}", Arrays.toString(linkFiles), libDir.toAbsolutePath().normalize().toString());
333 |
334 | if (Files.exists(libDir))
335 | Capsule.delete(libDir);
336 | addTempFile(Files.createDirectory(libDir));
337 |
338 | for (final String f : linkFiles)
339 | copy(f, "w32api", libDir);
340 |
341 | return libDir;
342 | } catch (IOException e) {
343 | throw new RuntimeException("Could not extract libraries necessary for building a Windows executable", e);
344 | }
345 | }
346 |
347 | private static Path setLaunch4JHeadDir() {
348 | try {
349 | final Path libDir = findOwnJarFile(NativeCapsule.class).toAbsolutePath().getParent().resolve("head");
350 | final String[] headFiles = new String[] { "consolehead.o", "guihead.o", "head.o" };
351 | log.debug("Copying launch4j headers {} to {}", Arrays.toString(headFiles), libDir.toAbsolutePath().normalize().toString());
352 |
353 | if (Files.exists(libDir))
354 | Capsule.delete(libDir);
355 | addTempFile(Files.createDirectory(libDir));
356 |
357 | for (final String f : headFiles)
358 | copy(f, "head", libDir);
359 |
360 | return libDir;
361 | } catch (IOException e) {
362 | throw new RuntimeException("Could not extract libraries necessary for building a Windows executable", e);
363 | }
364 | }
365 |
366 | private static void setLaunch4JBinDir() {
367 | if (Platform.myPlatform().isMac())
368 | copyLaunch4JBins("mac", new String[]{"ld", "windres"});
369 | else if (Platform.myPlatform().isLinux())
370 | copyLaunch4JBins("linux", new String[]{"ld", "windres"});
371 | else if (Platform.myPlatform().isWindows())
372 | copyLaunch4JBins("windows", new String[]{"ld.exe", "windres.exe"});
373 | else if (Platform.myPlatform().isUnix())
374 | log.warn("Detected non-Linux Unix platform, assuming launch4j's 'ld' and 'windres' can be found on the path");
375 | else
376 | throw new RuntimeException(Platform.myPlatform() + " is not supported");
377 | }
378 |
379 | private static Path copyLaunch4JBins(String os, String[] bins) {
380 | try {
381 | final Path binDir = addTempFile(Files.createTempDirectory("capsule-launch4j-bin-"));
382 | log.debug("Copying launch4j binaries {} for platform {} to {} and setting 'launch4j.bindir' system property", Arrays.toString(bins), os, binDir.toAbsolutePath().normalize().toString());
383 | for (String filename : bins)
384 | ensureExecutable(copy(filename, "bin/" + os, binDir));
385 | System.setProperty("launch4j.bindir", binDir.toString());
386 | return binDir;
387 | } catch (IOException e) {
388 | throw new RuntimeException("Could not extract binaries necessary for building a Windows executable", e);
389 | }
390 | }
391 |
392 | private static Path copy(String fileName, String resourceDir, Path targetDir) throws IOException {
393 | log.debug("Copying resource {} to {}", resourceDir + '/' + fileName, targetDir);
394 | try (InputStream in = NativeCapsule.class.getClassLoader().getResourceAsStream(resourceDir + '/' + fileName);
395 | OutputStream out = Files.newOutputStream(targetDir.resolve(fileName))) {
396 | copy(in, out);
397 | return targetDir.resolve(fileName);
398 | }
399 | }
400 |
401 | private static Path buildUnixApp(Path out) throws IOException {
402 | log.debug("Building native Unix app: {}", out);
403 |
404 | final Jar jar = createJar(out);
405 | makeUnixExecutable(jar);
406 | if (isGUIApp())
407 | makeGUICapsule(jar);
408 | jar.close();
409 | ensureExecutable(out);
410 |
411 | log.debug("Unix native app build complete");
412 |
413 | return out;
414 | }
415 |
416 | private static Path buildMacApp(Path out) throws IOException {
417 | out = withSuffix(out, ".app");
418 |
419 | log.debug("Building native Mac OS X app: {}", out);
420 |
421 | Capsule.delete(out);
422 | Files.createDirectory(out);
423 |
424 | final Path contents = out.resolve("Contents");
425 | Files.createDirectory(contents);
426 | try (PrintWriter info = new PrintWriter(Files.newBufferedWriter(contents.resolve("Info.plist"), Charset.forName("UTF-8")))) {
427 | writeInfo(info);
428 | }
429 |
430 | final Path resources = contents.resolve("Resources");
431 | Files.createDirectory(resources);
432 | final Path macos = contents.resolve("MacOS");
433 | Files.createDirectory(macos);
434 | final Path outJarPath = macos.resolve(getSimpleCapsuleName());
435 | final Jar jar = createJar(outJarPath);
436 | if (inCapsule.hasAttribute(Attribute.named(ATTR_ICON))) {
437 | final URLClassLoader urlClassLoader = new URLClassLoader( new URL[] { inCapsulePath.toUri().toURL() } );
438 | InputStream input = null;
439 | String resName = null;
440 | try {
441 | resName = inCapsule.getAttribute(Attribute.named(ATTR_ICON)) + ".icns";
442 | log.debug("Mac OS X: attempting to use icon {}", resName);
443 | input = urlClassLoader.getResourceAsStream(resName);
444 | } catch (Throwable ignored) {
445 | log.info("Mac OS X: icon resource {} can't be opened, omitting", resName);
446 | }
447 | if (resName != null && input != null) {
448 | boolean success = false;
449 | long copied;
450 | try {
451 | final Path iconOut = resources.resolve(resName);
452 | log.debug("Mac OS X: copying icon resource to {}", iconOut);
453 | copied = Files.copy(input, iconOut);
454 | if (copied > 0) {
455 | log.debug("Mac OS X: icon copied successfully to resource to {}, bytes {}", iconOut.toString(), copied);
456 | success = true;
457 | }
458 | } catch (IOException ioe) {
459 | log.info("Mac OS X: icon resource can't be copied successfully to {}, error: {}", resName, ioe.getMessage());
460 | } finally {
461 | input.close();
462 | if (!success)
463 | log.info("Windows: icon resource {} can't be read, omitting", resName);
464 | }
465 | } else {
466 | log.info("Mac OS X: icon resource {} can't be found, omitting", resName);
467 | }
468 | }
469 | makeUnixExecutable(jar);
470 | if (isGUIApp())
471 | makeGUICapsule(jar);
472 | jar.close();
473 | ensureExecutable(outJarPath);
474 |
475 | log.debug("Mac OS X native app build complete");
476 |
477 | return out;
478 | }
479 |
480 | private static void writeInfo(PrintWriter out) {
481 | out.println("");
482 | out.println("");
483 | out.println("");
484 | out.println("");
485 | out.println(" CFBundleGetInfoString");
486 | out.println(" " + getSimpleCapsuleName() + "");
487 | out.println(" CFBundleExecutable");
488 | out.println(" " + getSimpleCapsuleName() + "");
489 | out.println(" CFBundleIdentifier");
490 | out.println(" " + inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_NAME.getKey())) + "");
491 | out.println(" CFBundleName");
492 | out.println(" " + inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_NAME.getKey())) + "");
493 | if (inCapsule.hasAttribute(Attribute.named(ATTR_ICON))) {
494 | out.println(" CFBundleIconFile");
495 | out.println(" " + inCapsule.getAttribute(Attribute.named(ATTR_ICON)) + "");
496 | }
497 | if (inCapsule.hasAttribute(Attribute.named(Capsule.ATTR_APP_VERSION.getKey()))) {
498 | out.println(" CFBundleShortVersionString");
499 | out.println(" " + inCapsule.getAttribute(Attribute.named(Capsule.ATTR_APP_VERSION.getKey())) + "");
500 | }
501 | out.println(" CFBundleShortVersionString");
502 | out.println(" 1.0");
503 | out.println(" CFBundleInfoDictionaryVersion");
504 | out.println(" 6.0");
505 | out.println(" CFBundlePackageType");
506 | out.println(" APPL");
507 | out.println(" CFBundleSignature");
508 | out.println(" ????");
509 | out.println("");
510 | out.println("");
511 | }
512 |
513 | private static Jar makeUnixExecutable(Jar jar) {
514 | log.debug("Setting JAR prefix as native Unix executable");
515 | return jar.setJarPrefix("#!/bin/sh\n\nexec java -jar $0 \"$@\"\n");
516 | }
517 |
518 | private static Jar makeGUICapsule(Jar jar) throws IOException {
519 | log.debug("Making a GUI capsule");
520 |
521 | List caplets = inCapsule.getAttribute(Attribute.>named(Capsule.ATTR_CAPLETS.getKey()));
522 | //noinspection Convert2Diamond
523 | caplets = caplets == null ? new ArrayList() : new ArrayList(caplets);
524 |
525 | log.debug("GUI: adding {}", GUI_CAPSULE_NAME);
526 | caplets.add(GUI_CAPSULE_NAME);
527 |
528 | boolean usesMaven = false;
529 | for (Class> c : inCapsule.getCaplets()) {
530 | if (CapletUtil.isSubclass(c, MAVEN_CAPSULE_NAME)) {
531 | // The 2-stage Capsule lookup/resolve rule is:
532 | //
533 | // | Each `lookup` / `resolve`-customizing capsule must return from `lookup` values that only its own
534 | // | `resolve` can handle. Else (f.e. when extending `MavenCapsule`) the capsule-building process must
535 | // | make sure that only one of the capsules that can `resolve` the same `lookup` values is present
536 | // | in the chain.
537 |
538 | log.debug("GUI: removing non-GUI Maven caplet {}", c.getName());
539 | if (caplets.remove(c.getName()))
540 | log.debug("GUI: successfully removed non-GUI Maven caplet {}", c.getName());
541 | usesMaven = true;
542 | }
543 | }
544 | if (usesMaven) {
545 | log.debug("GUI: adding GUI Maven caplet {}", GUI_MAVEN_CAPSULE_NAME);
546 | caplets.add(GUI_MAVEN_CAPSULE_NAME);
547 | }
548 |
549 | jar.setListAttribute("Caplets", caplets);
550 |
551 | // jar.addClass(NativeCapsule.class);
552 | jar.addClass(GUICapsule.class);
553 | if (inCapsule.hasCaplet(MAVEN_CAPSULE_NAME)) {
554 | jar.addEntry("GUIMavenCapsule.class", NativeCapsule.class.getResourceAsStream("GUIMavenCapsule.class"));
555 | jar.addPackageOf(GUIListener.class, Jar.matches("capsule/((GUIDependencyManager)|(GUIListener)).*"));
556 | }
557 | return jar;
558 | }
559 |
560 | private static Path withSuffix(Path path, String suffix) {
561 | return path.getFileName().toString().endsWith(suffix) ?
562 | path : path.toAbsolutePath().getParent().resolve(path.getFileName().toString() + suffix);
563 | }
564 |
565 | private static Path findOwnJarFile(Class clazz) {
566 | final URL url = clazz.getClassLoader().getResource(clazz.getName().replace('.', '/') + ".class");
567 | assert url != null;
568 | if (!"jar".equals(url.getProtocol()))
569 | throw new AssertionError("Not in JAR");
570 | final String path = url.getPath();
571 | if (path == null || !path.startsWith("file:"))
572 | throw new IllegalStateException("Not in a local JAR file; loaded from: " + url);
573 |
574 | try {
575 | final URI jarUri = new URI(path.substring(0, path.indexOf('!')));
576 | return Paths.get(jarUri);
577 | } catch (URISyntaxException e) {
578 | throw new AssertionError(e);
579 | }
580 | }
581 |
582 | protected static void copy(InputStream is, OutputStream out) throws IOException {
583 | final byte[] buffer = new byte[1024];
584 | for (int bytesRead ; (bytesRead = is.read(buffer)) != -1 ; )
585 | out.write(buffer, 0, bytesRead);
586 | out.flush();
587 | }
588 |
589 | private static Path ensureExecutable(Path file) {
590 | log.debug("Ensuring executable: {}", file.toAbsolutePath().normalize().toString());
591 | if (!Files.isExecutable(file)) {
592 | try {
593 | Set perms = Files.getPosixFilePermissions(file);
594 | if (!perms.contains(PosixFilePermission.OWNER_EXECUTE)) {
595 | Set newPerms = EnumSet.copyOf(perms);
596 | newPerms.add(PosixFilePermission.OWNER_EXECUTE);
597 | Files.setPosixFilePermissions(file, newPerms);
598 | }
599 | } catch (IOException e) {
600 | throw new RuntimeException(e);
601 | }
602 | }
603 | return file;
604 | }
605 |
606 | private static Path addTempFile(Path file) {
607 | log.debug("Adding temp file: {}", file.toAbsolutePath().normalize().toString());
608 | tmpFiles.add(file);
609 | return file;
610 | }
611 | }
612 |
--------------------------------------------------------------------------------