[jboss-cvs] JBossAS SVN: r62371 - branches/JBoss_4_0_1_SP1_CP/testsuite/src/main/org/jboss/ant/taksdefs.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 16 14:48:19 EDT 2007
Author: jaroslaw.kijanowski
Date: 2007-04-16 14:48:19 -0400 (Mon, 16 Apr 2007)
New Revision: 62371
Added:
branches/JBoss_4_0_1_SP1_CP/testsuite/src/main/org/jboss/ant/taksdefs/AntCallOnDirectoryList.java
Log:
backport AntCallOnDirectoryList needed for compatibility matrix
Added: branches/JBoss_4_0_1_SP1_CP/testsuite/src/main/org/jboss/ant/taksdefs/AntCallOnDirectoryList.java
===================================================================
--- branches/JBoss_4_0_1_SP1_CP/testsuite/src/main/org/jboss/ant/taksdefs/AntCallOnDirectoryList.java (rev 0)
+++ branches/JBoss_4_0_1_SP1_CP/testsuite/src/main/org/jboss/ant/taksdefs/AntCallOnDirectoryList.java 2007-04-16 18:48:19 UTC (rev 62371)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, the OpenSource webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ant.taskdefs;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.taskdefs.Ant;
+import org.apache.tools.ant.taskdefs.Property;
+import org.apache.tools.ant.util.SourceFileScanner;
+import org.apache.tools.ant.util.FlatFileNameMapper;
+import org.apache.tools.ant.types.DirSet;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.File;
+
+
+/**
+ * This class will call a specified ant class for each existent file into fileSet or dirSet
+ *
+ * @author Clebert.suconic at jboss.com
+ */
+public class AntCallOnDirectoryList extends Task
+{
+ ArrayList list = new ArrayList();
+
+ String targetToExecute;
+
+ String directoryProperty;
+ String versionNameProperty;
+
+ Ant ant = null;
+
+ public String getVersionNameProperty()
+ {
+ return versionNameProperty;
+ }
+
+ public void setVersionNameProperty(String versionNameProperty)
+ {
+ this.versionNameProperty = versionNameProperty;
+ }
+
+ public String getTargetToExecute()
+ {
+ return targetToExecute;
+ }
+
+ public void setTargetToExecute(String targetToExecute)
+ {
+ this.targetToExecute = targetToExecute;
+ }
+
+ public String getDirectoryProperty()
+ {
+ return directoryProperty;
+ }
+
+ public void setDirectoryProperty(String directoryProperty)
+ {
+ this.directoryProperty = directoryProperty;
+ }
+
+
+ public void init()
+ {
+ super.init();
+ ant = (Ant) this.getProject().createTask("ant");
+ ant.setAntfile(this.getProject().getProperty("ant.file"));
+ ant.setOwningTarget(getOwningTarget());
+ ant.setTaskName(getTaskName());
+ ant.setLocation(getLocation());
+ ant.init();
+ }
+
+
+ public void addDirSet(DirSet dirSet)
+ {
+ list.add(dirSet);
+ }
+
+ public void execute() throws BuildException
+ {
+ init();
+ ant.setTarget(getTargetToExecute());
+ Property parameterDirectory = ant.createProperty();
+ parameterDirectory.setName(this.getDirectoryProperty());
+
+ Property parameterName = ant.createProperty();
+ parameterName.setName(this.getVersionNameProperty());
+
+
+ Iterator iter = list.iterator();
+ while (iter.hasNext())
+ {
+ DirSet dirSet = (DirSet) iter.next();
+ File currentDir = dirSet.getDir(this.getProject());
+ DirectoryScanner scanner = dirSet.getDirectoryScanner(this.getProject());
+
+ SourceFileScanner sourceScanner = new SourceFileScanner(this);
+ String[] strfiles = scanner.getIncludedDirectories();
+ ArrayList files = new ArrayList();
+ for (int i = 0; i < strfiles.length; i++)
+ {
+ File currentFile = new File(currentDir, strfiles[i]);
+ if (currentFile.getParentFile().getAbsolutePath().equals(currentDir.getAbsolutePath()))
+ {
+ files.add(currentFile);
+ parameterDirectory.setValue(currentFile.getAbsolutePath());
+ parameterName.setValue(currentFile.getName());
+ ant.execute();
+ }
+ }
+
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list