centipede2/src/java/org/krysalis/centipede2/ant ImportAntletTask.java,1.6,1.7

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/centipede2/src/java/org/krysalis/centipede2/ant
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3519/src/java/org/krysalis/centipede2/ant

Modified Files:
	ImportAntletTask.java 
Log Message:
Working on download as a zip.

Index: ImportAntletTask.java
===================================================================
RCS file: /cvsroot/metamorphosis/centipede2/src/java/org/krysalis/centipede2/ant/ImportAntletTask.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ImportAntletTask.java	22 Jan 2004 07:55:58 -0000	1.6
--- ImportAntletTask.java	5 Feb 2004 08:04:43 -0000	1.7
***************
*** 9,17 ****
--- 9,20 ----
  import java.io.File;
  import java.io.IOException;
+ import java.net.MalformedURLException;
  import java.net.URL;
  
  import org.apache.tools.ant.BuildException;
+ import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.taskdefs.Copy;
+ import org.apache.tools.ant.taskdefs.Expand;
  import org.apache.tools.ant.taskdefs.Get;
  import org.apache.tools.ant.taskdefs.ImportTask;
***************
*** 30,34 ****
  
  	private String name;
- 	private File file;
  	private URL href;
  
--- 33,36 ----
***************
*** 94,103 ****
  	private void downloadAntlet(File localAntlet) throws BuildException {
  		if (null != href) {
! 			// Transfer to download the antlet..
! 			getTask.setLocation(getLocation());
! 			getTask.setOwningTarget(getOwningTarget());
! 			getTask.setProject(getProject());
! 			getTask.setSrc(href);
! 			getTask.setDest(localAntlet);
  			getTask.setUseTimestamp(true);
  			getTask.setVerbose(true);
--- 96,132 ----
  	private void downloadAntlet(File localAntlet) throws BuildException {
  		if (null != href) {
! 			File temp = downloadAntletJar();
! 			if (temp.exists()) {
! 				unjarAntlet(temp);
! 				if (!temp.delete()) {
! 					log("Unable to delete temp file " + temp, Project.MSG_WARN);
! 				}
! 			}
! 
! 		}
! 	} /**
! 	   * @param temp
! 	   */
! 	private void unjarAntlet(File temp) { 
! 		Expand exp = new Expand();
! 		setTaskInfo(exp);
! 		exp.setSrc(temp);
! 		exp.setDest(getTargetDir());
! 		exp.execute();
! 		
! 	} 
! 	
! 	/**
! 	   *  
! 	   */
! 	private File downloadAntletJar() throws BuildException {
! 
! 		try {
! 			File temp = File.createTempFile(getName(), ".jar");
! 			URL fullURL;
! 			fullURL = new URL(href.toExternalForm() + "/" + getName() + ".jar");
! 			setTaskInfo(getTask);
! 			getTask.setSrc(fullURL);
! 			getTask.setDest(temp);
  			getTask.setUseTimestamp(true);
  			getTask.setVerbose(true);
***************
*** 105,167 ****
  			getTask.setIgnoreErrors(true);
  			getTask.execute();
! 		} else if (null != file) {
! 			// :TODO: Do we want to copy (from network share maybe)
! 			// or just use where is? Latter might be nice if
! 			// disconnected from network
! 
! 			//	Transfer to copy the antlet..
! 			copyTask.setLocation(getLocation());
! 			copyTask.setOwningTarget(getOwningTarget());
! 			copyTask.setProject(getProject());
! 			// From...
! 			copyTask.setFile(file);
! 			copyTask.setTofile(localAntlet);
! 			copyTask.setOverwrite(true);
! 			copyTask.setFailOnError(false);
! 			copyTask.execute();
  		}
! 	}
! 
  	/**
  	 * @return
  	 */
! 	private File getLocalAntletFile() throws IOException, BuildException {
! 
! 		// Where local antlets are stored...
! 		File antletDir = getAntletDir();
! 
! 		// Go looking for this one.
! 		File targetDir = new File(antletDir, getName());
! 
! 		if (targetDir.exists() && !targetDir.isDirectory())
! 			throw new BuildException(
! 				"Antlet directory ["
! 					+ targetDir.getAbsolutePath()
! 					+ "] not a workable directory.");
! 
! 		if (!targetDir.exists())
! 			targetDir.mkdirs();
! 
! 		File target = new File(targetDir, "xbuild.xml");
! 
! 		return target;
  	}
  
  	/**
! 	 * Where antlets are stored (locally)
! 	 * 
! 	 * @return
! 	 */
  	private File getAntletDir() throws IOException, BuildException {
  
  		File antletDir = null;
- 
  		String antHome = getProject().getProperty("ant.home");
! 
! 		if (null != antHome) {
! 
! 			// Dir: $ant.home
  			File antDir = new File(antHome);
- 
  			if (antDir.exists() && !antDir.isDirectory())
  				throw new BuildException(
--- 134,196 ----
  			getTask.setIgnoreErrors(true);
  			getTask.execute();
! 			return temp;
! 		} catch (MalformedURLException e) {
! 			throw new BuildException(e, getLocation());
! 		} catch (IOException e) {
! 			// TODO Auto-generated catch block
! 			throw new BuildException(e, getLocation());
  		}
! 	} /**
! 	   *  
! 	   */
! 	private void setTaskInfo(Task task) {
! 		// Transfer to download the antlet..
! 		task.setLocation(getLocation());
! 		task.setOwningTarget(getOwningTarget());
! 		task.setProject(getProject());
! 	} /**
! 	   * @return
! 	   */
! 	private File getLocalAntletFile() throws BuildException {
! 		File targetDir = getTargetDir();
! 		File target = new File(targetDir, "xbuild.xml");
! 		return target;
! 	} 
  	/**
+ 	 * ant.home/tools/antlet/antlet.name/
  	 * @return
+ 	 * @throws IOException
  	 */
! 	private File getTargetDir() throws BuildException {
! 		try {
! 			// Where local antlets are stored...
! 			File antletDir = getAntletDir();
! 			// Go looking for this one.
! 			File targetDir = new File(antletDir, getName());
! 			if (targetDir.exists() && !targetDir.isDirectory())
! 				throw new BuildException(
! 					"Antlet directory ["
! 						+ targetDir.getAbsolutePath()
! 						+ "] not a workable directory.");
! 			if (!targetDir.exists()){
! 				targetDir.mkdirs();
! 			}
! 			return targetDir;
! 		} catch (IOException e) {
! 			throw new BuildException("Error creating antlet dir for "+getName(),e,getLocation());
! 		}
  	}
  
  	/**
! 	   * Where antlets are stored (locally)
! 	   * 
! 	   * @return
! 	   */
  	private File getAntletDir() throws IOException, BuildException {
  
  		File antletDir = null;
  		String antHome = getProject().getProperty("ant.home");
! 		if (null != antHome) { // Dir: $ant.home
  			File antDir = new File(antHome);
  			if (antDir.exists() && !antDir.isDirectory())
  				throw new BuildException(
***************
*** 169,176 ****
  						+ antDir.getAbsolutePath()
  						+ "] not a workable directory.");
- 
  			// Dir: $ant.home/tools
  			File antletToolsDir = new File(antDir, "tools");
- 
  			if (antletToolsDir.exists() && !antDir.isDirectory())
  				throw new BuildException(
--- 198,203 ----
***************
*** 178,185 ****
  						+ antletToolsDir.getAbsolutePath()
  						+ "] not a workable directory.");
- 
  			// Dir: $ant.home/tools/antlet
  			antletDir = new File(antletToolsDir, "antlet");
- 
  			if (antletDir.exists() && !antletDir.isDirectory())
  				throw new BuildException(
--- 205,210 ----
***************
*** 187,281 ****
  						+ antletDir.getAbsolutePath()
  						+ "] not a workable directory.");
- 
  			// Ensure the directory exists (even if empty)
  			if (!antletDir.exists())
  				antletDir.mkdirs();
  		} else
! 			throw new BuildException("Property ${ant.home} needs to be set.");
! 
  		return antletDir;
! 	}
! 
! 	/**
! 	 * @return
! 	 */
  	public URL getHref() {
  		return href;
! 	}
! 
! 	/**
! 	 * @param href
! 	 */
  	public void setHref(URL href) {
  		this.href = href;
! 	}
! 
! 	/**
! 	 * @return
! 	 */
  	public String getName() {
  		return name;
! 	}
! 
! 	/**
! 	 * @param name
! 	 */
  	public void setName(String name) {
  		this.name = name;
  	}
  
! 	/**
! 	 * @return
! 	 */
! 	public File getFile() {
! 		return file;
! 	}
! 
! 	/**
! 	 * @param file
! 	 */
! 	public void setFile(File file) {
! 		this.file = file;
! 	}
! 
! }
! /*
!  * The Krysalis Patchy Software License, Version 1.1_01 Copyright (c) 2002
!  * Nicola Ken Barozzi. All rights reserved.
!  * 
!  * This Licence is compatible with the BSD licence as described and approved by
!  * http://www.opensource.org/, and is based on the Apache Software Licence
!  * Version 1.1.
!  * 
!  * 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 for project
!  * Krysalis (http://www.krysalis.org/)." Alternately, this acknowledgment may
!  * appear in the software itself, if and wherever such third-party
!  * acknowledgments normally appear. 4. The names "Krysalis" and "Nicola Ken
!  * Barozzi" and "Krysalis Centipede" must not be used to endorse or promote
!  * products derived from this software without prior written permission. For
!  * written permission, please contact [email protected]. 5. Products
!  * derived from this software may not be called "Krysalis", "Krysalis
!  * Centipede", nor may "Krysalis" appear in their name, without prior written
!  * permission of Nicola Ken Barozzi. 6. This software may contain voluntary
!  * contributions made by many individuals, who decided to donate the code to
!  * this project in respect of this licence.
!  * 
!  * 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
!  * KRYSALIS PROJECT 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.
!  */
--- 212,282 ----
  						+ antletDir.getAbsolutePath()
  						+ "] not a workable directory.");
  			// Ensure the directory exists (even if empty)
  			if (!antletDir.exists())
  				antletDir.mkdirs();
  		} else
