01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: /* $Id: BulkCopyTask.java 416058 2006-06-21 18:24:05Z andreas $ */
20:
21: package org.apache.lenya.cms.ant;
22:
23: import java.io.File;
24: import java.util.List;
25: import java.util.StringTokenizer;
26:
27: import org.apache.tools.ant.BuildException;
28: import org.apache.tools.ant.taskdefs.Copy;
29: import org.apache.tools.ant.types.FileSet;
30: import org.apache.tools.ant.types.Path;
31:
32: /**
33: * Copies all files matching filename or a all specififed filesets from each source directory.
34: * <br/><br/>
35: * Usage:
36: * <bulkCopy
37: * sourcedirs="dirOne:dirTwo"
38: * todir="WEB-INF/"
39: * flatten="true">
40: * <fileset includes="java/lib/*"/>
41: * </bulkCopy>
42: * <br/><br/>
43: * The above sample copies <em>dirOne/java/lib/*</em> and <em>dirTwo/java/lib/*</em>
44: * to <em>WEB-INF/lib</em>.
45: */
46: public class BulkCopyTask extends Copy {
47:
48: private Path sourceDirs;
49:
50: /**
51: * @see org.apache.tools.ant.taskdefs.Copy#execute()
52: */
53: public void execute() throws BuildException {
54:
55: final StringTokenizer sourceDirTokens = new StringTokenizer(
56: this .sourceDirs.toString(), File.pathSeparator);
57:
58: while (sourceDirTokens.hasMoreTokens()) {
59: final String sourceDir = sourceDirTokens.nextToken();
60:
61: for (int i = 0; i < getFileSets().size(); i++)
62: ((FileSet) getFileSets().get(i)).setDir(new File(
63: sourceDir));
64:
65: super .execute();
66: }
67: }
68:
69: /**
70: * @param _sourceDirs Colon separated list of source directories
71: */
72: public void setSourceDirs(Path _sourceDirs) {
73: this .sourceDirs = _sourceDirs;
74: }
75:
76: /**
77: * @return Returns the fileSet.
78: */
79: private List getFileSets() {
80: return super.filesets;
81: }
82: }
|