2
* The Apache Software License, Version 1.1
4
* Copyright (c) 1999 The Apache Software Foundation. All rights
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
14
* 2. Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in
16
* the documentation and/or other materials provided with the
19
* 3. The end-user documentation included with the redistribution, if
20
* any, must include the following acknowlegement:
21
* "This product includes software developed by the
22
* Apache Software Foundation (http://www.apache.org/)."
23
* Alternately, this acknowlegement may appear in the software itself,
24
* if and wherever such third-party acknowlegements normally appear.
26
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
27
* Foundation" must not be used to endorse or promote products derived
28
* from this software without prior written permission. For written
29
* permission, please contact apache@apache.org.
31
* 5. Products derived from this software may not be called "Apache"
32
* nor may "Apache" appear in their names without prior written
33
* permission of the Apache Group.
35
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47
* ====================================================================
49
* This software consists of voluntary contributions made by many
50
* individuals on behalf of the Apache Software Foundation. For more
51
* information on the Apache Software Foundation, please see
52
* <http://www.apache.org/>.
55
package org.apache.tools.ant.taskdefs.optional.ide;
60
import com.ibm.ivj.util.base.ExportCodeSpec;
61
import com.ibm.ivj.util.base.IvjException;
62
import com.ibm.ivj.util.base.Package;
64
import java.util.Enumeration;
65
import java.util.Vector;
66
import org.apache.tools.ant.BuildException;
67
import org.apache.tools.ant.Project;
68
import org.apache.tools.ant.Task;
69
import org.apache.tools.ant.types.PatternSet;
72
* Export packages from the Visual Age for Java workspace.
73
* The packages are specified similar to all other MatchingTasks.
74
* Since the VA Workspace is not file based, this task is simulating
75
* a directory hierarchy for the workspace:
76
* The 'root' contains all project 'dir's, and the projects contain
77
* their respective package 'dir's.
80
* <vajexport destdir="C:/builddir/source">
81
* <include name="/MyVAProject/org/foo/subsystem1/**" />
82
* <exclude name="/MyVAProject/org/foo/subsystem1/test/**"/>
85
* exports all packages in the project MyVAProject which start with
86
* 'org.foo.subsystem1' except of these starting with
87
* 'org.foo.subsystem1.test'.
89
* There are flags to choose which items to export:
90
* exportSources: export Java sources
91
* exportResources: export project resources
92
* exportClasses: export class files
93
* exportDebugInfo: export class files with debug info (use with exportClasses)
94
* default is exporting Java files and resources.
96
* @author Wolf Siberski, TUI Infotec GmbH
99
public class VAJExport extends Task {
100
protected File destDir;
101
protected boolean exportSources = true;
102
protected boolean exportResources = true;
103
protected boolean exportClasses = false;
104
protected boolean exportDebugInfo = false;
105
protected boolean useDefaultExcludes = true;
107
protected PatternSet patternSet = new PatternSet();
110
* add a name entry on the exclude list
112
public PatternSet.NameEntry createExclude() {
113
return patternSet.createExclude();
117
* add a name entry on the include list
119
public PatternSet.NameEntry createInclude() {
120
return patternSet.createInclude();
126
public void execute() throws BuildException {
127
// first off, make sure that we've got a destdir
128
if (destDir == null) {
129
throw new BuildException("destdir attribute must be set!");
132
VAJWorkspaceScanner ds = this.getWorkspaceScanner();
134
Package[] packages = ds.getIncludedPackages();
140
* export the array of Packages
142
public void export(Package[] packages) {
144
String dest = destDir.getAbsolutePath();
146
log("Exporting " + packages.length + " package(s) to " + dest);
147
for (int i = 0; i < packages.length; i++) {
148
log(" " + packages[i].getName(), Project.MSG_VERBOSE);
151
ExportCodeSpec exportSpec = new ExportCodeSpec();
153
exportSpec.setPackages(packages);
154
exportSpec.includeJava(exportSources);
155
exportSpec.includeClass(exportClasses);
156
exportSpec.includeResources(exportResources);
157
exportSpec.includeClassDebugInfo(exportDebugInfo);
158
exportSpec.useSubdirectories(true);
159
exportSpec.overwriteFiles(true);
160
exportSpec.setExportDirectory(dest);
161
VAJUtil.getWorkspace().exportData(exportSpec);
162
} catch (IvjException ex) {
163
throw VAJUtil.createBuildException("Exporting failed!", ex);
168
* Returns the directory scanner needed to access the files to process.
170
protected VAJWorkspaceScanner getWorkspaceScanner() {
171
VAJWorkspaceScanner scanner = new VAJWorkspaceScanner();
172
scanner.setIncludes(patternSet.getIncludePatterns(getProject()));
173
scanner.setExcludes(patternSet.getExcludePatterns(getProject()));
174
if (useDefaultExcludes)
175
scanner.addDefaultExcludes();
181
* Sets whether default exclusions should be used or not.
183
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
184
* should be used, "false"|"off"|"no" when they
187
public void setDefaultexcludes(boolean useDefaultExcludes) {
188
this.useDefaultExcludes = useDefaultExcludes;
192
* Set the destination directory into which the Java source
193
* files should be compiled.
195
public void setDestdir(File destDir) {
196
this.destDir = destDir;
200
* Sets the set of exclude patterns. Patterns may be separated by a comma
203
* @param excludes the string containing the exclude patterns
205
public void setExcludes(String excludes) {
206
patternSet.setExcludes(excludes);
211
public void setExportClasses(boolean doExport) {
212
exportClasses = doExport;
217
public void setExportDebugInfo(boolean doExport) {
218
exportDebugInfo = doExport;
223
public void setExportResources(boolean doExport) {
224
exportResources = doExport;
229
public void setExportSources(boolean doExport) {
230
exportSources = doExport;
233
* Sets the set of include patterns. Patterns may be separated by a comma
236
* @param includes the string containing the include patterns
238
public void setIncludes(String includes) {
239
patternSet.setIncludes(includes);