KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ant > taskdefs > RemoveVersionTask


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2004-2005 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: RemoveVersionTask.java,v 1.3 2005/06/08 06:17:17 nickb Exp $
16  */

17 package org.eclipse.emf.ant.taskdefs;
18
19 import java.io.File JavaDoc;
20
21 import org.apache.tools.ant.BuildException;
22
23 import org.eclipse.emf.ant.util.Util;
24
25
26 /**
27  * <p>
28  * Removes the version of all the subdirectories of a given directory. See
29  * {@link Util#removeVersion(File)} for further details.
30  * This task may be usefull when generating code for which the defined model (a
31  * Rose file for example) depends on directory names to find its dependencies.
32  * </p>
33  * <p>
34  * If this task is executed by a Eclipse driver with the <b>org.eclipse.emf.ant</b>
35  * plugin, it is neither necessary to use Ant's task <tt>TaskDef</tt> to declare this
36  * task in a script nor to change the Ant's runtime classpath.
37  * </p>
38  * <p>
39  * Usage example:
40  * </p>
41  * <pre>
42  * &lt;emf.RemoveVersion parentDir=&quot;c:\eclipse\plugins&quot;/&gt;
43  * </pre>
44  *
45  * @since 2.1.0
46  */

47 public class RemoveVersionTask extends EMFTask
48 {
49   private File JavaDoc parentDir;
50
51   public void setParentDir(File JavaDoc dir)
52   {
53     parentDir = dir;
54   }
55
56   protected void checkAttributes() throws BuildException
57   {
58     assertTrue("The attribute 'parentDir' must indicate a valid directory.", parentDir != null && parentDir.isDirectory());
59     assertTrue("You must have read and write access to " + parentDir.getAbsolutePath() + ".", parentDir.canRead() && parentDir.canWrite());
60   }
61
62   protected void doExecute() throws Exception JavaDoc
63   {
64     Util.removeVersion(parentDir);
65   }
66 }
Popular Tags