You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by aj...@apache.org on 2004/05/26 21:56:49 UTC

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

Author: ajack
Date: Wed May 26 14:56:48 2004
New Revision: 20490

Added:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/
   incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/SynchronizeTask.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/sync/
   incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/sync/SynchronizeTaskTests.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/sync/reposync.xml
Log:
try to get into SVN.


Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/SynchronizeTask.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/sync/SynchronizeTask.java	Wed May 26 14:56:48 2004
@@ -0,0 +1,123 @@
+/*
+ * 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.sync;
+
+import org.apache.depot.common.log.Logger;
+import org.apache.depot.update.ResourceUpdater;
+import org.apache.depot.update.UpdateException;
+import org.apache.depot.update.repository.DefaultRepository;
+import org.apache.depot.update.resource.ResourceGroup;
+import org.apache.depot.update.util.UpdateConstants;
+import org.apache.depot.common.ant.util.AntLogListener;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * @author ajack
+ */
+public class SynchronizeTask extends Task {
+
+	private String m_group = null;
+	private String m_ruper = UpdateConstants.DEFAULT;
+	private String m_target = UpdateConstants.LIBRARY;
+	private String m_repositories = UpdateConstants.DEFAULT;
+
+	/**
+	 * @param string
+	 */
+	public void setRepositories(String string) {
+		m_repositories = string;
+	}
+
+	/**
+	 * @param string
+	 */
+	public void setRuper(String string) {
+		m_ruper = string;
+	}
+
+	/**
+	 * @return
+	 */
+	public String getGroup() {
+		return m_group;
+	}
+
+	/**
+	 * @param string
+	 */
+	public void setGroup(String string) {
+		m_group = string;
+	}
+
+	/**
+	 * @param string
+	 */
+	public void setTarget(String string) {
+		m_target = string;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.tools.ant.Task#execute()
+	 */
+	public void execute() throws BuildException {
+
+		log("Execute Synchronize...");
+
+		// Set logging context..
+		Logger logger = Logger.pushContext(new AntLogListener(this));
+
+		try {
+			//
+			// This uses default or configured stuff..
+			//
+			if (!UpdateConstants.DEFAULT.equals(m_ruper))
+				log("Resource Updater: " + m_ruper, Project.MSG_INFO);
+
+			// Get the Resource Updater asked for
+			ResourceUpdater ruper = new ResourceUpdater(m_ruper);
+
+			if (!UpdateConstants.LIBRARY.equals(m_target))
+				log("Target Repository: " + m_target, Project.MSG_INFO);
+
+			// Assigned the target (to copy into)
+			ruper.setDefaultTargetRepository(
+				DefaultRepository.getRepository(m_target, true));
+
+			if (null != m_group) {
+
+				log("Update Group: " + m_group, Project.MSG_INFO);
+				ResourceGroup group = new ResourceGroup(m_group);
+				
+				// Update...
+				ruper.updateResourceGroup(group);
+				
+				// Cleanup (to remove duplicates)
+				ruper.clean(group);
+			}
+			else
+				throw new BuildException("Missing mandatory attribute 'group' required.");
+		}
+		catch (UpdateException re) {
+			throw new BuildException("Failed to <reposync " + m_group, re);
+		}
+		finally {
+			Logger.popContext(logger);
+		}
+	}
+}

Added: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/sync/SynchronizeTaskTests.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/sync/SynchronizeTaskTests.java	Wed May 26 14:56:48 2004
@@ -0,0 +1,63 @@
+/*
+ * 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.sync;
+
+import junit.framework.Assert;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileTest;
+
+/**
+ * 
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.2 $
+ */
+public class SynchronizeTaskTests extends BuildFileTest {
+
+	/**
+	 * Constructor for RuperDependTaskTest.
+	 * @param arg0
+	 */
+	public SynchronizeTaskTests(String arg0) {
+		super(arg0);
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(SynchronizeTaskTests.class);
+	}
+
+	public void setUp() {
+		configureProject("src/test/org/apache/depot/update/ant/sync/reposync.xml");
+	}
+
+	public void test1() {
+		executeTarget("test1");
+	}
+
+	public void test3() {
+		boolean passed = false;
+		try {
+			executeTarget("test2");
+		}
+		catch (BuildException be) {
+			passed = true;
+		}
+
+		if (!passed)
+			Assert.fail("Should've complained about no arguments...");
+	}
+}

Added: incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/sync/reposync.xml
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/ant/sync/reposync.xml	Wed May 26 14:56:48 2004
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<project name="ruper-synchronize-test" basedir="." default="all">
+	<taskdef resource="depot-update-antlib.xml"/>	
+		
+	<target name="test1">
+		<reposync group="test" />
+	</target>
+		
+	<target name="test2">
+		<!-- Intended to fail w/ "no args" message -->
+		<reposync />
+	</target>
+	
+	<target name="all" depends="test1,test2" />
+</project>