Submitted by: Kare Nuorteva <kare@satama.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267551 13f79535-47bb-0310-9956-ffa450edef68master
@@ -63,13 +63,23 @@ import java.net.*; | |||||
* @author costin@dnt.ro | * @author costin@dnt.ro | ||||
*/ | */ | ||||
public class Echo extends Task { | public class Echo extends Task { | ||||
String message; // required | |||||
private String message; // required | |||||
/** | |||||
* Does the work. | |||||
* | |||||
* @exception BuildException if someting goes wrong with the build | |||||
*/ | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
System.out.println(message); | System.out.println(message); | ||||
} | } | ||||
public void setMessage(String d) { | |||||
this.message=d; | |||||
/** | |||||
* Sets the message variable. | |||||
* | |||||
* @param msg Sets the value for the message variable. | |||||
*/ | |||||
public void setMessage(String msg) { | |||||
this.message = msg; | |||||
} | } | ||||
} | } |
@@ -63,9 +63,14 @@ import java.util.zip.*; | |||||
* @author costin@dnt.ro | * @author costin@dnt.ro | ||||
*/ | */ | ||||
public class Expand extends Task { | public class Expand extends Task { | ||||
String dest; // req | |||||
String source; // req | |||||
private String dest; // req | |||||
private String source; // req | |||||
/** | |||||
* Do the work. | |||||
* | |||||
* @exception BuildException Thrown in unrecoverable error. | |||||
*/ | |||||
// XXX move it to util or tools | // XXX move it to util or tools | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
try { | try { | ||||
@@ -108,10 +113,21 @@ public class Expand extends Task { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* Set the destination directory. File will be unzipped into the | |||||
* destination directory. | |||||
* | |||||
* @param d Path to the directory. | |||||
*/ | |||||
public void setDest(String d) { | public void setDest(String d) { | ||||
this.dest=d; | this.dest=d; | ||||
} | } | ||||
/** | |||||
* Set the path to zip-file. | |||||
* | |||||
* @param s Path to zip-file. | |||||
*/ | |||||
public void setSrc(String s) { | public void setSrc(String s) { | ||||
this.source = s; | this.source = s; | ||||
} | } | ||||
@@ -63,24 +63,36 @@ import java.net.*; | |||||
* @author costin@dnt.ro | * @author costin@dnt.ro | ||||
*/ | */ | ||||
public class Get extends Task { | public class Get extends Task { | ||||
String source; // required | |||||
String dest; // required | |||||
String verbose; | |||||
private String source; // required | |||||
private String dest; // required | |||||
private String verbose = ""; | |||||
/** | |||||
* Does the work. | |||||
* | |||||
* @exception BuildException Thrown in unrecovrable error. | |||||
*/ | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
try { | try { | ||||
URL url=new URL( source ); | |||||
URL url = null; | |||||
try { | |||||
url = new URL(source); | |||||
} catch (MalformedURLException e) { | |||||
throw new BuildException(e.toString()); | |||||
} | |||||
project.log("Getting: " + source); | project.log("Getting: " + source); | ||||
File destF=new File(dest); | File destF=new File(dest); | ||||
FileOutputStream fos = new FileOutputStream(destF); | FileOutputStream fos = new FileOutputStream(destF); | ||||
InputStream is=url.openStream(); | |||||
InputStream is = url.openStream(); | |||||
byte[] buffer = new byte[100 * 1024]; | byte[] buffer = new byte[100 * 1024]; | ||||
int length; | int length; | ||||
while ((length = is.read(buffer)) >= 0) { | while ((length = is.read(buffer)) >= 0) { | ||||
fos.write(buffer, 0, length); | fos.write(buffer, 0, length); | ||||
if( "true".equals(verbose)) System.out.print("."); | |||||
if ("true".equals(verbose)) System.out.print("."); | |||||
} | } | ||||
if( "true".equals(verbose)) System.out.println(); | if( "true".equals(verbose)) System.out.println(); | ||||
fos.close(); | fos.close(); | ||||
@@ -91,15 +103,30 @@ public class Get extends Task { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* Set the URL. | |||||
* | |||||
* @param d URL for the file. | |||||
*/ | |||||
public void setSrc(String d) { | public void setSrc(String d) { | ||||
this.source=d; | this.source=d; | ||||
} | } | ||||
/** | |||||
* Where to copy the source file. | |||||
* | |||||
* @param dest Path to file. | |||||
*/ | |||||
public void setDest(String dest) { | public void setDest(String dest) { | ||||
this.dest = dest; | this.dest = dest; | ||||
} | } | ||||
/** | |||||
* Be verbose, if set to "<CODE>true</CODE>". | |||||
* | |||||
* @param v if "true" then be verbose | |||||
*/ | |||||
public void setVerbose(String v) { | public void setVerbose(String v) { | ||||
verbose=v; | |||||
verbose = v; | |||||
} | } | ||||
} | } |
@@ -63,18 +63,23 @@ import java.util.*; | |||||
* @author costin@dnt.ro | * @author costin@dnt.ro | ||||
*/ | */ | ||||
public class Property extends Task { | public class Property extends Task { | ||||
String name; | |||||
String value; | |||||
String file; | |||||
String resource; | |||||
private String name; | |||||
private String value; | |||||
private String file; | |||||
private String resource; | |||||
// needs to be set at XML-reading time, | |||||
// no runtime action | |||||
/** | |||||
* Needs to be set at XML-reading time, | |||||
* no runtime action. | |||||
* | |||||
* @exception BuildException Thrown in unrecoverable error. | |||||
*/ | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
} | } | ||||
// XXX ugly - needs to be fixed | // XXX ugly - needs to be fixed | ||||
/** Called after each setter, will set the property at read-time | |||||
/** | |||||
* Called after each setter, will set the property at read-time | |||||
*/ | */ | ||||
private void initTimeSetProperty() { | private void initTimeSetProperty() { | ||||
try { | try { | ||||
@@ -55,16 +55,15 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
import java.io.*; | |||||
import java.util.*; | |||||
/** | /** | ||||
* Define a new task - name and class | * Define a new task - name and class | ||||
* | * | ||||
* @author costin@dnt.ro | * @author costin@dnt.ro | ||||
*/ | */ | ||||
public class Taskdef extends Task { | public class Taskdef extends Task { | ||||
String name; | |||||
String value; | |||||
private String name; | |||||
private String value; | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
try { | try { | ||||
@@ -87,10 +86,10 @@ public class Taskdef extends Task { | |||||
} | } | ||||
public void setName( String name) { | public void setName( String name) { | ||||
this.name=name; | |||||
this.name = name; | |||||
} | } | ||||
public void setClass(String v) { | public void setClass(String v) { | ||||
value=v; | |||||
value = v; | |||||
} | } | ||||
} | } |