Index: src/main/org/tigris/subversion/svnant/commands/List.java
===================================================================
--- src/main/org/tigris/subversion/svnant/commands/List.java (revision 0)
+++ src/main/org/tigris/subversion/svnant/commands/List.java (revision 0)
@@ -0,0 +1,170 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.tigris.subversion.svnant.commands;
+
+import java.io.StringWriter;
+
+import org.tigris.subversion.svnant.SvnAntException;
+import org.tigris.subversion.svnant.SvnAntValidationException;
+import org.tigris.subversion.svnclientadapter.ISVNDirEntry;
+import org.tigris.subversion.svnclientadapter.SVNRevision;
+import org.tigris.subversion.svnclientadapter.SVNUrl;
+
+/**
+ * retrieve listing from a Subversion URL
+ * @author Stephen Jones
+ * pokneetail@gmail.com
+ */
+public class List extends SvnCommand {
+ /** url to list */
+ protected SVNUrl url = null;
+
+ /** revision to list */
+ protected SVNRevision revision = SVNRevision.HEAD;
+
+ /** recurse? */
+ protected boolean recurse = false;
+
+ /** print to console? */
+ protected boolean printToConsole = false;
+
+ /** name of property to set */
+ protected String property = null;
+
+ @Override
+ public void execute() throws SvnAntException {
+ try {
+ // get directory entries from URL
+ ISVNDirEntry[] entries = svnClient.getList(url, revision, recurse);
+
+ StringWriter listingWriter = new StringWriter();
+
+ // print out directory entries
+ for (int i=0; i < entries.length; i++) {
+ ISVNDirEntry entry = entries[i];
+
+ if (printToConsole)
+ logInfo(entry.getPath());
+
+ if (property != null) {
+ listingWriter.write(entry.getPath());
+ listingWriter.write(System.getProperty("line.separator"));
+ }
+ }
+
+ // set desired property
+ if (property != null) {
+ String propertyValue = listingWriter.toString();
+ getProject().setProperty(property, propertyValue);
+ }
+ } catch (Exception e) {
+ throw new SvnAntException("Can't list URL: "+url, e);
+ }
+
+ }
+
+ @Override
+ protected void validateAttributes() throws SvnAntValidationException {
+ if (url == null)
+ throw new SvnAntValidationException("url attribute must be set");
+ // require either printToConsole or property
+ if ((property == null || property.trim().equals("")) && printToConsole == false) {
+ throw new SvnAntValidationException("to direct the output, you must either set printToConsole=\"true\" or provide a property name to set");
+ }
+ if (revision == null)
+ throw SvnAntValidationException.createInvalidRevisionException();
+ }
+
+ /**
+ * Sets the url attribute (required)
+ *
+ * @param url the Subversion URL to list */
+ public void setUrl(SVNUrl url) {
+ this.url = url;
+ }
+
+ /**
+ * Sets the revision (optional, defaults to HEAD)
+ * @param revision to list
+ */
+ public void setRevision(String revision) {
+ this.revision = getRevisionFrom(revision);
+ }
+
+ /**
+ * Sets the subversion listing to recurse (optional, defaults to false)
+ * @param recurse true to recurse into subdirectories.
+ */
+ public void setRecurse(boolean recurse) {
+ this.recurse = recurse;
+ }
+
+ /**
+ * Set this to true to print the listing to the Ant console (log info)
+ * @param printToConsole
+ */
+ public void setPrintToConsole(boolean printToConsole) {
+ this.printToConsole = printToConsole;
+ }
+
+ /**
+ * Sets the property to set with the listing output
+ * @param property name
+ */
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+}
Property changes on: src/main/org/tigris/subversion/svnant/commands/List.java
___________________________________________________________________
Name: svn:executable
+ *
Index: src/main/org/tigris/subversion/svnant/SvnTask.java
===================================================================
--- src/main/org/tigris/subversion/svnant/SvnTask.java (revision 3757)
+++ src/main/org/tigris/subversion/svnant/SvnTask.java (working copy)
@@ -328,6 +328,9 @@
addCommand(a);
}
+ public void addList(org.tigris.subversion.svnant.commands.List a) {
+ addCommand(a);
+ }
private void addCommand(SvnCommand cmd)
{