Browse Source

Misc doc, scoping, style and error recovery issues

Submitted by: Kare Nuorteva <kare@satama.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267551 13f79535-47bb-0310-9956-ffa450edef68
master
Sam Ruby 25 years ago
parent
commit
282f346ca2
5 changed files with 82 additions and 25 deletions
  1. +13
    -3
      src/main/org/apache/tools/ant/taskdefs/Echo.java
  2. +18
    -2
      src/main/org/apache/tools/ant/taskdefs/Expand.java
  3. +34
    -7
      src/main/org/apache/tools/ant/taskdefs/Get.java
  4. +12
    -7
      src/main/org/apache/tools/ant/taskdefs/Property.java
  5. +5
    -6
      src/main/org/apache/tools/ant/taskdefs/Taskdef.java

+ 13
- 3
src/main/org/apache/tools/ant/taskdefs/Echo.java View File

@@ -63,13 +63,23 @@ import java.net.*;
* @author costin@dnt.ro
*/
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 {
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;
}
}

+ 18
- 2
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -63,9 +63,14 @@ import java.util.zip.*;
* @author costin@dnt.ro
*/
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
public void execute() throws BuildException {
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) {
this.dest=d;
}

/**
* Set the path to zip-file.
*
* @param s Path to zip-file.
*/
public void setSrc(String s) {
this.source = s;
}


+ 34
- 7
src/main/org/apache/tools/ant/taskdefs/Get.java View File

@@ -63,24 +63,36 @@ import java.net.*;
* @author costin@dnt.ro
*/
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 {
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);

File destF=new File(dest);
FileOutputStream fos = new FileOutputStream(destF);

InputStream is=url.openStream();
InputStream is = url.openStream();
byte[] buffer = new byte[100 * 1024];
int length;
while ((length = is.read(buffer)) >= 0) {
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();
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) {
this.source=d;
}

/**
* Where to copy the source file.
*
* @param dest Path to file.
*/
public void setDest(String dest) {
this.dest = dest;
}

/**
* Be verbose, if set to "<CODE>true</CODE>".
*
* @param v if "true" then be verbose
*/
public void setVerbose(String v) {
verbose=v;
verbose = v;
}
}

+ 12
- 7
src/main/org/apache/tools/ant/taskdefs/Property.java View File

@@ -63,18 +63,23 @@ import java.util.*;
* @author costin@dnt.ro
*/
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 {
}

// 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() {
try {


+ 5
- 6
src/main/org/apache/tools/ant/taskdefs/Taskdef.java View File

@@ -55,16 +55,15 @@
package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.*;
import java.io.*;
import java.util.*;

/**
* Define a new task - name and class
*
* @author costin@dnt.ro
*/
public class Taskdef extends Task {
String name;
String value;
private String name;
private String value;
public void execute() throws BuildException {
try {
@@ -87,10 +86,10 @@ public class Taskdef extends Task {
}

public void setName( String name) {
this.name=name;
this.name = name;
}

public void setClass(String v) {
value=v;
value = v;
}
}

Loading…
Cancel
Save