git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268233 13f79535-47bb-0310-9956-ffa450edef68master
@@ -54,10 +54,9 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | |||||
import java.io.*; | import java.io.*; | ||||
import java.util.*; | import java.util.*; | ||||
import org.apache.tools.ant.*; | |||||
/** | /** | ||||
* Copies a directory. | * Copies a directory. | ||||
@@ -84,16 +83,16 @@ public class Copydir extends MatchingTask { | |||||
destDir = dest; | destDir = dest; | ||||
} | } | ||||
public void setFiltering(String filter) { | |||||
filtering = Project.toBoolean(filter); | |||||
public void setFiltering(boolean filter) { | |||||
filtering = filter; | |||||
} | } | ||||
public void setFlatten(boolean flatten) { | public void setFlatten(boolean flatten) { | ||||
this.flatten = flatten; | this.flatten = flatten; | ||||
} | } | ||||
public void setForceoverwrite(String force) { | |||||
forceOverwrite = Project.toBoolean(force); | |||||
public void setForceoverwrite(boolean force) { | |||||
forceOverwrite = force; | |||||
} | } | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
@@ -54,10 +54,9 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | |||||
import java.io.*; | import java.io.*; | ||||
import java.util.*; | import java.util.*; | ||||
import org.apache.tools.ant.*; | |||||
/** | /** | ||||
* Copies a file. | * Copies a file. | ||||
@@ -78,8 +77,8 @@ public class Copyfile extends Task { | |||||
srcFile = src; | srcFile = src; | ||||
} | } | ||||
public void setForceoverwrite(String force) { | |||||
forceOverwrite = Project.toBoolean(force); | |||||
public void setForceoverwrite(boolean force) { | |||||
forceOverwrite = force; | |||||
} | } | ||||
public void setDest(File dest) { | public void setDest(File dest) { | ||||
@@ -182,8 +182,8 @@ public class Exec extends Task { | |||||
this.out = out; | this.out = out; | ||||
} | } | ||||
public void setFailonerror(String fail) { | |||||
failOnError = Project.toBoolean(fail); | |||||
public void setFailonerror(boolean fail) { | |||||
failOnError = fail; | |||||
} | } | ||||
protected void outputLog(String line, int messageLevel) { | protected void outputLog(String line, int messageLevel) { | ||||
@@ -53,15 +53,15 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.types.Commandline; | |||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Vector; | import java.util.Vector; | ||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.types.Commandline; | |||||
/** | /** | ||||
* Generates a key. | * Generates a key. | ||||
* | * | ||||
* @author Peter Donald <a href="mailto:donaldp@mad.scientist.com">donaldp@mad.scientist.com</a> | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | */ | ||||
public class GenerateKey extends Task { | public class GenerateKey extends Task { | ||||
@@ -104,46 +104,46 @@ public class GenerateKey extends Task { | |||||
} | } | ||||
public String toString() { | public String toString() { | ||||
final int size = params.size(); | |||||
final StringBuffer sb = new StringBuffer(); | |||||
boolean firstPass = true; | |||||
for( int i = 0; i < size; i++ ) { | |||||
if( !firstPass ) { | |||||
sb.append(" ,"); | |||||
} | |||||
firstPass = false; | |||||
final DnameParam param = (DnameParam)params.elementAt( i ); | |||||
sb.append( encode( param.getName() ) ); | |||||
sb.append( '=' ); | |||||
sb.append( encode( param.getValue() ) ); | |||||
} | |||||
return sb.toString(); | |||||
final int size = params.size(); | |||||
final StringBuffer sb = new StringBuffer(); | |||||
boolean firstPass = true; | |||||
for( int i = 0; i < size; i++ ) { | |||||
if( !firstPass ) { | |||||
sb.append(" ,"); | |||||
} | |||||
firstPass = false; | |||||
final DnameParam param = (DnameParam)params.elementAt( i ); | |||||
sb.append( encode( param.getName() ) ); | |||||
sb.append( '=' ); | |||||
sb.append( encode( param.getValue() ) ); | |||||
} | |||||
return sb.toString(); | |||||
} | } | ||||
public String encode( final String string ) { | |||||
int end = string.indexOf(','); | |||||
if( -1 == end ) return string; | |||||
final StringBuffer sb = new StringBuffer(); | |||||
int start = 0; | |||||
while( -1 != end ) | |||||
{ | |||||
sb.append( string.substring( start, end ) ); | |||||
sb.append( "\\," ); | |||||
start = end + 1; | |||||
end = string.indexOf( ',', start ); | |||||
} | |||||
sb.append( string.substring( start ) ); | |||||
return sb.toString(); | |||||
} | |||||
public String encode( final String string ) { | |||||
int end = string.indexOf(','); | |||||
if( -1 == end ) return string; | |||||
final StringBuffer sb = new StringBuffer(); | |||||
int start = 0; | |||||
while( -1 != end ) | |||||
{ | |||||
sb.append( string.substring( start, end ) ); | |||||
sb.append( "\\," ); | |||||
start = end + 1; | |||||
end = string.indexOf( ',', start ); | |||||
} | |||||
sb.append( string.substring( start ) ); | |||||
return sb.toString(); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -168,20 +168,22 @@ public class GenerateKey extends Task { | |||||
protected boolean verbose; | protected boolean verbose; | ||||
public DistinguishedName createDname() throws BuildException { | public DistinguishedName createDname() throws BuildException { | ||||
if( null != expandedDname ) { | |||||
throw new BuildException("DName sub-element can only be specified once."); | |||||
} | |||||
if( null != dname ) { | |||||
throw new BuildException("It is not possible to specify dname both as attribute and element."); | |||||
} | |||||
expandedDname = new DistinguishedName(); | |||||
return expandedDname; | |||||
if( null != expandedDname ) { | |||||
throw new BuildException( "DName sub-element can only be specified once." ); | |||||
} | |||||
if( null != dname ) { | |||||
throw new BuildException( "It is not possible to specify dname both " + | |||||
"as attribute and element." ); | |||||
} | |||||
expandedDname = new DistinguishedName(); | |||||
return expandedDname; | |||||
} | } | ||||
public void setDname(final String dname) { | public void setDname(final String dname) { | ||||
if( null != expandedDname ) { | |||||
throw new BuildException("It is not possible to specify dname both as attribute and element."); | |||||
} | |||||
if( null != expandedDname ) { | |||||
throw new BuildException( "It is not possible to specify dname both " + | |||||
"as attribute and element." ); | |||||
} | |||||
this.dname = dname; | this.dname = dname; | ||||
} | } | ||||
@@ -214,40 +216,41 @@ public class GenerateKey extends Task { | |||||
} | } | ||||
public void setKeysize(final String keysize) throws BuildException { | public void setKeysize(final String keysize) throws BuildException { | ||||
try { this.keysize = Integer.parseInt(keysize); } | |||||
catch(final NumberFormatException nfe) | |||||
{ | |||||
throw new BuildException( "KeySize attribute should be a integer" ); | |||||
} | |||||
try { this.keysize = Integer.parseInt(keysize); } | |||||
catch(final NumberFormatException nfe) | |||||
{ | |||||
throw new BuildException( "KeySize attribute should be a integer" ); | |||||
} | |||||
} | } | ||||
public void setValidity(final String validity) throws BuildException { | public void setValidity(final String validity) throws BuildException { | ||||
try { this.validity = Integer.parseInt(validity); } | |||||
catch(final NumberFormatException nfe) | |||||
{ | |||||
throw new BuildException( "Validity attribute should be a integer" ); | |||||
} | |||||
try { this.validity = Integer.parseInt(validity); } | |||||
catch(final NumberFormatException nfe) | |||||
{ | |||||
throw new BuildException( "Validity attribute should be a integer" ); | |||||
} | |||||
} | } | ||||
public void setVerbose(final String verbose) { | |||||
this.verbose = project.toBoolean(verbose); | |||||
public void setVerbose(final boolean verbose) { | |||||
this.verbose = verbose; | |||||
} | } | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
if (project.getJavaVersion().equals(Project.JAVA_1_1)) { | if (project.getJavaVersion().equals(Project.JAVA_1_1)) { | ||||
throw new BuildException("The genkey task is only available on JDK versions 1.2 or greater"); | |||||
throw new BuildException( "The genkey task is only available on JDK" + | |||||
" versions 1.2 or greater" ); | |||||
} | } | ||||
if (null == alias) { | if (null == alias) { | ||||
throw new BuildException("alias attribute must be set"); | |||||
throw new BuildException( "alias attribute must be set" ); | |||||
} | } | ||||
if (null == storepass) { | if (null == storepass) { | ||||
throw new BuildException("storepass attribute must be set"); | |||||
throw new BuildException( "storepass attribute must be set" ); | |||||
} | } | ||||
if (null == dname && null == expandedDname) { | if (null == dname && null == expandedDname) { | ||||
throw new BuildException("dname must be set"); | |||||
throw new BuildException( "dname must be set" ); | |||||
} | } | ||||
final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
@@ -258,9 +261,9 @@ public class GenerateKey extends Task { | |||||
sb.append("-v "); | sb.append("-v "); | ||||
} | } | ||||
sb.append("-alias \""); | |||||
sb.append(alias); | |||||
sb.append("\" "); | |||||
sb.append("-alias \""); | |||||
sb.append(alias); | |||||
sb.append("\" "); | |||||
if (null != dname) { | if (null != dname) { | ||||
sb.append("-dname \""); | sb.append("-dname \""); | ||||
@@ -275,9 +278,9 @@ public class GenerateKey extends Task { | |||||
} | } | ||||
if (null != keystore) { | if (null != keystore) { | ||||
sb.append("-keystore \""); | |||||
sb.append("-keystore \""); | |||||
sb.append(keystore); | sb.append(keystore); | ||||
sb.append("\" "); | |||||
sb.append("\" "); | |||||
} | } | ||||
if (null != storepass) { | if (null != storepass) { | ||||
@@ -292,14 +295,14 @@ public class GenerateKey extends Task { | |||||
sb.append("\" "); | sb.append("\" "); | ||||
} | } | ||||
sb.append("-keypass \""); | |||||
sb.append("-keypass \""); | |||||
if (null != keypass) { | if (null != keypass) { | ||||
sb.append(keypass); | sb.append(keypass); | ||||
} | } | ||||
else { | |||||
else { | |||||
sb.append(storepass); | sb.append(storepass); | ||||
} | |||||
sb.append("\" "); | |||||
} | |||||
sb.append("\" "); | |||||
if (null != sigalg) { | if (null != sigalg) { | ||||
sb.append("-sigalg \""); | sb.append("-sigalg \""); | ||||
@@ -54,10 +54,10 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | |||||
import java.io.*; | import java.io.*; | ||||
import java.net.*; | import java.net.*; | ||||
import java.util.*; | import java.util.*; | ||||
import org.apache.tools.ant.*; | |||||
/** | /** | ||||
* Get a particular file from a URL source. | * Get a particular file from a URL source. | ||||
@@ -100,14 +100,14 @@ public class Get extends Task { | |||||
try { | try { | ||||
log("Getting: " + source); | |||||
log("Getting: " + source); | |||||
//set the timestamp to the file date. | |||||
long timestamp=0; | |||||
//set the timestamp to the file date. | |||||
long timestamp=0; | |||||
boolean hasTimestamp=false; | boolean hasTimestamp=false; | ||||
if(useTimestamp && dest.exists()) { | |||||
timestamp=dest.lastModified(); | |||||
if(useTimestamp && dest.exists()) { | |||||
timestamp=dest.lastModified(); | |||||
if (verbose) { | if (verbose) { | ||||
Date t=new Date(timestamp); | Date t=new Date(timestamp); | ||||
log("local file date : "+t.toString()); | log("local file date : "+t.toString()); | ||||
@@ -115,7 +115,7 @@ public class Get extends Task { | |||||
hasTimestamp=true; | hasTimestamp=true; | ||||
} | } | ||||
//set up the URL connection | //set up the URL connection | ||||
URLConnection connection=source.openConnection(); | URLConnection connection=source.openConnection(); | ||||
//modify the headers | //modify the headers | ||||
@@ -128,7 +128,7 @@ public class Get extends Task { | |||||
connection.connect(); | connection.connect(); | ||||
//next test for a 304 result (HTTP only) | //next test for a 304 result (HTTP only) | ||||
if(connection instanceof HttpURLConnection) { | if(connection instanceof HttpURLConnection) { | ||||
HttpURLConnection httpConnection=(HttpURLConnection)connection; | |||||
HttpURLConnection httpConnection=(HttpURLConnection)connection; | |||||
if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED) { | if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED) { | ||||
//not modified so no file download. just return instead | //not modified so no file download. just return instead | ||||
//and trace out something so the user doesn't think that the | //and trace out something so the user doesn't think that the | ||||
@@ -141,45 +141,45 @@ public class Get extends Task { | |||||
//REVISIT: at this point even non HTTP connections may support the if-modified-since | //REVISIT: at this point even non HTTP connections may support the if-modified-since | ||||
//behaviour -we just check the date of the content and skip the write if it is not | //behaviour -we just check the date of the content and skip the write if it is not | ||||
//newer. Some protocols (FTP) dont include dates, of course. | //newer. Some protocols (FTP) dont include dates, of course. | ||||
FileOutputStream fos = new FileOutputStream(dest); | |||||
FileOutputStream fos = new FileOutputStream(dest); | |||||
InputStream is=null; | |||||
for( int i=0; i< 3 ; i++ ) { | |||||
try { | |||||
is = connection.getInputStream(); | |||||
break; | |||||
} catch( IOException ex ) { | |||||
log( "Error opening connection " + ex ); | |||||
} | |||||
} | |||||
if( is==null ) { | |||||
log( "Can't get " + source + " to " + dest); | |||||
if(ignoreErrors) | |||||
InputStream is=null; | |||||
for( int i=0; i< 3 ; i++ ) { | |||||
try { | |||||
is = connection.getInputStream(); | |||||
break; | |||||
} catch( IOException ex ) { | |||||
log( "Error opening connection " + ex ); | |||||
} | |||||
} | |||||
if( is==null ) { | |||||
log( "Can't get " + source + " to " + dest); | |||||
if(ignoreErrors) | |||||
return; | return; | ||||
throw new BuildException( "Can't get " + source + " to " + dest, | |||||
throw new BuildException( "Can't get " + source + " to " + dest, | |||||
location); | location); | ||||
} | |||||
byte[] buffer = new byte[100 * 1024]; | |||||
int length; | |||||
while ((length = is.read(buffer)) >= 0) { | |||||
fos.write(buffer, 0, length); | |||||
if (verbose) System.out.print("."); | |||||
} | |||||
if(verbose) System.out.println(); | |||||
fos.close(); | |||||
is.close(); | |||||
} | |||||
byte[] buffer = new byte[100 * 1024]; | |||||
int length; | |||||
while ((length = is.read(buffer)) >= 0) { | |||||
fos.write(buffer, 0, length); | |||||
if (verbose) System.out.print("."); | |||||
} | |||||
if(verbose) System.out.println(); | |||||
fos.close(); | |||||
is.close(); | |||||
//if (and only if) the use file time option is set, then the | //if (and only if) the use file time option is set, then the | ||||
//saved file now has its timestamp set to that of the downloaded file | //saved file now has its timestamp set to that of the downloaded file | ||||
if(useTimestamp) { | if(useTimestamp) { | ||||
long remoteTimestamp=connection.getLastModified(); | |||||
long remoteTimestamp=connection.getLastModified(); | |||||
if (verbose) { | if (verbose) { | ||||
Date t=new Date(remoteTimestamp); | Date t=new Date(remoteTimestamp); | ||||
log("last modified = "+t.toString() | log("last modified = "+t.toString() | ||||
+((remoteTimestamp==0)?" - using current time instead":"")); | |||||
+((remoteTimestamp==0)?" - using current time instead":"")); | |||||
} | } | ||||
if(remoteTimestamp!=0) | if(remoteTimestamp!=0) | ||||
touchFile(dest,remoteTimestamp); | touchFile(dest,remoteTimestamp); | ||||
@@ -187,12 +187,12 @@ public class Get extends Task { | |||||
} catch (IOException ioe) { | |||||
log("Error getting " + source + " to " + dest ); | |||||
if(ignoreErrors) | |||||
} catch (IOException ioe) { | |||||
log("Error getting " + source + " to " + dest ); | |||||
if(ignoreErrors) | |||||
return; | return; | ||||
throw new BuildException(ioe, location); | |||||
} | |||||
throw new BuildException(ioe, location); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -221,7 +221,7 @@ public class Get extends Task { | |||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
} | |||||
} | |||||
/** | /** | ||||
* Set the URL. | * Set the URL. | ||||
@@ -229,7 +229,7 @@ public class Get extends Task { | |||||
* @param u URL for the file. | * @param u URL for the file. | ||||
*/ | */ | ||||
public void setSrc(URL u) { | public void setSrc(URL u) { | ||||
this.source = u; | |||||
this.source = u; | |||||
} | } | ||||
/** | /** | ||||
@@ -238,7 +238,7 @@ public class Get extends Task { | |||||
* @param dest Path to file. | * @param dest Path to file. | ||||
*/ | */ | ||||
public void setDest(File dest) { | public void setDest(File dest) { | ||||
this.dest = dest; | |||||
this.dest = dest; | |||||
} | } | ||||
/** | /** | ||||
@@ -247,7 +247,7 @@ public class Get extends Task { | |||||
* @param v if "true" then be verbose | * @param v if "true" then be verbose | ||||
*/ | */ | ||||
public void setVerbose(boolean v) { | public void setVerbose(boolean v) { | ||||
verbose = v; | |||||
verbose = v; | |||||
} | } | ||||
/** | /** | ||||
@@ -256,7 +256,7 @@ public class Get extends Task { | |||||
* @param v if "true" then don't report download errors up to ant | * @param v if "true" then don't report download errors up to ant | ||||
*/ | */ | ||||
public void setIgnoreErrors(boolean v) { | public void setIgnoreErrors(boolean v) { | ||||
ignoreErrors = v; | |||||
ignoreErrors = v; | |||||
} | } | ||||
/** | /** | ||||
@@ -110,7 +110,7 @@ public class Replace extends MatchingTask { | |||||
} | } | ||||
if (dir != null) { | if (dir != null) { | ||||
DirectoryScanner ds = super.getDirectoryScanner(dir); | |||||
DirectoryScanner ds = super.getDirectoryScanner(dir); | |||||
String[] srcs = ds.getIncludedFiles(); | String[] srcs = ds.getIncludedFiles(); | ||||
for(int i=0; i<srcs.length; i++) { | for(int i=0; i<srcs.length; i++) { | ||||
@@ -53,9 +53,9 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.io.File; | |||||
import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
import java.io.File; | |||||
/** | /** | ||||
* Sign a archive. | * Sign a archive. | ||||
@@ -119,16 +119,16 @@ public class SignJar extends Task { | |||||
this.signedjar = signedjar; | this.signedjar = signedjar; | ||||
} | } | ||||
public void setVerbose(final String verbose) { | |||||
this.verbose = project.toBoolean(verbose); | |||||
public void setVerbose(final boolean verbose) { | |||||
this.verbose = verbose; | |||||
} | } | ||||
public void setInternalsf(final String internalsf) { | |||||
this.internalsf = project.toBoolean(internalsf); | |||||
public void setInternalsf(final boolean internalsf) { | |||||
this.internalsf = internalsf; | |||||
} | } | ||||
public void setSectionsonly(final String sectionsonly) { | |||||
this.sectionsonly = project.toBoolean(sectionsonly); | |||||
public void setSectionsonly(final boolean sectionsonly) { | |||||
this.sectionsonly = sectionsonly; | |||||
} | } | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
@@ -54,14 +54,12 @@ | |||||
package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.taskdefs.*; | |||||
import netrexx.lang.Rexx; | |||||
import java.io.*; | import java.io.*; | ||||
import java.lang.reflect.*; | import java.lang.reflect.*; | ||||
import java.util.*; | import java.util.*; | ||||
import netrexx.lang.Rexx; | |||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.taskdefs.*; | |||||
/** | /** | ||||
* Task to compile NetRexx source files. This task can take the following | * Task to compile NetRexx source files. This task can take the following | ||||
@@ -154,8 +152,8 @@ public class NetRexxC extends MatchingTask { | |||||
/** | /** | ||||
* Set whether literals are treated as binary, rather than NetRexx types | * Set whether literals are treated as binary, rather than NetRexx types | ||||
*/ | */ | ||||
public void setBinary(String binary) { | |||||
this.binary = Project.toBoolean(binary); | |||||
public void setBinary(boolean binary) { | |||||
this.binary = binary; | |||||
} | } | ||||
/** | /** | ||||
@@ -170,17 +168,17 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false | * The default value is false | ||||
*/ | */ | ||||
public void setComments(String comments) { | |||||
this.comments = Project.toBoolean(comments); | |||||
public void setComments(boolean comments) { | |||||
this.comments = comments; | |||||
} | } | ||||
/** | |||||
/** | |||||
* Set whether error messages come out in compact or verbose format. | * Set whether error messages come out in compact or verbose format. | ||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false | * The default value is false | ||||
*/ | */ | ||||
public void setCompact(String compact) { | |||||
this.compact = Project.toBoolean(compact); | |||||
public void setCompact(boolean compact) { | |||||
this.compact = compact; | |||||
} | } | ||||
/** | /** | ||||
@@ -189,8 +187,8 @@ public class NetRexxC extends MatchingTask { | |||||
* The default value is true. | * The default value is true. | ||||
* Setting this flag to false, will automatically set the keep flag to true. | * Setting this flag to false, will automatically set the keep flag to true. | ||||
*/ | */ | ||||
public void setCompile(String compile) { | |||||
this.compile = Project.toBoolean(compile); | |||||
public void setCompile(boolean compile) { | |||||
this.compile = compile; | |||||
if (!this.compile && !this.keep) this.keep = true; | if (!this.compile && !this.keep) this.keep = true; | ||||
} | } | ||||
@@ -199,15 +197,15 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is true. | * The default value is true. | ||||
*/ | */ | ||||
public void setConsole(String console) { | |||||
this.console = Project.toBoolean(console); | |||||
public void setConsole(boolean console) { | |||||
this.console = console; | |||||
} | } | ||||
/** | /** | ||||
* Whether variable cross references are generated | * Whether variable cross references are generated | ||||
*/ | */ | ||||
public void setCrossref(String crossref) { | |||||
this.crossref = Project.toBoolean(crossref); | |||||
public void setCrossref(boolean crossref) { | |||||
this.crossref = crossref; | |||||
} | } | ||||
/** | /** | ||||
@@ -216,8 +214,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is true. | * The default value is true. | ||||
*/ | */ | ||||
public void setDecimal(String decimal) { | |||||
this.decimal = Project.toBoolean(decimal); | |||||
public void setDecimal(boolean decimal) { | |||||
this.decimal = decimal; | |||||
} | } | ||||
/** | /** | ||||
@@ -231,8 +229,8 @@ public class NetRexxC extends MatchingTask { | |||||
/** | /** | ||||
* Whether diagnostic information about the compile is generated | * Whether diagnostic information about the compile is generated | ||||
*/ | */ | ||||
public void setDiag(String diag) { | |||||
this.diag = Project.toBoolean(diag); | |||||
public void setDiag(boolean diag) { | |||||
this.diag = diag; | |||||
} | } | ||||
/** | /** | ||||
@@ -240,16 +238,16 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setExplicit(String explicit) { | |||||
this.explicit = Project.toBoolean(explicit); | |||||
public void setExplicit(boolean explicit) { | |||||
this.explicit = explicit; | |||||
} | } | ||||
/** | /** | ||||
* Whether the generated java code is formatted nicely or left to match NetRexx | * Whether the generated java code is formatted nicely or left to match NetRexx | ||||
* line numbers for call stack debugging | * line numbers for call stack debugging | ||||
*/ | */ | ||||
public void setFormat(String format) { | |||||
this.format = Project.toBoolean(format); | |||||
public void setFormat(boolean format) { | |||||
this.format = format; | |||||
} | } | ||||
/** | /** | ||||
@@ -257,8 +255,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setJava(String java) { | |||||
this.java = Project.toBoolean(java); | |||||
public void setJava(boolean java) { | |||||
this.java = java; | |||||
} | } | ||||
@@ -268,24 +266,24 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setKeep(String keep) { | |||||
this.keep = Project.toBoolean(keep); | |||||
public void setKeep(boolean keep) { | |||||
this.keep = keep; | |||||
} | } | ||||
/** | /** | ||||
* Whether the compiler text logo is displayed when compiling | * Whether the compiler text logo is displayed when compiling | ||||
*/ | */ | ||||
public void setLogo(String logo) { | |||||
this.logo = Project.toBoolean(logo); | |||||
public void setLogo(boolean logo) { | |||||
this.logo = logo; | |||||
} | } | ||||
/** | |||||
/** | |||||
* Whether the generated .java file should be replaced when compiling | * Whether the generated .java file should be replaced when compiling | ||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setReplace(String replace) { | |||||
this.replace = Project.toBoolean(replace); | |||||
public void setReplace(boolean replace) { | |||||
this.replace = replace; | |||||
} | } | ||||
/** | /** | ||||
@@ -294,8 +292,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setSavelog(String savelog) { | |||||
this.savelog = Project.toBoolean(savelog); | |||||
public void setSavelog(boolean savelog) { | |||||
this.savelog = savelog; | |||||
} | } | ||||
/** | /** | ||||
@@ -304,8 +302,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is true. | * The default value is true. | ||||
*/ | */ | ||||
public void setSourcedir(String sourcedir) { | |||||
this.sourcedir = Project.toBoolean(sourcedir); | |||||
public void setSourcedir(boolean sourcedir) { | |||||
this.sourcedir = sourcedir; | |||||
} | } | ||||
/** | /** | ||||
@@ -322,22 +320,22 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setStrictargs(String strictargs) { | |||||
this.strictargs = Project.toBoolean(strictargs); | |||||
public void setStrictargs(boolean strictargs) { | |||||
this.strictargs = strictargs; | |||||
} | } | ||||
/** | /** | ||||
* Tells the NetRexx compile that assignments must match exactly on type | * Tells the NetRexx compile that assignments must match exactly on type | ||||
*/ | */ | ||||
public void setStrictassign(String strictassign) { | |||||
this.strictassign = Project.toBoolean(strictassign); | |||||
public void setStrictassign(boolean strictassign) { | |||||
this.strictassign = strictassign; | |||||
} | } | ||||
/** | /** | ||||
* Specifies whether the NetRexx compiler should be case sensitive or not | * Specifies whether the NetRexx compiler should be case sensitive or not | ||||
*/ | */ | ||||
public void setStrictcase(String strictcase) { | |||||
this.strictcase = Project.toBoolean(strictcase); | |||||
public void setStrictcase(boolean strictcase) { | |||||
this.strictcase = strictcase; | |||||
} | } | ||||
/** | /** | ||||
@@ -347,8 +345,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setStrictimport(String strictimport) { | |||||
this.strictimport = Project.toBoolean(strictimport); | |||||
public void setStrictimport(boolean strictimport) { | |||||
this.strictimport = strictimport; | |||||
} | } | ||||
/** | /** | ||||
@@ -356,16 +354,16 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setStrictprops(String strictprops) { | |||||
this.strictprops = Project.toBoolean(strictprops); | |||||
public void setStrictprops(boolean strictprops) { | |||||
this.strictprops = strictprops; | |||||
} | } | ||||
/** | /** | ||||
* Whether the compiler should force catching of exceptions by explicitly named types | * Whether the compiler should force catching of exceptions by explicitly named types | ||||
*/ | */ | ||||
public void setStrictsignal(String strictsignal) { | |||||
this.strictsignal = Project.toBoolean(strictsignal); | |||||
public void setStrictsignal(boolean strictsignal) { | |||||
this.strictsignal = strictsignal; | |||||
} | } | ||||
/** | /** | ||||
@@ -373,8 +371,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setSymbols(String symbols) { | |||||
this.symbols = Project.toBoolean(symbols); | |||||
public void setSymbols(boolean symbols) { | |||||
this.symbols = symbols; | |||||
} | } | ||||
/** | /** | ||||
@@ -382,8 +380,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setTime(String time) { | |||||
this.time = Project.toBoolean(time); | |||||
public void setTime(boolean time) { | |||||
this.time = time; | |||||
} | } | ||||
/** | /** | ||||
@@ -393,9 +391,9 @@ public class NetRexxC extends MatchingTask { | |||||
*/ | */ | ||||
public void setTrace(String trace) { | public void setTrace(String trace) { | ||||
if (trace.equalsIgnoreCase("trace") | if (trace.equalsIgnoreCase("trace") | ||||
|| trace.equalsIgnoreCase("trace1") | |||||
|| trace.equalsIgnoreCase("trace2") | |||||
|| trace.equalsIgnoreCase("notrace")) { | |||||
|| trace.equalsIgnoreCase("trace1") | |||||
|| trace.equalsIgnoreCase("trace2") | |||||
|| trace.equalsIgnoreCase("notrace")) { | |||||
this.trace = trace; | this.trace = trace; | ||||
} else { | } else { | ||||
throw new BuildException("Unknown trace value specified: '" + trace + "'"); | throw new BuildException("Unknown trace value specified: '" + trace + "'"); | ||||
@@ -407,8 +405,8 @@ public class NetRexxC extends MatchingTask { | |||||
* Valid true values are "on" or "true". Anything else sets the flag to false. | * Valid true values are "on" or "true". Anything else sets the flag to false. | ||||
* The default value is false. | * The default value is false. | ||||
*/ | */ | ||||
public void setUtf8(String utf8) { | |||||
this.utf8 = Project.toBoolean(utf8); | |||||
public void setUtf8(boolean utf8) { | |||||
this.utf8 = utf8; | |||||
} | } | ||||
/** | /** | ||||
@@ -463,7 +461,10 @@ public class NetRexxC extends MatchingTask { | |||||
// if it's a source file, see if the destination class file | // if it's a source file, see if the destination class file | ||||
// needs to be recreated via compilation | // needs to be recreated via compilation | ||||
if (filename.toLowerCase().endsWith(".nrx")) { | if (filename.toLowerCase().endsWith(".nrx")) { | ||||
File classFile = new File(destDir, filename.substring(0, filename.lastIndexOf('.')) + ".class"); | |||||
File classFile = | |||||
new File(destDir, | |||||
filename.substring(0, filename.lastIndexOf('.')) + ".class"); | |||||
if (!compile || srcFile.lastModified() > classFile.lastModified()) { | if (!compile || srcFile.lastModified() > classFile.lastModified()) { | ||||
filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); | filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); | ||||
compileList.addElement(destFile.getAbsolutePath()); | compileList.addElement(destFile.getAbsolutePath()); | ||||
@@ -492,7 +493,7 @@ public class NetRexxC extends MatchingTask { | |||||
project.copyFile(fromFile, toFile); | project.copyFile(fromFile, toFile); | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
String msg = "Failed to copy " + fromFile + " to " + toFile | String msg = "Failed to copy " + fromFile + " to " + toFile | ||||
+ " due to " + ioe.getMessage(); | |||||
+ " due to " + ioe.getMessage(); | |||||
throw new BuildException(msg, ioe); | throw new BuildException(msg, ioe); | ||||
} | } | ||||
} | } | ||||
@@ -554,8 +555,8 @@ public class NetRexxC extends MatchingTask { | |||||
try { | try { | ||||
StringWriter out = new StringWriter(); | StringWriter out = new StringWriter(); | ||||
int rc = COM.ibm.netrexx.process.NetRexxC.main( | |||||
new Rexx(compileArgs), new PrintWriter(out)); | |||||
int rc = COM.ibm.netrexx.process.NetRexxC. | |||||
main(new Rexx(compileArgs), new PrintWriter(out)); | |||||
if (rc > 1) { // 1 is warnings from real NetRexxC | if (rc > 1) { // 1 is warnings from real NetRexxC | ||||
log(out.toString(), Project.MSG_ERR); | log(out.toString(), Project.MSG_ERR); | ||||
@@ -644,7 +645,7 @@ public class NetRexxC extends MatchingTask { | |||||
*/ | */ | ||||
private void addExistingToClasspath(StringBuffer target,String source) { | private void addExistingToClasspath(StringBuffer target,String source) { | ||||
StringTokenizer tok = new StringTokenizer(source, | StringTokenizer tok = new StringTokenizer(source, | ||||
System.getProperty("path.separator"), false); | |||||
System.getProperty("path.separator"), false); | |||||
while (tok.hasMoreTokens()) { | while (tok.hasMoreTokens()) { | ||||
File f = project.resolveFile(tok.nextToken()); | File f = project.resolveFile(tok.nextToken()); | ||||
@@ -653,7 +654,7 @@ public class NetRexxC extends MatchingTask { | |||||
target.append(f.getAbsolutePath()); | target.append(f.getAbsolutePath()); | ||||
} else { | } else { | ||||
log("Dropping from classpath: "+ | log("Dropping from classpath: "+ | ||||
f.getAbsolutePath(), Project.MSG_VERBOSE); | |||||
f.getAbsolutePath(), Project.MSG_VERBOSE); | |||||
} | } | ||||
} | } | ||||
@@ -101,8 +101,8 @@ public class RenameExtensions extends MatchingTask { | |||||
* store replace attribute - this determines whether the target file | * store replace attribute - this determines whether the target file | ||||
* should be overwritten if present | * should be overwritten if present | ||||
*/ | */ | ||||
public void setReplace(String replaceString) { | |||||
replace = Project.toBoolean(replaceString); | |||||
public void setReplace(boolean replace) { | |||||
this.replace = replace; | |||||
} | } | ||||
/** | /** | ||||
@@ -119,7 +119,8 @@ public class RenameExtensions extends MatchingTask { | |||||
// first off, make sure that we've got a from and to extension | // first off, make sure that we've got a from and to extension | ||||
if (fromExtension == null || toExtension == null || srcDir == null) { | if (fromExtension == null || toExtension == null || srcDir == null) { | ||||
throw new BuildException("srcDir, fromExtension and toExtension attributes must be set!"); | |||||
throw new BuildException( "srcDir, fromExtension and toExtension " + | |||||
"attributes must be set!" ); | |||||
} | } | ||||
// scan source and dest dirs to build up rename list | // scan source and dest dirs to build up rename list | ||||
@@ -136,7 +137,10 @@ public class RenameExtensions extends MatchingTask { | |||||
fromFile = (File)e.nextElement(); | fromFile = (File)e.nextElement(); | ||||
toFile = (File)renameList.get(fromFile); | toFile = (File)renameList.get(fromFile); | ||||
if (toFile.exists() && replace) toFile.delete(); | if (toFile.exists() && replace) toFile.delete(); | ||||
if (!fromFile.renameTo(toFile)) throw new BuildException("Rename from: '" + fromFile + "' to '" + toFile + "' failed."); | |||||
if (!fromFile.renameTo(toFile)) { | |||||
throw new BuildException( "Rename from: '" + fromFile + "' to '" + | |||||
toFile + "' failed." ); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -147,17 +151,22 @@ public class RenameExtensions extends MatchingTask { | |||||
String filename = files[i]; | String filename = files[i]; | ||||
// if it's a file that ends in the fromExtension, copy to the rename list | // if it's a file that ends in the fromExtension, copy to the rename list | ||||
if (filename.toLowerCase().endsWith(fromExtension)) { | if (filename.toLowerCase().endsWith(fromExtension)) { | ||||
File destFile = new File(srcDir, filename.substring(0, filename.lastIndexOf(fromExtension)) + toExtension); | |||||
File destFile = | |||||
new File( srcDir, | |||||
filename.substring(0, filename.lastIndexOf(fromExtension)) + | |||||
toExtension ); | |||||
if (replace || !destFile.exists()) { | if (replace || !destFile.exists()) { | ||||
list.put(srcFile, destFile); | list.put(srcFile, destFile); | ||||
} else { | } else { | ||||
log("Rejecting file: '" + srcFile + "' for rename as replace is false and file exists", Project.MSG_VERBOSE); | |||||
log( "Rejecting file: '" + srcFile + "' for rename as " + | |||||
"replace is false and file exists", Project.MSG_VERBOSE ); | |||||
} | } | ||||
} else { | } else { | ||||
log("File '"+ filename + "' doesn't match fromExtension: '" + fromExtension + "'", Project.MSG_VERBOSE); | |||||
log( "File '"+ filename + "' doesn't match fromExtension: '" + | |||||
fromExtension + "'", Project.MSG_VERBOSE ); | |||||
} | } | ||||
} | } | ||||
return list; | return list; | ||||
} | } | ||||
} | } |