source: release-kits/wirk3/bin/launch4j/src/net/sf/launch4j/ant/Launch4jTask.java@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 3.6 KB
Line 
1/*
2 Launch4j (http://launch4j.sourceforge.net/)
3 Cross-platform Java application wrapper for creating Windows native executables.
4
5 Copyright (C) 2004, 2006 Grzegorz Kowal
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22/*
23 * Created on May 24, 2005
24 */
25package net.sf.launch4j.ant;
26
27import java.io.File;
28
29import net.sf.launch4j.Builder;
30import net.sf.launch4j.BuilderException;
31import net.sf.launch4j.Log;
32import net.sf.launch4j.config.Config;
33import net.sf.launch4j.config.ConfigPersister;
34import net.sf.launch4j.config.ConfigPersisterException;
35
36import org.apache.tools.ant.BuildException;
37import org.apache.tools.ant.Task;
38
39/**
40 * @author Copyright (C) 2005 Grzegorz Kowal
41 */
42public class Launch4jTask extends Task {
43 private File _configFile;
44 private AntConfig _config;
45
46 // Override configFile settings
47 private File jar;
48 private File outfile;
49 private String fileVersion;
50 private String txtFileVersion;
51 private String productVersion;
52 private String txtProductVersion;
53
54 public void execute() throws BuildException {
55 try {
56 if (_configFile != null && _config != null) {
57 throw new BuildException(
58 Messages.getString("Launch4jTask.specify.config")); //$NON-NLS-1$
59 } else if (_configFile != null) {
60 ConfigPersister.getInstance().load(_configFile);
61 Config c = ConfigPersister.getInstance().getConfig();
62 if (jar != null) {
63 c.setJar(jar);
64 }
65 if (outfile != null) {
66 c.setOutfile(outfile);
67 }
68 if (fileVersion != null) {
69 c.getVersionInfo().setFileVersion(fileVersion);
70 }
71 if (txtFileVersion != null) {
72 c.getVersionInfo().setTxtFileVersion(txtFileVersion);
73 }
74 if (productVersion != null) {
75 c.getVersionInfo().setProductVersion(productVersion);
76 }
77 if (txtProductVersion != null) {
78 c.getVersionInfo().setTxtProductVersion(txtProductVersion);
79 }
80 } else if (_config != null) {
81 ConfigPersister.getInstance().setAntConfig(_config,
82 getProject().getBaseDir());
83 } else {
84 throw new BuildException(
85 Messages.getString("Launch4jTask.specify.config")); //$NON-NLS-1$
86 }
87 final Builder b = new Builder(Log.getAntLog());
88 b.build();
89 } catch (ConfigPersisterException e) {
90 throw new BuildException(e);
91 } catch (BuilderException e) {
92 throw new BuildException(e);
93 }
94 }
95
96 public void setConfigFile(File configFile) {
97 _configFile = configFile;
98 }
99
100 public void addConfig(AntConfig config) {
101 _config = config;
102 }
103
104 public void setFileVersion(String fileVersion) {
105 this.fileVersion = fileVersion;
106 }
107
108 public void setJar(File jar) {
109 this.jar = jar;
110 }
111
112 public void setJarPath(String path) {
113 this.jar = new File(path);
114 }
115
116 public void setOutfile(File outfile) {
117 this.outfile = outfile;
118 }
119
120 public void setProductVersion(String productVersion) {
121 this.productVersion = productVersion;
122 }
123
124 public void setTxtFileVersion(String txtFileVersion) {
125 this.txtFileVersion = txtFileVersion;
126 }
127
128 public void setTxtProductVersion(String txtProductVersion) {
129 this.txtProductVersion = txtProductVersion;
130 }
131}
Note: See TracBrowser for help on using the repository browser.