You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by ni...@apache.org on 2004/05/03 05:48:09 UTC

svn commit: rev 10505 - in incubator/depot/trunk/update/src: java java/org/apache/depot/update/ant test/org/apache/depot/update/ant

Author: nickchalko
Date: Sun May  2 22:48:08 2004
New Revision: 10505

Added:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSetExportTask.java
Modified:
   incubator/depot/trunk/update/src/java/depot-update-antlib.xml
   incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedResourceSetTaskTest.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml
Log:
Added CachedResourceSetExportTask and test, which fails ofcourse.  
Test first.

Modified: incubator/depot/trunk/update/src/java/depot-update-antlib.xml
==============================================================================
--- incubator/depot/trunk/update/src/java/depot-update-antlib.xml	(original)
+++ incubator/depot/trunk/update/src/java/depot-update-antlib.xml	Sun May  2 22:48:08 2004
@@ -15,6 +15,7 @@
 -->
 <antlib>
     <typedef name="cachedset" classname="org.apache.depot.update.ant.CachedResourceSet"/>
+    <taskdef name="cachedsetexport" classname="org.apache.depot.update.ant.CachedResourceSetExportTask"/>
     
     <typedef name="resource" classname="org.apache.depot.update.ant.ResourceElement"/>
     <typedef name="repository" classname="org.apache.depot.update.ant.RepositoryElement"/>

Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSetExportTask.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSetExportTask.java	Sun May  2 22:48:08 2004
@@ -0,0 +1,69 @@
+/*
+ * ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ========================================================================
+ */
+package org.apache.depot.update.ant;
+
+import java.io.File;
+
+import org.apache.tools.ant.Task;
+/**
+ * Export a cached resource set to xml file. <code>
+ * <cachedresourceset>
+ *      <resource name="foo" 
+ *                version="1.2.3"  
+ *                href="http://mydownload.com/bar/foo-1.2.3.jar" 
+ *                local="${local.repository}/bar/jars/foo-1.2.3.jar"/>
+ * </cachedresourceset>
+ * </code>
+ */
+public class CachedResourceSetExportTask extends Task {
+	private String refid;
+	private File toFile;
+	
+	/**
+	 * The refid of the cachedset to export.
+	 * 
+	 * @return Returns the refid.
+	 */
+	public String getRefid() {
+		return refid;
+	}
+	/**
+	 * SEt the refid of the cachedset to export
+	 * 
+	 * @param refid
+	 *            The refid to set.
+	 */
+	public void setRefid(String refid) {
+		this.refid = refid;
+	}
+	/**
+	 * The file to export the Cached set to
+	 * @return Returns the toFile.
+	 */
+	public File getToFile() {
+		return toFile;
+	}
+	/**
+	 * The file to export the Cached set to
+	 * 
+	 * @param toFile The toFile to set.
+	 */
+	public void setToFile(File toFile) {
+		this.toFile = toFile;
+	}
+}
\ No newline at end of file

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedResourceSetTaskTest.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedResourceSetTaskTest.java	(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/CachedResourceSetTaskTest.java	Sun May  2 22:48:08 2004
@@ -88,4 +88,19 @@
 			System.out.println(getOutput());
 		}
 	}
+	/**
+	 * Test the exporting of cached set test1.
+	 *
+	 */
+	public void testExport1() {
+		try {
+			executeTarget("testExport1");
+			File file = new File("build/test1-export.build.xml");
+			assertTrue("Expected " + file + " to  exists", file.exists());
+		} finally {
+			System.out.println(getOutput());
+		}
+	}
+	
+	
 }

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml	(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/build.xml	Sun May  2 22:48:08 2004
@@ -20,6 +20,8 @@
 
 	<property name="depot.home" value="${basedir}/build/depot-home" />
 	<property name="local.repository" value="${depot.home}/local-repository" />
+	<property name="sandbox.dir" value="build/test/sandbox" />
+
 	<typedef resource="depot-update-antlib.xml" />
 	<repository id="maven" url="http://www.ibiblio.org/maven/" remote="true" />
 	<repository id="localtest" url="file:///${localtest.dir}" remote="true" />
@@ -34,7 +36,7 @@
 		<cachedset id="test1">
 			<resource name="helloworld" ext="jar" version="1.1" repository="localtest" />
 		</cachedset>
-		<copy toDir="build/test/sandbox">
+		<copy toDir="${sandgox.dir}">
 			<fileset refid="test1.fileset" />
 		</copy>
 	</target>
@@ -43,7 +45,7 @@
 		<cachedset id="test2">
 			<resource name="helloworld" ext="jar" version="1.2" repository="localtest" />
 		</cachedset>
-		<copy toDir="build/test/sandbox">
+		<copy toDir="${sandgox.dir}">
 			<fileset refid="test2.fileset" />
 		</copy>
 	</target>
@@ -53,7 +55,7 @@
 		<cachedset id="test3">
 			<resource name="helloworld" ext="jar" version="1.3" repository="localtest" />
 		</cachedset>
-		<copy toDir="build/test/sandbox">
+		<copy toDir="${sandgox.dir}">
 			<fileset refid="test3.fileset" />
 		</copy>
 	</target>
@@ -68,7 +70,7 @@
 		<cachedset id="test4">
 			<resource name="helloworld" ext="jar" version="1.2" repository="localtest" />
 		</cachedset>
-		<copy toDir="build/test/sandbox">
+		<copy toDir="${sandgox.dir}">
 			<fileset refid="test4.fileset" />
 		</copy>
 	</target>
@@ -84,13 +86,18 @@
 			<resource name="notfound" ext="jar" version="1.2" repository="localtest" />
 		</cachedset>
 		<!-- have to use the chaced set before it is used. -->
-		<copy toDir="build/test/sandbox">
+		<copy toDir="${sandgox.dir}">
 			<fileset refid="testNotFound.fileset" />
 		</copy>
 	</target>
 
+
+	<target name="testExport1" depends="test1">
+		<cachedsetexport refid="test1" toFile="build/test1-export.build.xml" />
+	</target>
+
 	<target name="clean-jars">
 		<delete dir="${local.repository}" />
-		<delete dir="build/test/sandbox" />
+		<delete dir="${sandgox.dir}" />
 	</target>
 </project>