incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickcha...@apache.org
Subject svn commit: rev 6875 - incubator/depot/trunk/ruper/src/java/ant/org/apache/ruper/ant/sandbox/chalko
Date Thu, 26 Feb 2004 08:55:57 GMT
Author: nickchalko
Date: Thu Feb 26 00:55:57 2004
New Revision: 6875

Modified:
   incubator/depot/trunk/ruper/src/java/ant/org/apache/ruper/ant/sandbox/chalko/RuperSet.java
Log:
Added getting and creating the repo dir.

Modified: incubator/depot/trunk/ruper/src/java/ant/org/apache/ruper/ant/sandbox/chalko/RuperSet.java
==============================================================================
--- incubator/depot/trunk/ruper/src/java/ant/org/apache/ruper/ant/sandbox/chalko/RuperSet.java
(original)
+++ incubator/depot/trunk/ruper/src/java/ant/org/apache/ruper/ant/sandbox/chalko/RuperSet.java
Thu Feb 26 00:55:57 2004
@@ -15,9 +15,12 @@
  * ========================================================================
  */
 package org.apache.ruper.ant.sandbox.chalko;
+import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.FileScanner;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.DataType;
@@ -27,6 +30,7 @@
  * @version $Revision: $
  */
 public class RuperSet extends DataType {
+	public static final String REPOSITORY_DIR_PROPERTY = "repository.dir";
 	private final Project project;
 	private String id;
 	private final RuperFileSet fileSet = new RuperFileSet(this);
@@ -37,7 +41,6 @@
 	public RuperSet(Project project) {
 		super();
 		this.project = project;
-		
 	}
 	/**
 	 * @param resource
@@ -60,14 +63,38 @@
 	 */
 	public void setId(String id) {
 		this.id = id;
-		project.addReference(id+".fileset",fileSet);
+		project.addReference(id + ".fileset", fileSet);
 	}
-
 	/**
 	 * @return
 	 */
-	 FileScanner getFileScanner() {
-		// TODO Auto-generated method stub
-		return null;
+	FileScanner getFileScanner() {
+		final DirectoryScanner scanner = new DirectoryScanner();
+		scanner.setBasedir(getRepoDir());
+		return scanner;
+	}
+	/**
+	 * @return
+	 */
+	private File getRepoDir() {
+		String repoDir = project.getProperty(REPOSITORY_DIR_PROPERTY);
+		if (repoDir == null) {
+			repoDir = getAntHome() + "/tools/repo";
+		}
+		File repo = new File(repoDir);
+		if (!repo.exists()) {
+			repo.mkdirs();
+		}
+		return repo;
+	}
+	/**
+	 * @return
+	 */
+	private String getAntHome() {
+		final String property = project.getProperty("ant.home");
+		if (property == null) {
+			throw new BuildException("The property ant.home must be set");
+		}
+		return property;
 	}
 }

Mime
View raw message