! 			throw new BuildException("Property ${ant.home} must be set.");
  		return antletDir;
! 	} /**
! 	   * @return
! 	   */
  	public URL getHref() {
  		return href;
! 	} /**
! 	   * @param href
! 	   */
  	public void setHref(URL href) {
  		this.href = href;
! 	} /**
! 	   * @return
! 	   */
  	public String getName() {
  		return name;
! 	} /**
! 	   * @param name
! 	   */
  	public void setName(String name) {
  		this.name = name;
  	}
  
! } /*
!    * The Krysalis Patchy Software License, Version 1.1_01 Copyright (c) 2002
!    * Nicola Ken Barozzi. All rights reserved.
!    * 
!    * This Licence is compatible with the BSD licence as described and approved
!    * by http://www.opensource.org/, and is based on the Apache Software Licence
!    * Version 1.1.
!    * 
!    * 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 for
!    * project Krysalis (http://www.krysalis.org/)." Alternately, this
!    * acknowledgment may appear in the software itself, if and wherever such
!    * third-party acknowledgments normally appear. 4. The names "Krysalis" and
!    * "Nicola Ken Barozzi" and "Krysalis Centipede" must not be used to endorse
!    * or promote products derived from this software without prior written
!    * permission. For written permission, please contact [email protected]. 5.
!    * Products derived from this software may not be called "Krysalis",
!    * "Krysalis Centipede", nor may "Krysalis" appear in their name, without
!    * prior written permission of Nicola Ken Barozzi. 6. This software may
!    * contain voluntary contributions made by many individuals, who decided to
!    * donate the code to this project in respect of this licence.
!    * 
!    * 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 KRYSALIS PROJECT 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.
!    */



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.