Update of /cvsroot/metamorphosis/centipede2/src/java/org/krysalis/centipede2/ant
In directory sc8-pr-cvs1:/tmp/cvs-serv13930/src/java/org/krysalis/centipede2/ant
Modified Files:
antlib.xml ImportAntletTask.java
Log Message:
1) Added file attribute (to get from local/network file)
2) Added Get/Copy tasks (for implementing file and href)
Index: antlib.xml
===================================================================
RCS file: /cvsroot/metamorphosis/centipede2/src/java/org/krysalis/centipede2/ant/antlib.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** antlib.xml 31 Oct 2003 07:44:16 -0000 1.2
--- antlib.xml 4 Nov 2003 20:34:06 -0000 1.3
***************
*** 1,5 ****
<?xml version="1.0"?>
<antlib>
! <typedef name="importantlet" classname="org.krysalis.centipede2.ant.ImportAntletTask"/>
!
</antlib>
--- 1,9 ----
<?xml version="1.0"?>
<antlib>
! <typedef
! name="importantlet"
! classname="org.krysalis.centipede2.ant.ImportAntletTask"/>
! <typedef
! name="importAntlet"
! classname="org.krysalis.centipede2.ant.ImportAntletTask"/>
</antlib>
Index: ImportAntletTask.java
===================================================================
RCS file: /cvsroot/metamorphosis/centipede2/src/java/org/krysalis/centipede2/ant/ImportAntletTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ImportAntletTask.java 31 Oct 2003 08:45:42 -0000 1.3
--- ImportAntletTask.java 4 Nov 2003 20:34:06 -0000 1.4
***************
*** 8,18 ****
package org.krysalis.centipede2.ant;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.ImportTask;
/**
! * Import a antlet the easy way.
*
* @author Nick Chalko <[email protected]>
--- 8,22 ----
package org.krysalis.centipede2.ant;
import java.io.File;
+ import java.io.IOException;
+ import java.net.URL;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+ import org.apache.tools.ant.taskdefs.Copy;
+ import org.apache.tools.ant.taskdefs.Get;
import org.apache.tools.ant.taskdefs.ImportTask;
/**
! * Import an antlet the easy way.
*
* @author Nick Chalko <[email protected]>
***************
*** 22,56 ****
public class ImportAntletTask extends Task {
private final ImportTask importTask;
private String name;
! private String href;
!
! /**
! * @return
! */
! public String getHref() {
! return href;
! }
!
! /**
! * @param href
! */
! public void setHref(String href) {
! this.href = href;
! }
!
! /**
! * @return
! */
! public String getName() {
! return name;
! }
!
! /**
! * @param name
! */
! public void setName(String name) {
! this.name = name;
! }
/**
--- 26,35 ----
public class ImportAntletTask extends Task {
private final ImportTask importTask;
+ private final Get getTask;
+ private final Copy copyTask;
private String name;
! private File file;
! private URL href;
/**
***************
*** 60,64 ****
super();
importTask = new ImportTask();
!
}
--- 39,44 ----
super();
importTask = new ImportTask();
! getTask = new Get();
! copyTask = new Copy();
}
***************
*** 69,73 ****
*/
public void execute() throws BuildException {
! File antlet = getAntletFile();
importTask.setLocation(getLocation());
importTask.setOwningTarget(getOwningTarget());
--- 49,65 ----
*/
public void execute() throws BuildException {
!
! File antlet = null;
!
! try {
! antlet = getAntletFile();
! }
! catch (IOException ioe) {
! throw new BuildException(
! "Failed to get antlet [" + name + "]",
! ioe);
! }
!
! // Transfer to the included antlet..
importTask.setLocation(getLocation());
importTask.setOwningTarget(getOwningTarget());
***************
*** 75,79 ****
importTask.setFile(antlet.getAbsolutePath());
importTask.execute();
-
}
--- 67,70 ----
***************
*** 81,89 ****
* @return
*/
! private File getAntletFile() {
File localAntlet = getLocalAntletFile();
! if (localAntlet == null) {
! localAntlet = getRemoteAntlet();
! }
return localAntlet;
}
--- 72,91 ----
* @return
*/
! private File getAntletFile() throws IOException, BuildException {
!
! // Look for it locally
File localAntlet = getLocalAntletFile();
!
! // Even if found it, ensure latest
! //:TODO: save this step later..
! downloadAntlet(localAntlet);
!
! if (!localAntlet.exists())
! throw new BuildException(
! "Failed to locate (or download) antlet: ["
! + name
! + "]"
! + localAntlet.getAbsolutePath());
!
return localAntlet;
}
***************
*** 92,98 ****
* @return
*/
! private File getRemoteAntlet() {
! // TODO Auto-generated method stub
! return null;
}
--- 94,127 ----
* @return
*/
! 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);
! // Assume just temporarily offline ...
! 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();
! }
}
***************
*** 100,122 ****
* @return
*/
! private File getLocalAntletFile() {
File antletDir = getAntletDir();
File targetDir = new File(antletDir, getName());
File target = new File(targetDir, "xbuild.xml");
! return target.exists()?target:null;
}
-
/**
* @return
*/
! private File getAntletDir() {
! String dirName = getProject().getProperty("ant.home");
! File antDir = new File(dirName);
! File antletDir = new File(new File(antDir, "tools"), "antlet");
! if (!antletDir.exists()) {
! antletDir.mkdirs();
}
return antletDir;
}
--- 129,244 ----
* @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(
! "Property ${ant.home} -> ["
! + antDir.getAbsolutePath()
! + "] not a workable directory.");
!
! // Dir: $ant.home/tools
! File antletToolsDir = new File(antDir, "tools");
!
! if (antletToolsDir.exists() && !antDir.isDirectory())
! throw new BuildException(
! "Property ${ant.home}/tools -> ["
! + antletToolsDir.getAbsolutePath()
! + "] not a workable directory.");
!
! // Dir: $ant.home/tools/antlet
! antletDir = new File(antletToolsDir, "antlet");
!
! if (antletDir.exists() && !antletDir.isDirectory())
! throw new BuildException(
! "Property ${ant.home}/tools/antlet -> ["
! + 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;
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
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.