~ubuntu-branches/ubuntu/maverick/proguard/maverick

« back to all changes in this revision

Viewing changes to src/proguard/ant/ProGuardTask.java

  • Committer: Bazaar Package Importer
  • Author(s): Sam Clegg
  • Date: 2005-11-13 09:42:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051113094259-432zf4yyw4890mmn
Tags: 3.4-1
* New upstream release (Closes: #338355)
* debian/control: bump standards version
* debian/copyright: update FSF address
* increase java stack size for proguard and proguardgui

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: ProGuardTask.java,v 1.28 2004/11/20 15:08:57 eric Exp $
 
1
/* $Id: ProGuardTask.java,v 1.32 2005/06/11 13:21:35 eric Exp $
2
2
 *
3
3
 * ProGuard -- shrinking, optimization, and obfuscation of Java class files.
4
4
 *
5
 
 * Copyright (c) 2002-2004 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2005 Eric Lafortune (eric@graphics.cornell.edu)
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify it
8
8
 * under the terms of the GNU General Public License as published by the Free
39
39
    {
40
40
        try
41
41
        {
42
 
            ConfigurationParser parser = new ConfigurationParser(configurationFile.getPath());
43
 
            parser.parse(configuration);
 
42
            ConfigurationParser parser = new ConfigurationParser(configurationFile);
 
43
 
 
44
            try
 
45
            {
 
46
                parser.parse(configuration);
 
47
            }
 
48
            catch (ParseException ex)
 
49
            {
 
50
                throw new BuildException(ex.getMessage());
 
51
            }
 
52
            finally
 
53
            {
 
54
                parser.close();
 
55
            }
44
56
        }
45
57
        catch (IOException ex)
46
58
        {
47
59
            throw new BuildException(ex.getMessage());
48
60
        }
49
 
        catch (ParseException ex)
50
 
        {
51
 
            throw new BuildException(ex.getMessage());
52
 
        }
53
61
    }
54
62
 
55
63
 
76
84
 
77
85
    public void setPrintseeds(File printSeeds)
78
86
    {
79
 
        configuration.printSeeds = optionalFileName(printSeeds);
 
87
        configuration.printSeeds = optionalFile(printSeeds);
80
88
    }
81
89
 
82
90
 
88
96
 
89
97
    public void setPrintusage(File printUsage)
90
98
    {
91
 
        configuration.printUsage = optionalFileName(printUsage);
 
99
        configuration.printUsage = optionalFile(printUsage);
92
100
    }
93
101
 
94
102
 
112
120
 
113
121
    public void setPrintmapping(File printMapping)
114
122
    {
115
 
        configuration.printMapping = optionalFileName(printMapping);
 
123
        configuration.printMapping = optionalFile(printMapping);
116
124
    }
117
125
 
118
126
 
119
 
    public void setApplymapping(String applyMapping)
 
127
    public void setApplymapping(File applyMapping)
120
128
    {
121
 
        configuration.applyMapping = applyMapping;
 
129
        configuration.applyMapping = resolvedFile(applyMapping);
122
130
    }
123
131
 
124
132
 
125
133
    public void setObfuscationdictionary(File obfuscationDictionary)
126
134
    {
127
 
        configuration.obfuscationDictionary = obfuscationDictionary.getName();
 
135
        configuration.obfuscationDictionary = resolvedFile(obfuscationDictionary);
128
136
    }
129
137
 
130
138
 
178
186
 
179
187
    public void setDump(File dump)
180
188
    {
181
 
        configuration.dump = optionalFileName(dump);
 
189
        configuration.dump = optionalFile(dump);
182
190
    }
183
191
 
184
192
 
200
208
 
201
209
    // Small utility methods.
202
210
 
203
 
    private String optionalFileName(File file)
 
211
    /**
 
212
     * Returns a file that is properly resolved with respect to the project
 
213
     * directory, or <code>null</code> or empty if its name is actually a
 
214
     * boolean flag.
 
215
     */
 
216
    private File optionalFile(File file)
204
217
    {
205
218
        String fileName = file.getName();
206
219
 
210
223
            fileName.equalsIgnoreCase("off")    ? null :
211
224
            fileName.equalsIgnoreCase("true")  ||
212
225
            fileName.equalsIgnoreCase("yes")   ||
213
 
            fileName.equalsIgnoreCase("on")     ? ""   :
214
 
                                                  file.getPath();
 
226
            fileName.equalsIgnoreCase("on")     ? new File("")   :
 
227
                                                  resolvedFile(file);
 
228
    }
 
229
 
 
230
 
 
231
    /**
 
232
     * Returns a file that is properly resolved with respect to the project
 
233
     * directory.
 
234
     */
 
235
    private File resolvedFile(File file)
 
236
    {
 
237
        return file.isAbsolute() ? file :
 
238
                                   new File(getProject().getBaseDir(),
 
239
                                            file.getName());
215
240
    }
216
241
}