Browse Source

style

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274850 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
ae3bd3ae51
43 changed files with 416 additions and 413 deletions
  1. +5
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  2. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  3. +26
    -26
      src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
  4. +27
    -18
      src/main/org/apache/tools/ant/taskdefs/optional/IContract.java
  5. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  6. +23
    -23
      src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
  7. +35
    -38
      src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  8. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java
  9. +14
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
  10. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
  11. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/Script.java
  12. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/StyleBook.java
  13. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/Test.java
  14. +10
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
  15. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java
  16. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java
  17. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/InnerClassFilenameFilter.java
  18. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
  19. +12
    -12
      src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
  20. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java
  21. +10
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
  22. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
  23. +16
    -16
      src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
  24. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java
  25. +9
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  26. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
  27. +14
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java
  28. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  29. +15
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java
  30. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  31. +12
    -12
      src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  32. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java
  33. +16
    -16
      src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java
  34. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAuditParser.java
  35. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAuditStreamHandler.java
  36. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/metamata/MMetricsStreamHandler.java
  37. +21
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java
  38. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
  39. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java
  40. +10
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java
  41. +29
    -29
      src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
  42. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
  43. +7
    -9
      src/main/org/apache/tools/ant/types/optional/ScriptFilter.java

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

@@ -156,10 +156,8 @@ public class ANTLR extends Task {
public void setGlib(String superGrammar) { public void setGlib(String superGrammar) {
String sg = null; String sg = null;
if (Os.isFamily("dos")) { if (Os.isFamily("dos")) {
sg = superGrammar.replace('\\','/');
}
else
{
sg = superGrammar.replace('\\', '/');
} else {
sg = superGrammar; sg = superGrammar;
} }
setGlib(fileUtils.resolveFile(getProject().getBaseDir(), sg)); setGlib(fileUtils.resolveFile(getProject().getBaseDir(), sg));
@@ -304,8 +302,8 @@ public class ANTLR extends Task {
File generatedFile = getGeneratedFile(); File generatedFile = getGeneratedFile();
boolean targetIsOutOfDate = boolean targetIsOutOfDate =
target.lastModified() > generatedFile.lastModified(); target.lastModified() > generatedFile.lastModified();
boolean superGrammarIsOutOfDate = superGrammar != null &&
(superGrammar.lastModified() > generatedFile.lastModified());
boolean superGrammarIsOutOfDate = superGrammar != null
&& (superGrammar.lastModified() > generatedFile.lastModified());
if (targetIsOutOfDate || superGrammarIsOutOfDate) { if (targetIsOutOfDate || superGrammarIsOutOfDate) {
if (targetIsOutOfDate) { if (targetIsOutOfDate) {
log("Compiling " + target + " as it is newer than " log("Compiling " + target + " as it is newer than "
@@ -431,6 +429,7 @@ public class ANTLR extends Task {
try { try {
bos.close(); bos.close();
} catch (IOException e) { } catch (IOException e) {
// ignore
} }
} }
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/Cab.java View File

@@ -144,7 +144,7 @@ public class Cab extends MatchingTask {
protected void checkConfiguration() throws BuildException { protected void checkConfiguration() throws BuildException {
if (baseDir == null && filesets.size() == 0) { if (baseDir == null && filesets.size() == 0) {
throw new BuildException("basedir attribute or at least one " throw new BuildException("basedir attribute or at least one "
+ "nested filest is required!",
+ "nested filest is required!",
getLocation()); getLocation());
} }
if (baseDir != null && !baseDir.exists()) { if (baseDir != null && !baseDir.exists()) {
@@ -266,7 +266,7 @@ public class Cab extends MatchingTask {
try { try {
Process p = Execute.launch(getProject(), Process p = Execute.launch(getProject(),
new String[] {"listcab"}, null, new String[] {"listcab"}, null,
baseDir != null ? baseDir
baseDir != null ? baseDir
: getProject().getBaseDir(), : getProject().getBaseDir(),
true); true);
OutputStream out = p.getOutputStream(); OutputStream out = p.getOutputStream();


+ 26
- 26
src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java View File

@@ -164,7 +164,7 @@ public class EchoProperties extends Task {
* *
* @param file the input file * @param file the input file
*/ */
public void setSrcfile( File file ) {
public void setSrcfile(File file) {
inFile = file; inFile = file;
} }


@@ -260,16 +260,16 @@ public class EchoProperties extends Task {
if (inFile.exists() && !inFile.canRead()) { if (inFile.exists() && !inFile.canRead()) {
String message = "Can not read from the specified srcfile!"; String message = "Can not read from the specified srcfile!";
if (failonerror) { if (failonerror) {
throw new BuildException( message, getLocation() );
throw new BuildException(message, getLocation());
} else { } else {
log( message, Project.MSG_ERR );
log(message, Project.MSG_ERR);
} }
return; return;
} }


FileInputStream in = null; FileInputStream in = null;
try { try {
in = new FileInputStream( inFile );
in = new FileInputStream(inFile);
Properties props = new Properties(); Properties props = new Properties();
props.load(in); props.load(in);
CollectionUtils.putAll(allProps, props); CollectionUtils.putAll(allProps, props);
@@ -279,21 +279,21 @@ public class EchoProperties extends Task {
if (failonerror) { if (failonerror) {
throw new BuildException(message, fnfe, getLocation()); throw new BuildException(message, fnfe, getLocation());
} else { } else {
log( message, Project.MSG_WARN );
log(message, Project.MSG_WARN);
} }
return; return;
} catch( IOException ioe ) {
} catch(IOException ioe) {
String message = String message =
"Could not read file " + inFile.getAbsolutePath(); "Could not read file " + inFile.getAbsolutePath();
if (failonerror) { if (failonerror) {
throw new BuildException(message, ioe, getLocation()); throw new BuildException(message, ioe, getLocation());
} else { } else {
log( message, Project.MSG_WARN );
log(message, Project.MSG_WARN);
} }
return; return;
} finally { } finally {
try { try {
if( null != in ) {
if(null != in) {
in.close(); in.close();
} }
} catch(IOException ioe) {} } catch(IOException ioe) {}
@@ -305,7 +305,7 @@ public class EchoProperties extends Task {
PropertySet ps = (PropertySet) enum.nextElement(); PropertySet ps = (PropertySet) enum.nextElement();
CollectionUtils.putAll(allProps, ps.getProperties()); CollectionUtils.putAll(allProps, ps.getProperties());
} }
OutputStream os = null; OutputStream os = null;
try { try {
if (destfile == null) { if (destfile == null) {
@@ -376,7 +376,7 @@ public class EchoProperties extends Task {
if ("text".equals(format)) { if ("text".equals(format)) {
jdkSaveProperties(props, os, "Ant properties"); jdkSaveProperties(props, os, "Ant properties");
} else if ("xml".equals(format)) { } else if ("xml".equals(format)) {
xmlSaveProperties(props, os );
xmlSaveProperties(props, os);
} }
} }


@@ -384,29 +384,29 @@ public class EchoProperties extends Task {
OutputStream os) throws IOException { OutputStream os) throws IOException {
// create XML document // create XML document
Document doc = getDocumentBuilder().newDocument(); Document doc = getDocumentBuilder().newDocument();
Element rootElement = doc.createElement( PROPERTIES );
Element rootElement = doc.createElement(PROPERTIES);


// output properties // output properties
String name; String name;
Enumeration e = props.propertyNames(); Enumeration e = props.propertyNames();
while( e.hasMoreElements() ) {
while(e.hasMoreElements()) {
name = (String)e.nextElement(); name = (String)e.nextElement();
Element propElement = doc.createElement( PROPERTY );
propElement.setAttribute( ATTR_NAME, name );
propElement.setAttribute( ATTR_VALUE, props.getProperty( name ) );
rootElement.appendChild( propElement );
Element propElement = doc.createElement(PROPERTY);
propElement.setAttribute(ATTR_NAME, name);
propElement.setAttribute(ATTR_VALUE, props.getProperty(name));
rootElement.appendChild(propElement);
} }


Writer wri = null; Writer wri = null;
try { try {
wri = new OutputStreamWriter( os, "UTF8" );
wri.write( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
( new DOMElementWriter() ).write( rootElement, wri, 0, "\t" );
wri = new OutputStreamWriter(os, "UTF8");
wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
(new DOMElementWriter()).write(rootElement, wri, 0, "\t");
wri.flush(); wri.flush();
} catch( IOException ioe ) {
throw new BuildException( "Unable to write XML file", ioe );
} catch(IOException ioe) {
throw new BuildException("Unable to write XML file", ioe);
} finally { } finally {
if( wri != null ) {
if(wri != null) {
wri.close(); wri.close();
} }
} }
@@ -414,11 +414,11 @@ public class EchoProperties extends Task {


/** /**
* JDK 1.2 allows for the safer method * JDK 1.2 allows for the safer method
* <tt>Properties.store( OutputStream, String )</tt>, which throws an
* <tt>Properties.store(OutputStream, String)</tt>, which throws an
* <tt>IOException</tt> on an output error. This method attempts to * <tt>IOException</tt> on an output error. This method attempts to
* use the JDK 1.2 method first, and if that does not exist, then the * use the JDK 1.2 method first, and if that does not exist, then the
* JDK 1.0 compatible method * JDK 1.0 compatible method
* <tt>Properties.save( OutputStream, String )</tt> is used instead.
* <tt>Properties.save(OutputStream, String)</tt> is used instead.
* *
*@param props the properties to record *@param props the properties to record
*@param os record the properties to this output stream *@param os record the properties to this output stream
@@ -476,8 +476,8 @@ public class EchoProperties extends Task {
private static DocumentBuilder getDocumentBuilder() { private static DocumentBuilder getDocumentBuilder() {
try { try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder(); return DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch( Exception e ) {
throw new ExceptionInInitializerError( e );
} catch(Exception e) {
throw new ExceptionInInitializerError(e);
} }
} }
} }


+ 27
- 18
src/main/org/apache/tools/ant/taskdefs/optional/IContract.java View File

@@ -78,10 +78,13 @@ import org.apache.tools.ant.types.Reference;
/** /**
* Instruments Java classes with iContract DBC preprocessor. * Instruments Java classes with iContract DBC preprocessor.
* <br/> * <br/>
* The task can generate a properties file for <a href="http://hjem.sol.no/hellesoy/icontrol.html">iControl</a>,
* a graphical user interface that lets you turn on/off assertions. iControl generates a control file that you can refer to
* The task can generate a properties file for
* <a href="http://hjem.sol.no/hellesoy/icontrol.html">iControl</a>,
* a graphical user interface that lets you turn on/off assertions.
* iControl generates a control file that you can refer to
* from this task using the controlfile attribute. * from this task using the controlfile attribute.
* iContract is at <a href="http://www.reliable-systems.com/tools/">http://www.reliable-systems.com/tools/</a>
* iContract is at
* <a href="http://www.reliable-systems.com/tools/">http://www.reliable-systems.com/tools/</a>
* <p/> * <p/>
* Thanks to Rainer Schmitz for enhancements and comments. * Thanks to Rainer Schmitz for enhancements and comments.
* *
@@ -154,22 +157,25 @@ import org.apache.tools.ant.types.Reference;
* </tr> * </tr>
* <tr> * <tr>
* <td valign="top">verbosity</td> * <td valign="top">verbosity</td>
* <td valign="top">Indicates the verbosity level of iContract. Any combination
* of <code>error*,warning*,note*,info*,progress*,debug*</code> (comma separated) can be
* used. Defaults to <code>error*</code></td>
* <td valign="top">Indicates the verbosity level of iContract.
* Any combination of
* <code>error*,warning*,note*,info*,progress*,debug*</code>
* (comma separated) can be used. Defaults to <code>error*</code></td>
* <td valign="top" align="center">No</td> * <td valign="top" align="center">No</td>
* </tr> * </tr>
* <tr> * <tr>
* <td valign="top">quiet</td> * <td valign="top">quiet</td>
* <td valign="top">Indicates if iContract should be quiet. Turn it off if many your classes extend uninstrumented classes
* and you don't want warnings about this. Defaults to <code>false</code></td>
* <td valign="top">Indicates if iContract should be quiet. Turn it off
* if many your classes extend uninstrumented classes and you don't
* want warnings about this. Defaults to <code>false</code></td>
* <td valign="top" align="center">No</td> * <td valign="top" align="center">No</td>
* </tr> * </tr>
* <tr> * <tr>
* <td valign="top">updateicontrol</td> * <td valign="top">updateicontrol</td>
* <td valign="top">If set to true, it indicates that the properties file for
* iControl in the current directory should be updated (or created if it doesn't exist).
* Defaults to <code>false</code>.</td>
* <td valign="top">If set to true, it indicates that the properties
* file for iControl in the current directory should be updated
* (or created if it doesn't exist). Defaults to <code>false</code>.
* </td>
* <td valign="top" align="center">No</td> * <td valign="top" align="center">No</td>
* </tr> * </tr>
* <tr> * <tr>
@@ -614,7 +620,8 @@ public class IContract extends MatchingTask {
if (updateIcontrol) { if (updateIcontrol) {
Properties iControlProps = new Properties(); Properties iControlProps = new Properties();


try {// to read existing propertiesfile
try {
// to read existing propertiesfile
iControlProps.load(new FileInputStream("icontrol.properties")); iControlProps.load(new FileInputStream("icontrol.properties"));
} catch (IOException e) { } catch (IOException e) {
log("File icontrol.properties not found. That's ok. Writing a default one."); log("File icontrol.properties not found. That's ok. Writing a default one.");
@@ -625,7 +632,8 @@ public class IContract extends MatchingTask {
iControlProps.setProperty("controlFile", controlFile.getAbsolutePath()); iControlProps.setProperty("controlFile", controlFile.getAbsolutePath());
iControlProps.setProperty("targetsFile", targets.getAbsolutePath()); iControlProps.setProperty("targetsFile", targets.getAbsolutePath());


try {// to read existing propertiesfile
try {
// to read existing propertiesfile
iControlProps.store(new FileOutputStream("icontrol.properties"), ICONTROL_PROPERTIES_HEADER); iControlProps.store(new FileOutputStream("icontrol.properties"), ICONTROL_PROPERTIES_HEADER);
log("Updated icontrol.properties"); log("Updated icontrol.properties");
} catch (IOException e) { } catch (IOException e) {
@@ -644,7 +652,8 @@ public class IContract extends MatchingTask {
} }
throw new BuildException("iContract instrumentation failed. Code=" + result); throw new BuildException("iContract instrumentation failed. Code=" + result);
} }
} else {// not dirty
} else {
// not dirty
//log( "Nothing to do. Everything up to date." ); //log( "Nothing to do. Everything up to date." );
} }
} }
@@ -664,10 +673,10 @@ public class IContract extends MatchingTask {
if (repositoryDir == null) { if (repositoryDir == null) {
throw new BuildException("repositorydir attribute must be set!", getLocation()); throw new BuildException("repositorydir attribute must be set!", getLocation());
} }
if (updateIcontrol == true && classDir == null) {
if (updateIcontrol && classDir == null) {
throw new BuildException("classdir attribute must be specified when updateicontrol=true!", getLocation()); throw new BuildException("classdir attribute must be specified when updateicontrol=true!", getLocation());
} }
if (updateIcontrol == true && controlFile == null) {
if (updateIcontrol && controlFile == null) {
throw new BuildException("controlfile attribute must be specified when updateicontrol=true!", getLocation()); throw new BuildException("controlfile attribute must be specified when updateicontrol=true!", getLocation());
} }
} }
@@ -719,8 +728,8 @@ public class IContract extends MatchingTask {
File classFile = new File(buildDir, files[i].substring(0, files[i].indexOf(".java")) + ".class"); File classFile = new File(buildDir, files[i].substring(0, files[i].indexOf(".java")) + ".class");


if (srcFile.lastModified() > now) { if (srcFile.lastModified() > now) {
log("Warning: file modified in the future: " +
files[i], Project.MSG_WARN);
log("Warning: file modified in the future: "
+ files[i], Project.MSG_WARN);
} }


if (!classFile.exists() || srcFile.lastModified() > classFile.lastModified()) { if (!classFile.exists() || srcFile.lastModified() > classFile.lastModified()) {


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/Javah.java View File

@@ -337,8 +337,8 @@ public class Javah extends Task {
throw new BuildException("Compile failed"); throw new BuildException("Compile failed");
} }
*/ */
try { try {
Class javahMainClass = null; Class javahMainClass = null;
try { try {
@@ -348,17 +348,17 @@ public class Javah extends Task {
// assume older than 1.4.2 tools.jar // assume older than 1.4.2 tools.jar
javahMainClass = Class.forName("com.sun.tools.javah.Main"); javahMainClass = Class.forName("com.sun.tools.javah.Main");
} }
// now search for the constructor that takes in String[] arguments. // now search for the constructor that takes in String[] arguments.
Class[] strings = new Class[] {String[].class}; Class[] strings = new Class[] {String[].class};
Constructor constructor = javahMainClass.getConstructor(strings); Constructor constructor = javahMainClass.getConstructor(strings);
// construct the javah Main instance // construct the javah Main instance
Object javahMain = constructor.newInstance(new Object[] {cmd.getArguments()}); Object javahMain = constructor.newInstance(new Object[] {cmd.getArguments()});
// find the run method // find the run method
Method runMethod = javahMainClass.getMethod("run",new Class[0]); Method runMethod = javahMainClass.getMethod("run",new Class[0]);
runMethod.invoke(javahMain,new Object[0]); runMethod.invoke(javahMain,new Object[0]);
} catch (Exception ex) { } catch (Exception ex) {
if (ex instanceof BuildException) { if (ex instanceof BuildException) {
@@ -368,7 +368,7 @@ public class Javah extends Task {
} }
} }
} }
/** /**
* Does the command line argument processing common to classic and * Does the command line argument processing common to classic and
* modern. * modern.


+ 23
- 23
src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000,2002 The Apache Software Foundation. All rights
* Copyright (c) 2000,2002 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -85,11 +85,11 @@ public class Native2Ascii extends MatchingTask {
/** /**
* Flag the conversion to run in the reverse sense, * Flag the conversion to run in the reverse sense,
* that is Ascii to Native encoding. * that is Ascii to Native encoding.
*
*
* @param reverse True if the conversion is to be reversed, * @param reverse True if the conversion is to be reversed,
* otherwise false; * otherwise false;
*/ */
public void setReverse(boolean reverse){
public void setReverse(boolean reverse) {
this.reverse = reverse; this.reverse = reverse;
} }


@@ -97,10 +97,10 @@ public class Native2Ascii extends MatchingTask {
* Set the encoding to translate to/from. * Set the encoding to translate to/from.
* If unset, the default encoding for the JVM is used. * If unset, the default encoding for the JVM is used.
* *
* @param encoding String containing the name of the Native
* @param encoding String containing the name of the Native
* encoding to convert from or to. * encoding to convert from or to.
*/ */
public void setEncoding(String encoding){
public void setEncoding(String encoding) {
this.encoding = encoding; this.encoding = encoding;
} }


@@ -109,7 +109,7 @@ public class Native2Ascii extends MatchingTask {
* *
* @param srcDir directory to find input file in. * @param srcDir directory to find input file in.
*/ */
public void setSrc(File srcDir){
public void setSrc(File srcDir) {
this.srcDir = srcDir; this.srcDir = srcDir;
} }


@@ -119,7 +119,7 @@ public class Native2Ascii extends MatchingTask {
* *
* @param destDir directory to place output file into. * @param destDir directory to place output file into.
*/ */
public void setDest(File destDir){
public void setDest(File destDir) {
this.destDir = destDir; this.destDir = destDir;
} }


@@ -129,7 +129,7 @@ public class Native2Ascii extends MatchingTask {
* *
* @param ext File extension to use for converted files. * @param ext File extension to use for converted files.
*/ */
public void setExt(String ext){
public void setExt(String ext) {
this.extension = ext; this.extension = ext;
} }


@@ -151,19 +151,19 @@ public class Native2Ascii extends MatchingTask {
String[] files; // list of files to process String[] files; // list of files to process


// default srcDir to basedir // default srcDir to basedir
if (srcDir == null){
if (srcDir == null) {
srcDir = getProject().resolveFile("."); srcDir = getProject().resolveFile(".");
} }


// Require destDir // Require destDir
if (destDir == null){
if (destDir == null) {
throw new BuildException("The dest attribute must be set."); throw new BuildException("The dest attribute must be set.");
} }


// if src and dest dirs are the same, require the extension // if src and dest dirs are the same, require the extension
// to be set, so we don't stomp every file. One could still // to be set, so we don't stomp every file. One could still
// include a file with the same extension, but .... // include a file with the same extension, but ....
if (srcDir.equals(destDir) && extension == null && mapper == null){
if (srcDir.equals(destDir) && extension == null && mapper == null) {
throw new BuildException("The ext attribute or a mapper must be set if" throw new BuildException("The ext attribute or a mapper must be set if"
+ " src and dest dirs are the same."); + " src and dest dirs are the same.");
} }
@@ -178,7 +178,7 @@ public class Native2Ascii extends MatchingTask {
} else { } else {
m = mapper.getImplementation(); m = mapper.getImplementation();
} }
scanner = getDirectoryScanner(srcDir); scanner = getDirectoryScanner(srcDir);
files = scanner.getIncludedFiles(); files = scanner.getIncludedFiles();
SourceFileScanner sfs = new SourceFileScanner(this); SourceFileScanner sfs = new SourceFileScanner(this);
@@ -190,7 +190,7 @@ public class Native2Ascii extends MatchingTask {
String message = "Converting " + count + " file" String message = "Converting " + count + " file"
+ (count != 1 ? "s" : "") + " from "; + (count != 1 ? "s" : "") + " from ";
log(message + srcDir + " to " + destDir); log(message + srcDir + " to " + destDir);
for (int i = 0; i < files.length; i++){
for (int i = 0; i < files.length; i++) {
convert(files[i], m.mapFileName(files[i])[0]); convert(files[i], m.mapFileName(files[i])[0]);
} }
} }
@@ -209,11 +209,11 @@ public class Native2Ascii extends MatchingTask {


// Set up the basic args (this could be done once, but // Set up the basic args (this could be done once, but
// it's cleaner here) // it's cleaner here)
if (reverse){
if (reverse) {
cmd.createArgument().setValue("-reverse"); cmd.createArgument().setValue("-reverse");
} }


if (encoding != null){
if (encoding != null) {
cmd.createArgument().setValue("-encoding"); cmd.createArgument().setValue("-encoding");
cmd.createArgument().setValue(encoding); cmd.createArgument().setValue(encoding);
} }
@@ -225,27 +225,27 @@ public class Native2Ascii extends MatchingTask {
cmd.createArgument().setFile(srcFile); cmd.createArgument().setFile(srcFile);
cmd.createArgument().setFile(destFile); cmd.createArgument().setFile(destFile);
// Make sure we're not about to clobber something // Make sure we're not about to clobber something
if (srcFile.equals(destFile)){
throw new BuildException("file " + srcFile
if (srcFile.equals(destFile)) {
throw new BuildException("file " + srcFile
+ " would overwrite its self"); + " would overwrite its self");
} }


// Make intermediate directories if needed // Make intermediate directories if needed
// XXX JDK 1.1 dosen't have File.getParentFile, // XXX JDK 1.1 dosen't have File.getParentFile,
String parentName = destFile.getParent(); String parentName = destFile.getParent();
if (parentName != null){
if (parentName != null) {
File parentFile = new File(parentName); File parentFile = new File(parentName);
if ((!parentFile.exists()) && (!parentFile.mkdirs())){
if ((!parentFile.exists()) && (!parentFile.mkdirs())) {
throw new BuildException("cannot create parent directory " throw new BuildException("cannot create parent directory "
+ parentName); + parentName);
} }
} }
log("converting " + srcName, Project.MSG_VERBOSE); log("converting " + srcName, Project.MSG_VERBOSE);
sun.tools.native2ascii.Main n2a sun.tools.native2ascii.Main n2a
= new sun.tools.native2ascii.Main(); = new sun.tools.native2ascii.Main();
if (!n2a.convert(cmd.getArguments())){
if (!n2a.convert(cmd.getArguments())) {
throw new BuildException("conversion failed"); throw new BuildException("conversion failed");
} }
} }
@@ -258,7 +258,7 @@ public class Native2Ascii extends MatchingTask {
public String[] mapFileName(String fileName) { public String[] mapFileName(String fileName) {
int lastDot = fileName.lastIndexOf('.'); int lastDot = fileName.lastIndexOf('.');
if (lastDot >= 0) { if (lastDot >= 0) {
return new String[] {fileName.substring(0, lastDot)
return new String[] {fileName.substring(0, lastDot)
+ extension}; + extension};
} else { } else {
return new String[] {fileName + extension}; return new String[] {fileName + extension};


+ 35
- 38
src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java View File

@@ -60,9 +60,6 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
@@ -195,7 +192,7 @@ public class PropertyFile extends Task {
properties = new Properties(); properties = new Properties();
try { try {
if (propertyfile.exists()) { if (propertyfile.exists()) {
log("Updating property file: "
log("Updating property file: "
+ propertyfile.getAbsolutePath()); + propertyfile.getAbsolutePath());
FileInputStream fis = null; FileInputStream fis = null;
try { try {
@@ -208,7 +205,7 @@ public class PropertyFile extends Task {
} }
} }
} else { } else {
log("Creating new property file: "
log("Creating new property file: "
+ propertyfile.getAbsolutePath()); + propertyfile.getAbsolutePath());
FileOutputStream out = null; FileOutputStream out = null;
try { try {
@@ -289,40 +286,40 @@ public class PropertyFile extends Task {
public void setKey(String value) { public void setKey(String value) {
this.key = value; this.key = value;
} }
/**
/**
* Value to set (=), to add (+) or subtract (-) * Value to set (=), to add (+) or subtract (-)
*/ */
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
/** /**
* operation to apply.
* &quot;+&quot; or &quot;=&quot;
* operation to apply.
* &quot;+&quot; or &quot;=&quot;
*(default) for all datatypes; &quot;-&quot; for date and int only)\. *(default) for all datatypes; &quot;-&quot; for date and int only)\.
*/ */
public void setOperation(Operation value) { public void setOperation(Operation value) {
this.operation = Operation.toOperation(value.getValue()); this.operation = Operation.toOperation(value.getValue());
} }
/** /**
* Regard the value as : int, date or string (default) * Regard the value as : int, date or string (default)
*/ */
public void setType(Type value) { public void setType(Type value) {
this.type = Type.toType(value.getValue()); this.type = Type.toType(value.getValue());
} }
/** /**
* Initial value to set for a property if it is not * Initial value to set for a property if it is not
* already defined in the property file. * already defined in the property file.
* For type date, an additional keyword is allowed: &quot;now&quot; * For type date, an additional keyword is allowed: &quot;now&quot;
*/ */
public void setDefault(String value) { public void setDefault(String value) {
this.defaultValue = value; this.defaultValue = value;
} }
/** /**
* For int and date type only. If present, Values will * For int and date type only. If present, Values will
* be parsed and formatted accordingly. * be parsed and formatted accordingly.
@@ -330,7 +327,7 @@ public class PropertyFile extends Task {
public void setPattern(String value) { public void setPattern(String value) {
this.pattern = value; this.pattern = value;
} }
/** /**
* The unit of the value to be applied to date +/- operations. * The unit of the value to be applied to date +/- operations.
* Valid Values are: * Valid Values are:
@@ -344,7 +341,7 @@ public class PropertyFile extends Task {
* <li>month</li> * <li>month</li>
* <li>year</li> * <li>year</li>
* </ul> * </ul>
* This only applies to date types using a +/- operation.
* This only applies to date types using a +/- operation.
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void setUnit(PropertyFile.Unit unit) { public void setUnit(PropertyFile.Unit unit) {
@@ -372,11 +369,11 @@ public class PropertyFile extends Task {
// which means do nothing // which means do nothing
npe.printStackTrace(); npe.printStackTrace();
} }
if (newValue == null) { if (newValue == null) {
newValue = ""; newValue = "";
} }
// Insert as a string by default // Insert as a string by default
props.put(key, newValue); props.put(key, newValue);
} }
@@ -400,17 +397,17 @@ public class PropertyFile extends Task {
if (currentStringValue == null) { if (currentStringValue == null) {
currentStringValue = DEFAULT_DATE_VALUE; currentStringValue = DEFAULT_DATE_VALUE;
} }
if ("now".equals(currentStringValue)) { if ("now".equals(currentStringValue)) {
currentValue.setTime(new Date()); currentValue.setTime(new Date());
} else { } else {
try { try {
currentValue.setTime(fmt.parse(currentStringValue)); currentValue.setTime(fmt.parse(currentStringValue));
} catch (ParseException pe) {
// swallow
} catch (ParseException pe) {
// swallow
} }
} }
if (operation != Operation.EQUALS_OPER) { if (operation != Operation.EQUALS_OPER) {
int offset = 0; int offset = 0;
try { try {
@@ -454,7 +451,7 @@ public class PropertyFile extends Task {
} catch (ParseException pe) { } catch (ParseException pe) {
// swallow // swallow
} }
if (operation == Operation.EQUALS_OPER) { if (operation == Operation.EQUALS_OPER) {
newValue = currentValue; newValue = currentValue;
} else { } else {
@@ -478,7 +475,7 @@ public class PropertyFile extends Task {


this.newValue = fmt.format(newValue); this.newValue = fmt.format(newValue);
} }
/** /**
* Handle operations for type <code>string</code>. * Handle operations for type <code>string</code>.
* *
@@ -490,11 +487,11 @@ public class PropertyFile extends Task {
String newValue = DEFAULT_STRING_VALUE; String newValue = DEFAULT_STRING_VALUE;


String currentValue = getCurrentValue(oldValue); String currentValue = getCurrentValue(oldValue);
if (currentValue == null) { if (currentValue == null) {
currentValue = DEFAULT_STRING_VALUE; currentValue = DEFAULT_STRING_VALUE;
} }
if (operation == Operation.EQUALS_OPER) { if (operation == Operation.EQUALS_OPER) {
newValue = currentValue; newValue = currentValue;
} else if (operation == Operation.INCREMENT_OPER) { } else if (operation == Operation.INCREMENT_OPER) {
@@ -502,7 +499,7 @@ public class PropertyFile extends Task {
} }
this.newValue = newValue; this.newValue = newValue;
} }
/** /**
* Check if parameter combinations can be supported * Check if parameter combinations can be supported
* @todo make sure the 'unit' attribute is only specified on date * @todo make sure the 'unit' attribute is only specified on date
@@ -511,11 +508,11 @@ public class PropertyFile extends Task {
private void checkParameters() throws BuildException { private void checkParameters() throws BuildException {
if (type == Type.STRING_TYPE && if (type == Type.STRING_TYPE &&
operation == Operation.DECREMENT_OPER) { operation == Operation.DECREMENT_OPER) {
throw new BuildException("- is not suported for string "
throw new BuildException("- is not suported for string "
+ "properties (key:" + key + ")"); + "properties (key:" + key + ")");
} }
if (value == null && defaultValue == null) { if (value == null && defaultValue == null) {
throw new BuildException("\"value\" and/or \"default\" "
throw new BuildException("\"value\" and/or \"default\" "
+ "attribute must be specified (key:" + key + ")"); + "attribute must be specified (key:" + key + ")");
} }
if (key == null) { if (key == null) {
@@ -523,7 +520,7 @@ public class PropertyFile extends Task {
} }
if (type == Type.STRING_TYPE && if (type == Type.STRING_TYPE &&
pattern != null) { pattern != null) {
throw new BuildException("pattern is not suported for string "
throw new BuildException("pattern is not suported for string "
+ "properties (key:" + key + ")"); + "properties (key:" + key + ")");
} }
} }
@@ -532,13 +529,13 @@ public class PropertyFile extends Task {
String ret = null; String ret = null;
if (operation == Operation.EQUALS_OPER) { if (operation == Operation.EQUALS_OPER) {
// If only value is specified, the property is set to it // If only value is specified, the property is set to it
// regardless of its previous value.
// regardless of its previous value.
if (value != null && defaultValue == null) { if (value != null && defaultValue == null) {
ret = value; ret = value;
} }
// If only default is specified and the property previously // If only default is specified and the property previously
// existed in the property file, it is unchanged.
// existed in the property file, it is unchanged.
if (value == null && defaultValue != null && oldValue != null) { if (value == null && defaultValue != null && oldValue != null) {
ret = oldValue; ret = oldValue;
} }
@@ -548,7 +545,7 @@ public class PropertyFile extends Task {
if (value == null && defaultValue != null && oldValue == null) { if (value == null && defaultValue != null && oldValue == null) {
ret = defaultValue; ret = defaultValue;
} }
// If value and default are both specified and the property // If value and default are both specified and the property
// previously existed in the property file, the property // previously existed in the property file, the property
// is set to value. // is set to value.
@@ -558,17 +555,17 @@ public class PropertyFile extends Task {


// If value and default are both specified and the property // If value and default are both specified and the property
// did not exist in the property file, the property is set // did not exist in the property file, the property is set
// to default.
// to default.
if (value != null && defaultValue != null && oldValue == null) { if (value != null && defaultValue != null && oldValue == null) {
ret = defaultValue; ret = defaultValue;
} }
} else { } else {
ret = (oldValue == null) ? defaultValue : oldValue; ret = (oldValue == null) ? defaultValue : oldValue;
} }
return ret; return ret;
} }
/** /**
* Enumerated attribute with the values "+", "-", "=" * Enumerated attribute with the values "+", "-", "="
*/ */
@@ -617,7 +614,7 @@ public class PropertyFile extends Task {
} }
} }
} }
/** /**
* Borrowed from Tstamp * Borrowed from Tstamp
* @todo share all this time stuff across many tasks as a datetime datatype * @todo share all this time stuff across many tasks as a datetime datatype


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java View File

@@ -103,7 +103,7 @@ public class RenameExtensions extends MatchingTask {
fromExtension = from; fromExtension = from;
} }


/**
/**
* The string that renamed files will end with on * The string that renamed files will end with on
* completion * completion
*/ */
@@ -133,7 +133,7 @@ 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 "
throw new BuildException("srcDir, fromExtension and toExtension "
+ "attributes must be set!"); + "attributes must be set!");
} }


@@ -147,7 +147,7 @@ public class RenameExtensions extends MatchingTask {
log(" from=\"*" + fromExtension + "\"", Project.MSG_INFO); log(" from=\"*" + fromExtension + "\"", Project.MSG_INFO);
log(" to=\"*" + toExtension + "\" />", Project.MSG_INFO); log(" to=\"*" + toExtension + "\" />", Project.MSG_INFO);
log("</move>", Project.MSG_INFO); log("</move>", Project.MSG_INFO);
log("using the same patterns on <fileset> as you\'ve used here",
log("using the same patterns on <fileset> as you\'ve used here",
Project.MSG_INFO); Project.MSG_INFO);


Move move = (Move) getProject().createTask("move"); Move move = (Move) getProject().createTask("move");


+ 14
- 14
src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java View File

@@ -102,8 +102,8 @@ import org.apache.tools.ant.util.regexp.Regexp;
* Call Syntax: * Call Syntax:
* *
* &lt;replaceregexp file="file" * &lt;replaceregexp file="file"
* match="pattern"
* replace="pattern"
* match="pattern"
* replace="pattern"
* flags="options"? * flags="options"?
* byline="true|false"? &gt; * byline="true|false"? &gt;
* regexp? * regexp?
@@ -120,9 +120,9 @@ import org.apache.tools.ant.util.regexp.Regexp;
* Attributes: * Attributes:
* *
* file --&gt; A single file to operation on (mutually exclusive with the fileset subelements) * file --&gt; A single file to operation on (mutually exclusive with the fileset subelements)
* match --&gt; The Regular expression to match
* replace --&gt; The Expression replacement string
* flags --&gt; The options to give to the replacement
* match --&gt; The Regular expression to match
* replace --&gt; The Expression replacement string
* flags --&gt; The options to give to the replacement
* g = Substitute all occurrences. default is to replace only the first one * g = Substitute all occurrences. default is to replace only the first one
* i = Case insensitive match * i = Case insensitive match
* *
@@ -202,7 +202,7 @@ public class ReplaceRegExp extends Task {
* of the regular expression. * of the regular expression.
* Required if no nested &lt;substitution&gt; is used * Required if no nested &lt;substitution&gt; is used
*/ */
public void setReplace(String replace) { public void setReplace(String replace) {
if (subs != null) { if (subs != null) {
throw new BuildException("Only one substitution expression is " throw new BuildException("Only one substitution expression is "
@@ -219,12 +219,12 @@ public class ReplaceRegExp extends Task {
* <ul> * <ul>
* <li>g : Global replacement. Replace all occurences found * <li>g : Global replacement. Replace all occurences found
* <li>i : Case Insensitive. Do not consider case in the match * <li>i : Case Insensitive. Do not consider case in the match
* <li>m : Multiline. Treat the string as multiple lines of input,
* <li>m : Multiline. Treat the string as multiple lines of input,
* using "^" and "$" as the start or end of any line, respectively, rather than start or end of string. * using "^" and "$" as the start or end of any line, respectively, rather than start or end of string.
* <li> s : Singleline. Treat the string as a single line of input, using * <li> s : Singleline. Treat the string as a single line of input, using
* "." to match any character, including a newline, which normally, it would not match. * "." to match any character, including a newline, which normally, it would not match.
*</ul> *</ul>
*/
*/
public void setFlags(String flags) { public void setFlags(String flags) {
this.flags = flags; this.flags = flags;
} }
@@ -303,7 +303,7 @@ public class ReplaceRegExp extends Task {
Regexp regexp = r.getRegexp(getProject()); Regexp regexp = r.getRegexp(getProject());


if (regexp.matches(input, options)) { if (regexp.matches(input, options)) {
res = regexp.substitute(input, s.getExpression(getProject()),
res = regexp.substitute(input, s.getExpression(getProject()),
options); options);
} }


@@ -441,7 +441,7 @@ public class ReplaceRegExp extends Task {
fileUtils.rename(temp, f); fileUtils.rename(temp, f);
temp = null; temp = null;
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Couldn't rename temporary file "
throw new BuildException("Couldn't rename temporary file "
+ temp, getLocation()); + temp, getLocation());
} }
} }
@@ -502,12 +502,12 @@ public class ReplaceRegExp extends Task {
try { try {
doReplace(file, options); doReplace(file, options);
} catch (IOException e) { } catch (IOException e) {
log("An error occurred processing file: '"
log("An error occurred processing file: '"
+ file.getAbsolutePath() + "': " + e.toString(), + file.getAbsolutePath() + "': " + e.toString(),
Project.MSG_ERR); Project.MSG_ERR);
} }
} else if (file != null) { } else if (file != null) {
log("The following file is missing: '"
log("The following file is missing: '"
+ file.getAbsolutePath() + "'", Project.MSG_ERR); + file.getAbsolutePath() + "'", Project.MSG_ERR);
} }


@@ -526,12 +526,12 @@ public class ReplaceRegExp extends Task {
try { try {
doReplace(f, options); doReplace(f, options);
} catch (Exception e) { } catch (Exception e) {
log("An error occurred processing file: '"
log("An error occurred processing file: '"
+ f.getAbsolutePath() + "': " + e.toString(), + f.getAbsolutePath() + "': " + e.toString(),
Project.MSG_ERR); Project.MSG_ERR);
} }
} else { } else {
log("The following file is missing: '"
log("The following file is missing: '"
+ f.getAbsolutePath() + "'", Project.MSG_ERR); + f.getAbsolutePath() + "'", Project.MSG_ERR);
} }
} }


+ 8
- 8
src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java View File

@@ -79,7 +79,7 @@ import org.apache.tools.ant.types.Path;
* @author lucas@collab.net * @author lucas@collab.net
*/ */
public class Rpm extends Task { public class Rpm extends Task {
/** /**
* the spec file * the spec file
*/ */
@@ -127,10 +127,10 @@ public class Rpm extends Task {
private File error; private File error;


public void execute() throws BuildException { public void execute() throws BuildException {
Commandline toExecute = new Commandline(); Commandline toExecute = new Commandline();


toExecute.setExecutable(rpmBuildCommand == null
toExecute.setExecutable(rpmBuildCommand == null
? guessRpmBuildCommand() ? guessRpmBuildCommand()
: rpmBuildCommand); : rpmBuildCommand);
if (topDir != null) { if (topDir != null) {
@@ -210,7 +210,7 @@ public class Rpm extends Task {


/** /**
* The directory which will have the expected * The directory which will have the expected
* subdirectories, SPECS, SOURCES, BUILD, SRPMS ; optional.
* subdirectories, SPECS, SOURCES, BUILD, SRPMS ; optional.
* If this isn't specified, * If this isn't specified,
* the <tt>baseDir</tt> value is used * the <tt>baseDir</tt> value is used
*/ */
@@ -237,7 +237,7 @@ public class Rpm extends Task {
} }


/** /**
* Flag (optional, default=false) to remove
* Flag (optional, default=false) to remove
* the generated files in the BUILD directory * the generated files in the BUILD directory
*/ */
public void setCleanBuildDir(boolean cbd) { public void setCleanBuildDir(boolean cbd) {
@@ -252,7 +252,7 @@ public class Rpm extends Task {
} }


/** /**
* Flag (optional, default=false)
* Flag (optional, default=false)
* to remove the sources after the build. * to remove the sources after the build.
* See the the <tt>--rmsource</tt> option of rpmbuild. * See the the <tt>--rmsource</tt> option of rpmbuild.
*/ */
@@ -307,8 +307,8 @@ public class Rpm extends Task {
Path p = new Path(getProject(), path); Path p = new Path(getProject(), path);
String[] pElements = p.list(); String[] pElements = p.list();
for (int i = 0; i < pElements.length; i++) { for (int i = 0; i < pElements.length; i++) {
File f = new File(pElements[i],
"rpmbuild"
File f = new File(pElements[i],
"rpmbuild"
+ (Os.isFamily("dos") ? ".exe" : "")); + (Os.isFamily("dos") ? ".exe" : ""));
if (f.canRead()) { if (f.canRead()) {
return f.getAbsolutePath(); return f.getAbsolutePath();


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/Script.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -150,7 +150,7 @@ public class Script extends Task {
*/ */
public void setSrc(String fileName) { public void setSrc(String fileName) {
File file = new File(fileName); File file = new File(fileName);
if (!file.exists()) {
if (!file.exists()) {
throw new BuildException("file " + fileName + " not found."); throw new BuildException("file " + fileName + " not found.");
} }


@@ -164,7 +164,7 @@ public class Script extends Task {
} catch (IOException e) { } catch (IOException e) {
throw new BuildException(e); throw new BuildException(e);
} }
script += new String(data); script += new String(data);
} }




+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/StyleBook.java View File

@@ -85,10 +85,10 @@ public class StyleBook
} }


/** /**
* The book xml file that the documentation generation starts from;
* The book xml file that the documentation generation starts from;
* required. * required.
*/ */
public void setBook(final File book) { public void setBook(final File book) {
m_book = book; m_book = book;
} }


+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/optional/Test.java View File

@@ -60,7 +60,7 @@ import org.apache.tools.ant.taskdefs.Java;
/** /**
* This is a primitive task to execute a unit test in the * This is a primitive task to execute a unit test in the
* org.apache.testlet framework. * org.apache.testlet framework.
*
*
* @deprecated testlet has been abandoned in favor of JUnit by the * @deprecated testlet has been abandoned in favor of JUnit by the
* Avalon community * Avalon community
* *
@@ -109,17 +109,17 @@ public class Test extends Java {




/** /**
* a boolean value indicating whether tests should display a
* a boolean value indicating whether tests should display a
* message on success; optional * message on success; optional
*/ */
public void setShowSuccess(final boolean showSuccess) { public void setShowSuccess(final boolean showSuccess) {
createArg().setValue("-s=" + showSuccess); createArg().setValue("-s=" + showSuccess);
} }




/** /**
* a boolean value indicating whether a banner should be displayed
* a boolean value indicating whether a banner should be displayed
* when starting testlet engine; optional. * when starting testlet engine; optional.
*/ */
public void setShowBanner(final String showBanner) { public void setShowBanner(final String showBanner) {
@@ -128,7 +128,7 @@ public class Test extends Java {




/** /**
* a boolean indicating that a stack trace is displayed on
* a boolean indicating that a stack trace is displayed on
* error (but not normal failure); optional. * error (but not normal failure); optional.
*/ */
public void setShowTrace(final boolean showTrace) { public void setShowTrace(final boolean showTrace) {


+ 10
- 10
src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java View File

@@ -118,12 +118,12 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
/** The In memory version of the stylesheet */ /** The In memory version of the stylesheet */
private Templates templates; private Templates templates;


/**
* The modification time of the stylesheet from which the templates
* are read
/**
* The modification time of the stylesheet from which the templates
* are read
*/ */
private long templatesModTime; private long templatesModTime;
/** possible resolver for URIs */ /** possible resolver for URIs */
private URIResolver uriResolver; private URIResolver uriResolver;


@@ -143,10 +143,10 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
if (this.stylesheet != null) { if (this.stylesheet != null) {
// resetting the stylesheet - reset transformer // resetting the stylesheet - reset transformer
transformer = null; transformer = null;
// do we need to reset templates as well // do we need to reset templates as well
if (!this.stylesheet.equals(stylesheet) if (!this.stylesheet.equals(stylesheet)
|| (stylesheet.lastModified() != templatesModTime)) {
|| (stylesheet.lastModified() != templatesModTime)) {
templates = null; templates = null;
} }
} }
@@ -222,7 +222,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
/** /**
* Read in templates from the stylsheet * Read in templates from the stylsheet
*/ */
private void readTemplates()
private void readTemplates()
throws IOException, TransformerConfigurationException { throws IOException, TransformerConfigurationException {
// WARN: Don't use the StreamSource(File) ctor. It won't work with // WARN: Don't use the StreamSource(File) ctor. It won't work with
// xalan prior to 2.2 because of systemid bugs. // xalan prior to 2.2 because of systemid bugs.
@@ -233,7 +233,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
// the file quickly on windows. // the file quickly on windows.
InputStream xslStream = null; InputStream xslStream = null;
try { try {
xslStream
xslStream
= new BufferedInputStream(new FileInputStream(stylesheet)); = new BufferedInputStream(new FileInputStream(stylesheet));
templatesModTime = stylesheet.lastModified(); templatesModTime = stylesheet.lastModified();
StreamSource src = new StreamSource(xslStream); StreamSource src = new StreamSource(xslStream);
@@ -247,7 +247,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
} }
} }
} }
/** /**
* Create a new transformer based on the liaison settings * Create a new transformer based on the liaison settings
* @return the newly created and configured transformer. * @return the newly created and configured transformer.
@@ -333,7 +333,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
* string or object. * string or object.
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void setAttribute(String name, Object value){
public void setAttribute(String name, Object value) {
final Object[] pair = new Object[]{name, value}; final Object[] pair = new Object[]{name, value};
attributes.addElement(pair); attributes.addElement(pair);
} }


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java View File

@@ -105,24 +105,24 @@ public class XalanLiaison implements XSLTLiaison {
// collector will close them...whenever possible and // collector will close them...whenever possible and
// Windows may complain about not being able to delete files. // Windows may complain about not being able to delete files.
try { try {
if (xslStream != null){
if (xslStream != null) {
xslStream.close(); xslStream.close();
} }
} catch (IOException ignored){}
} catch (IOException ignored) {}
try { try {
if (fis != null){
if (fis != null) {
fis.close(); fis.close();
} }
} catch (IOException ignored){}
} catch (IOException ignored) {}
try { try {
if (fos != null){
if (fos != null) {
fos.close(); fos.close();
} }
} catch (IOException ignored){}
} catch (IOException ignored) {}
} }
} }


public void addParam(String name, String value){
public void addParam(String name, String value) {
processor.setStylesheetParam(name, value); processor.setStylesheetParam(name, value);
} }




+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java View File

@@ -89,7 +89,7 @@ public class XslpLiaison implements XSLTLiaison {
// it is really the pathname // it is really the pathname
xslSheet = xslReader.read(fileName.getAbsolutePath()); xslSheet = xslReader.read(fileName.getAbsolutePath());
} }
public void transform(File infile, File outfile) throws Exception { public void transform(File infile, File outfile) throws Exception {
FileOutputStream fos = new FileOutputStream(outfile); FileOutputStream fos = new FileOutputStream(outfile);
// XSLP does not support encoding...we're in hot water. // XSLP does not support encoding...we're in hot water.
@@ -97,7 +97,7 @@ public class XslpLiaison implements XSLTLiaison {
processor.process(infile.getAbsolutePath(), xslSheet, out); processor.process(infile.getAbsolutePath(), xslSheet, out);
} }


public void addParam(String name, String expression){
public void addParam(String name, String expression) {
processor.setProperty(name, expression); processor.setProperty(name, expression);
} }




+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/ejb/InnerClassFilenameFilter.java View File

@@ -59,7 +59,7 @@ import java.io.FilenameFilter;
public class InnerClassFilenameFilter implements FilenameFilter { public class InnerClassFilenameFilter implements FilenameFilter {
private String baseClassName; private String baseClassName;


InnerClassFilenameFilter(String baseclass){
InnerClassFilenameFilter(String baseclass) {
int extidx = baseclass.lastIndexOf(".class"); int extidx = baseclass.lastIndexOf(".class");
if (extidx == -1) { if (extidx == -1) {
extidx = baseclass.length() - 1; extidx = baseclass.length() - 1;
@@ -67,7 +67,7 @@ public class InnerClassFilenameFilter implements FilenameFilter {
baseClassName = baseclass.substring(0, extidx); baseClassName = baseclass.substring(0, extidx);
} }


public boolean accept (File Dir, String filename){
public boolean accept (File Dir, String filename) {
if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class")) if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class"))
|| (filename.indexOf(baseClassName + "$") != 0)) { || (filename.indexOf(baseClassName + "$") != 0)) {
return false; return false;


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java View File

@@ -112,8 +112,8 @@ public class JavaCC extends Task {
protected static final int TASKDEF_TYPE_JJTREE = 2; protected static final int TASKDEF_TYPE_JJTREE = 2;
protected static final int TASKDEF_TYPE_JJDOC = 3; protected static final int TASKDEF_TYPE_JJDOC = 3;


protected static final String[] ARCHIVE_LOCATIONS =
new String[] {"JavaCC.zip", "bin/lib/JavaCC.zip",
protected static final String[] ARCHIVE_LOCATIONS =
new String[] {"JavaCC.zip", "bin/lib/JavaCC.zip",
"bin/lib/javacc.jar", "bin/lib/javacc.jar",
"javacc.jar", // used by jpackage for JavaCC 3.x "javacc.jar", // used by jpackage for JavaCC 3.x
}; };
@@ -353,7 +353,7 @@ public class JavaCC extends Task {
* @return the file object pointing to the JavaCC archive. * @return the file object pointing to the JavaCC archive.
*/ */
protected static File getArchiveFile(File home) throws BuildException { protected static File getArchiveFile(File home) throws BuildException {
return new File(home,
return new File(home,
ARCHIVE_LOCATIONS[getMajorVersionNumber(home) - 1]); ARCHIVE_LOCATIONS[getMajorVersionNumber(home) - 1]);
} }


@@ -365,7 +365,7 @@ public class JavaCC extends Task {
* or if the archive could not be found despite attempts to do so. * or if the archive could not be found despite attempts to do so.
* @return the main class for the taskdef. * @return the main class for the taskdef.
*/ */
protected static String getMainClass(File home, int type)
protected static String getMainClass(File home, int type)
throws BuildException { throws BuildException {


int majorVersion = getMajorVersionNumber(home); int majorVersion = getMajorVersionNumber(home);
@@ -398,7 +398,7 @@ public class JavaCC extends Task {


case 3: case 3:
case 4: case 4:
/*
/*
* This is where the fun starts, JavaCC 3.0 uses * This is where the fun starts, JavaCC 3.0 uses
* org.netbeans.javacc, 3.1 uses org.javacc - I wonder * org.netbeans.javacc, 3.1 uses org.javacc - I wonder
* which version is going to use net.java.javacc. * which version is going to use net.java.javacc.
@@ -466,7 +466,7 @@ public class JavaCC extends Task {
* or if the archive could not be found despite attempts to do so. * or if the archive could not be found despite attempts to do so.
* @return a number that is useless outside the scope of this class * @return a number that is useless outside the scope of this class
*/ */
protected static int getMajorVersionNumber(File home)
protected static int getMajorVersionNumber(File home)
throws BuildException { throws BuildException {


if (home == null || !home.isDirectory()) { if (home == null || !home.isDirectory()) {
@@ -476,7 +476,7 @@ public class JavaCC extends Task {
for (int i = 0; i < ARCHIVE_LOCATIONS.length; i++) { for (int i = 0; i < ARCHIVE_LOCATIONS.length; i++) {
File f = new File(home, ARCHIVE_LOCATIONS[i]); File f = new File(home, ARCHIVE_LOCATIONS[i]);


if (f.exists()){
if (f.exists()) {
return (i + 1); return (i + 1);
} }
} }


+ 12
- 12
src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java View File

@@ -110,11 +110,11 @@ public class JDependTask extends Task {


static { static {
try { try {
Class packageFilter =
Class packageFilter =
Class.forName("jdepend.framework.PackageFilter"); Class.forName("jdepend.framework.PackageFilter");
packageFilterC =
packageFilterC =
packageFilter.getConstructor(new Class[] {java.util.Collection.class}); packageFilter.getConstructor(new Class[] {java.util.Collection.class});
setFilter =
setFilter =
jdepend.textui.JDepend.class.getDeclaredMethod("setFilter", jdepend.textui.JDepend.class.getDeclaredMethod("setFilter",
new Class[] {packageFilter}); new Class[] {packageFilter});
} catch (Throwable t) { } catch (Throwable t) {
@@ -199,9 +199,9 @@ public class JDependTask extends Task {


/** /**
* Gets the sourcepath. * Gets the sourcepath.
*
*
* @deprecated * @deprecated
*
*
*/ */
public Path getSourcespath() { public Path getSourcespath() {
return _sourcesPath; return _sourcesPath;
@@ -219,7 +219,7 @@ public class JDependTask extends Task {


/** /**
* Gets the classespath. * Gets the classespath.
*
*
*/ */
public Path getClassespath() { public Path getClassespath() {
return _classesPath; return _classesPath;
@@ -355,7 +355,7 @@ public class JDependTask extends Task {
} }
} }


// if there is an error/failure and that it should halt, stop
// if there is an error/failure and that it should halt, stop
// everything otherwise just log a statement // everything otherwise just log a statement
boolean errorOccurred = exitValue == JDependTask.ERRORS; boolean errorOccurred = exitValue == JDependTask.ERRORS;


@@ -391,7 +391,7 @@ public class JDependTask extends Task {
try { try {
fw = new FileWriter(getOutputFile().getPath()); fw = new FileWriter(getOutputFile().getPath());
} catch (IOException e) { } catch (IOException e) {
String msg = "JDepend Failed when creating the output file: "
String msg = "JDepend Failed when creating the output file: "
+ e.getMessage(); + e.getMessage();
log(msg); log(msg);
throw new BuildException(msg); throw new BuildException(msg);
@@ -507,8 +507,8 @@ public class JDependTask extends Task {
} }


if (getOutputFile() != null) { if (getOutputFile() != null) {
// having a space between the file and its path causes commandline
// to add quotes around the argument thus making JDepend not taking
// having a space between the file and its path causes commandline
// to add quotes around the argument thus making JDepend not taking
// it into account. Thus we split it in two // it into account. Thus we split it in two
commandline.createArgument().setValue("-file"); commandline.createArgument().setValue("-file");
commandline.createArgument().setValue(_outputFile.getPath()); commandline.createArgument().setValue(_outputFile.getPath());
@@ -522,7 +522,7 @@ public class JDependTask extends Task {


// not necessary as JDepend would fail, but why loose some time? // not necessary as JDepend would fail, but why loose some time?
if (!f.exists() || !f.isDirectory()) { if (!f.exists() || !f.isDirectory()) {
throw new BuildException("\"" + f.getPath() + "\" does not "
throw new BuildException("\"" + f.getPath() + "\" does not "
+ "represent a valid directory. JDepend would fail."); + "represent a valid directory. JDepend would fail.");
} }
commandline.createArgument().setValue(f.getPath()); commandline.createArgument().setValue(f.getPath());
@@ -566,7 +566,7 @@ public class JDependTask extends Task {


return null; return null;
/* /*
if (getTimeout() == null){
if (getTimeout() == null) {
return null; return null;
} }
return new ExecuteWatchdog(getTimeout().intValue()); return new ExecuteWatchdog(getTimeout().intValue());


+ 8
- 8
src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java View File

@@ -61,7 +61,7 @@ import org.apache.tools.ant.types.Path;


/** /**
* This class defines objects that can link together various jar and * This class defines objects that can link together various jar and
* zip files.
* zip files.
* *
* <p>It is basically a wrapper for the jlink code written originally * <p>It is basically a wrapper for the jlink code written originally
* by <a href="mailto:beard@netscape.com">Patrick Beard</a>. The * by <a href="mailto:beard@netscape.com">Patrick Beard</a>. The
@@ -154,11 +154,11 @@ public class JlinkTask extends MatchingTask {
public void execute() throws BuildException { public void execute() throws BuildException {
//Be sure everything has been set. //Be sure everything has been set.
if (outfile == null) { if (outfile == null) {
throw new BuildException("outfile attribute is required! "
throw new BuildException("outfile attribute is required! "
+ "Please set."); + "Please set.");
} }
if (!haveAddFiles() && !haveMergeFiles()) { if (!haveAddFiles() && !haveMergeFiles()) {
throw new BuildException("addfiles or mergefiles required! "
throw new BuildException("addfiles or mergefiles required! "
+ "Please set."); + "Please set.");
} }
log("linking: " + outfile.getPath()); log("linking: " + outfile.getPath());
@@ -181,19 +181,19 @@ public class JlinkTask extends MatchingTask {
} }
} }


private boolean haveAddFiles(){
private boolean haveAddFiles() {
return haveEntries(addfiles); return haveEntries(addfiles);
} }


private boolean haveMergeFiles(){
private boolean haveMergeFiles() {
return haveEntries(mergefiles); return haveEntries(mergefiles);
} }


private boolean haveEntries(Path p){
if (p == null){
private boolean haveEntries(Path p) {
if (p == null) {
return false; return false;
} }
if (p.size() > 0){
if (p.size() > 0) {
return true; return true;
} }
return false; return false;


+ 10
- 10
src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java View File

@@ -164,7 +164,7 @@ public class JspC extends MatchingTask {
src.append(srcDir); src.append(srcDir);
} }
} }
public Path getSrcDir(){
public Path getSrcDir() {
return src; return src;
} }


@@ -175,28 +175,28 @@ public class JspC extends MatchingTask {
public void setDestdir(File destDir) { public void setDestdir(File destDir) {
this.destDir = destDir; this.destDir = destDir;
} }
public File getDestdir(){
public File getDestdir() {
return destDir; return destDir;
} }


/** /**
* Set the name of the package the compiled jsp files should be in. * Set the name of the package the compiled jsp files should be in.
*/ */
public void setPackage(String pkg){
public void setPackage(String pkg) {
this.packageName = pkg; this.packageName = pkg;
} }


public String getPackage(){
public String getPackage() {
return packageName; return packageName;
} }


/** /**
* Set the verbose level of the compiler * Set the verbose level of the compiler
*/ */
public void setVerbose(int i){
public void setVerbose(int i) {
verbose = i; verbose = i;
} }
public int getVerbose(){
public int getVerbose() {
return verbose; return verbose;
} }


@@ -298,7 +298,7 @@ public class JspC extends MatchingTask {
public void setClasspathRef(Reference r) { public void setClasspathRef(Reference r) {
createClasspath().setRefid(r); createClasspath().setRefid(r);
} }
public Path getClasspath(){
public Path getClasspath() {
return classpath; return classpath;
} }


@@ -316,7 +316,7 @@ public class JspC extends MatchingTask {
/** /**
* get the classpath used to find the compiler adapter * get the classpath used to find the compiler adapter
*/ */
public Path getCompilerclasspath(){
public Path getCompilerclasspath() {
return compilerClasspath; return compilerClasspath;
} }


@@ -389,7 +389,7 @@ public class JspC extends MatchingTask {
/** /**
* get the list of files to compile * get the list of files to compile
*/ */
public Vector getCompileList(){
public Vector getCompileList() {
return compileList; return compileList;
} }


@@ -430,7 +430,7 @@ public class JspC extends MatchingTask {
if (src == null) { if (src == null) {
throw new BuildException("srcdir attribute must be set!", throw new BuildException("srcdir attribute must be set!",
getLocation()); getLocation());
}
}
String [] list = src.list(); String [] list = src.list();
if (list.length == 0) { if (list.length == 0) {
throw new BuildException("srcdir attribute must be set!", throw new BuildException("srcdir attribute must be set!",


+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java View File

@@ -132,9 +132,9 @@ public class JasperC extends DefaultJspCompilerAdapter {
getJspc().deleteEmptyJavaFiles(); getJspc().deleteEmptyJavaFiles();
} }
} }




/** /**
* build up a command line * build up a command line
* @return a command line for jasper * @return a command line for jasper
@@ -149,12 +149,12 @@ public class JasperC extends DefaultJspCompilerAdapter {
addArg(cmd, "-uribase", jspc.getUribase()); addArg(cmd, "-uribase", jspc.getUribase());
addArg(cmd, "-ieplugin", jspc.getIeplugin()); addArg(cmd, "-ieplugin", jspc.getIeplugin());
addArg(cmd, "-webinc", jspc.getWebinc()); addArg(cmd, "-webinc", jspc.getWebinc());
addArg(cmd, "-webxml", jspc.getWebxml());
addArg(cmd, "-webxml", jspc.getWebxml());
addArg(cmd, "-die9"); addArg(cmd, "-die9");


if (jspc.isMapped()){
if (jspc.isMapped()) {
addArg(cmd, "-mapped"); addArg(cmd, "-mapped");
}
}
if (jspc.getWebApp() != null) { if (jspc.getWebApp() != null) {
File dir = jspc.getWebApp().getDirectory(); File dir = jspc.getWebApp().getDirectory();
addArg(cmd, "-webapp", dir); addArg(cmd, "-webapp", dir);


+ 16
- 16
src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java View File

@@ -84,7 +84,7 @@ public class AggregateTransformer {
public static final String NOFRAMES = "noframes"; public static final String NOFRAMES = "noframes";


public static class Format extends EnumeratedAttribute { public static class Format extends EnumeratedAttribute {
public String[] getValues(){
public String[] getValues() {
return new String[]{FRAMES, NOFRAMES}; return new String[]{FRAMES, NOFRAMES};
} }
} }
@@ -106,16 +106,16 @@ public class AggregateTransformer {


/** XML Parser factory */ /** XML Parser factory */
private static DocumentBuilderFactory privateDBFactory; private static DocumentBuilderFactory privateDBFactory;
/** XML Parser factory accessible to subclasses */ /** XML Parser factory accessible to subclasses */
protected static DocumentBuilderFactory dbfactory; protected static DocumentBuilderFactory dbfactory;
static { static {
privateDBFactory = DocumentBuilderFactory.newInstance(); privateDBFactory = DocumentBuilderFactory.newInstance();
dbfactory = privateDBFactory; dbfactory = privateDBFactory;
} }


public AggregateTransformer(Task task){
public AggregateTransformer(Task task) {
this.task = task; this.task = task;
} }


@@ -127,12 +127,12 @@ public class AggregateTransformer {
protected static DocumentBuilderFactory getDocumentBuilderFactory() { protected static DocumentBuilderFactory getDocumentBuilderFactory() {
return privateDBFactory; return privateDBFactory;
} }
public void setFormat(Format format){
public void setFormat(Format format) {
this.format = format.getValue(); this.format = format.getValue();
} }


public void setXmlDocument(Document doc){
public void setXmlDocument(Document doc) {
this.document = doc; this.document = doc;
} }


@@ -151,7 +151,7 @@ public class AggregateTransformer {
} finally { } finally {
in.close(); in.close();
} }
} catch (Exception e){
} catch (Exception e) {
throw new BuildException("Error while parsing document: " + xmlfile, e); throw new BuildException("Error while parsing document: " + xmlfile, e);
} }
} }
@@ -162,17 +162,17 @@ public class AggregateTransformer {
* @param styledir the directory containing the xsl files if the user * @param styledir the directory containing the xsl files if the user
* would like to override with its own style. * would like to override with its own style.
*/ */
public void setStyledir(File styledir){
public void setStyledir(File styledir) {
this.styleDir = styledir; this.styleDir = styledir;
} }


/** set the destination directory */ /** set the destination directory */
public void setTodir(File todir){
public void setTodir(File todir) {
this.toDir = todir; this.toDir = todir;
} }


/** set the extension of the output files */ /** set the extension of the output files */
public void setExtension(String ext){
public void setExtension(String ext) {
task.log("extension is not used anymore", Project.MSG_WARN); task.log("extension is not used anymore", Project.MSG_WARN);
} }


@@ -182,7 +182,7 @@ public class AggregateTransformer {
XalanExecutor executor = XalanExecutor.newInstance(this); XalanExecutor executor = XalanExecutor.newInstance(this);
try { try {
executor.execute(); executor.execute();
} catch (Exception e){
} catch (Exception e) {
throw new BuildException("Errors while applying transformations: " throw new BuildException("Errors while applying transformations: "
+ e.getMessage(), e); + e.getMessage(), e);
} }
@@ -210,18 +210,18 @@ public class AggregateTransformer {
*/ */
protected String getStylesheetSystemId() throws IOException { protected String getStylesheetSystemId() throws IOException {
String xslname = "junit-frames.xsl"; String xslname = "junit-frames.xsl";
if (NOFRAMES.equals(format)){
if (NOFRAMES.equals(format)) {
xslname = "junit-noframes.xsl"; xslname = "junit-noframes.xsl";
} }
if (styleDir == null){
if (styleDir == null) {
URL url = getClass().getResource("xsl/" + xslname); URL url = getClass().getResource("xsl/" + xslname);
if (url == null){
if (url == null) {
throw new FileNotFoundException("Could not find jar resource " + xslname); throw new FileNotFoundException("Could not find jar resource " + xslname);
} }
return url.toExternalForm(); return url.toExternalForm();
} }
File file = new File(styleDir, xslname); File file = new File(styleDir, xslname);
if (!file.exists()){
if (!file.exists()) {
throw new FileNotFoundException("Could not find file '" + file + "'"); throw new FileNotFoundException("Could not find file '" + file + "'");
} }
return JAXPUtils.getSystemId(file); return JAXPUtils.getSystemId(file);


+ 8
- 8
src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java View File

@@ -60,7 +60,7 @@ import java.util.Vector;
/** /**
* Baseclass for BatchTest and JUnitTest. * Baseclass for BatchTest and JUnitTest.
* *
* @author Stefan Bodewig
* @author Stefan Bodewig
* @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
*/ */
public abstract class BaseTest { public abstract class BaseTest {
@@ -84,7 +84,7 @@ public abstract class BaseTest {
public boolean getFiltertrace() { public boolean getFiltertrace() {
return filtertrace; return filtertrace;
} }
public void setFork(boolean value) { public void setFork(boolean value) {
fork = value; fork = value;
} }
@@ -125,15 +125,15 @@ public abstract class BaseTest {
* Sets the destination directory. * Sets the destination directory.
*/ */
public void setTodir(File destDir) { public void setTodir(File destDir) {
this.destDir = destDir;
this.destDir = destDir;
} }


/** /**
* @return the destination directory as an absolute path if it exists * @return the destination directory as an absolute path if it exists
* otherwise return <tt>null</tt> * otherwise return <tt>null</tt>
*/ */
public String getTodir(){
if (destDir != null){
public String getTodir() {
if (destDir != null) {
return destDir.getAbsolutePath(); return destDir.getAbsolutePath();
} }
return null; return null;
@@ -142,15 +142,15 @@ public abstract class BaseTest {
public java.lang.String getFailureProperty() { public java.lang.String getFailureProperty() {
return failureProperty; return failureProperty;
} }
public void setFailureProperty(String failureProperty) { public void setFailureProperty(String failureProperty) {
this.failureProperty = failureProperty; this.failureProperty = failureProperty;
} }
public java.lang.String getErrorProperty() { public java.lang.String getErrorProperty() {
return errorProperty; return errorProperty;
} }
public void setErrorProperty(String errorProperty) { public void setErrorProperty(String errorProperty) {
this.errorProperty = errorProperty; this.errorProperty = errorProperty;
} }


+ 9
- 9
src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java View File

@@ -65,8 +65,8 @@ import org.apache.tools.ant.types.FileSet;
/** /**
* <p> Create then run <code>JUnitTest</code>'s based on the list of files given by the fileset attribute. * <p> Create then run <code>JUnitTest</code>'s based on the list of files given by the fileset attribute.
* *
* <p> Every <code>.java</code> or <code>.class</code> file in the fileset is
* assumed to be a testcase.
* <p> Every <code>.java</code> or <code>.class</code> file in the fileset is
* assumed to be a testcase.
* A <code>JUnitTest</code> is created for each of these named classes with basic setup * A <code>JUnitTest</code> is created for each of these named classes with basic setup
* inherited from the parent <code>BatchTest</code>. * inherited from the parent <code>BatchTest</code>.
* *
@@ -88,7 +88,7 @@ public final class BatchTest extends BaseTest {
* create a new batchtest instance * create a new batchtest instance
* @param project the project it depends on. * @param project the project it depends on.
*/ */
public BatchTest(Project project){
public BatchTest(Project project) {
this.project = project; this.project = project;
} }


@@ -107,7 +107,7 @@ public final class BatchTest extends BaseTest {
* @return an enumeration of all elements of this batchtest that are * @return an enumeration of all elements of this batchtest that are
* a <tt>JUnitTest</tt> instance. * a <tt>JUnitTest</tt> instance.
*/ */
public final Enumeration elements(){
public final Enumeration elements() {
JUnitTest[] tests = createAllJUnitTest(); JUnitTest[] tests = createAllJUnitTest();
return Enumerations.fromArray(tests); return Enumerations.fromArray(tests);
} }
@@ -118,7 +118,7 @@ public final class BatchTest extends BaseTest {
* @param v the vector to which should be added all individual tests of this * @param v the vector to which should be added all individual tests of this
* batch test. * batch test.
*/ */
final void addTestsTo(Vector v){
final void addTestsTo(Vector v) {
JUnitTest[] tests = createAllJUnitTest(); JUnitTest[] tests = createAllJUnitTest();
v.ensureCapacity(v.size() + tests.length); v.ensureCapacity(v.size() + tests.length);
for (int i = 0; i < tests.length; i++) { for (int i = 0; i < tests.length; i++) {
@@ -131,7 +131,7 @@ public final class BatchTest extends BaseTest {
* is configured to match this instance properties. * is configured to match this instance properties.
* @return the array of all <tt>JUnitTest</tt>s that belongs to this batch. * @return the array of all <tt>JUnitTest</tt>s that belongs to this batch.
*/ */
private JUnitTest[] createAllJUnitTest(){
private JUnitTest[] createAllJUnitTest() {
String[] filenames = getFilenames(); String[] filenames = getFilenames();
JUnitTest[] tests = new JUnitTest[filenames.length]; JUnitTest[] tests = new JUnitTest[filenames.length];
for (int i = 0; i < tests.length; i++) { for (int i = 0; i < tests.length; i++) {
@@ -151,7 +151,7 @@ public final class BatchTest extends BaseTest {
* qualified class name (If it is not the case it will fail when running the test). * qualified class name (If it is not the case it will fail when running the test).
* For the class <tt>org/apache/Whatever.class</tt> it will return <tt>org/apache/Whatever</tt>. * For the class <tt>org/apache/Whatever.class</tt> it will return <tt>org/apache/Whatever</tt>.
*/ */
private String[] getFilenames(){
private String[] getFilenames() {
Vector v = new Vector(); Vector v = new Vector();
final int size = this.filesets.size(); final int size = this.filesets.size();
for (int j = 0; j < size; j++) { for (int j = 0; j < size; j++) {
@@ -181,7 +181,7 @@ public final class BatchTest extends BaseTest {
* @param filename the filename to "convert" to a classname. * @param filename the filename to "convert" to a classname.
* @return the classname matching the filename. * @return the classname matching the filename.
*/ */
public static final String javaToClass(String filename){
public static final String javaToClass(String filename) {
return filename.replace(File.separatorChar, '.'); return filename.replace(File.separatorChar, '.');
} }


@@ -192,7 +192,7 @@ public final class BatchTest extends BaseTest {
* <tt>JUnitTest</tt>. It must be a fully qualified name. * <tt>JUnitTest</tt>. It must be a fully qualified name.
* @return the <tt>JUnitTest</tt> over the given classname. * @return the <tt>JUnitTest</tt> over the given classname.
*/ */
private JUnitTest createJUnitTest(String classname){
private JUnitTest createJUnitTest(String classname) {
JUnitTest test = new JUnitTest(); JUnitTest test = new JUnitTest();
test.setName(classname); test.setName(classname);
test.setHaltonerror(this.haltOnError); test.setHaltonerror(this.haltOnError);


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java View File

@@ -74,7 +74,7 @@ import org.w3c.dom.Text;
public final class DOMUtil { public final class DOMUtil {


/** unused constructor */ /** unused constructor */
private DOMUtil(){
private DOMUtil() {
} }


/** /**
@@ -98,7 +98,7 @@ public final class DOMUtil {
* @param recurse <tt>true</tt> if you want the list to be made recursively * @param recurse <tt>true</tt> if you want the list to be made recursively
* otherwise <tt>false</tt>. * otherwise <tt>false</tt>.
*/ */
public static NodeList listChildNodes(Node parent, NodeFilter filter, boolean recurse){
public static NodeList listChildNodes(Node parent, NodeFilter filter, boolean recurse) {
NodeListImpl matches = new NodeListImpl(); NodeListImpl matches = new NodeListImpl();
NodeList children = parent.getChildNodes(); NodeList children = parent.getChildNodes();
if (children != null) { if (children != null) {
@@ -122,13 +122,13 @@ public final class DOMUtil {


/** custom implementation of a nodelist */ /** custom implementation of a nodelist */
public static class NodeListImpl extends Vector implements NodeList { public static class NodeListImpl extends Vector implements NodeList {
public int getLength(){
public int getLength() {
return size(); return size();
} }
public Node item(int i){
public Node item(int i) {
try { try {
return (Node) elementAt(i); return (Node) elementAt(i);
} catch (ArrayIndexOutOfBoundsException e){
} catch (ArrayIndexOutOfBoundsException e) {
return null; // conforming to NodeList interface return null; // conforming to NodeList interface
} }
} }
@@ -160,7 +160,7 @@ public final class DOMUtil {
* given name. * given name.
*/ */
public static Element getChildByTagName (Node parent, String tagname) { public static Element getChildByTagName (Node parent, String tagname) {
if (parent == null){
if (parent == null) {
return null; return null;
} }
NodeList childList = parent.getChildNodes(); NodeList childList = parent.getChildNodes();
@@ -187,7 +187,7 @@ public final class DOMUtil {
* appended to <tt>parent</tt>. * appended to <tt>parent</tt>.
* @return the cloned node that is appended to <tt>parent</tt> * @return the cloned node that is appended to <tt>parent</tt>
*/ */
public static final Node importNode(Node parent, Node child){
public static final Node importNode(Node parent, Node child) {
Node copy = null; Node copy = null;
final Document doc = parent.getOwnerDocument(); final Document doc = parent.getOwnerDocument();




+ 14
- 14
src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java View File

@@ -64,8 +64,8 @@ import java.util.NoSuchElementException;
* @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
*/ */
public final class Enumerations { public final class Enumerations {
private Enumerations(){
private Enumerations() {
} }


/** /**
@@ -73,7 +73,7 @@ public final class Enumerations {
* @param array the array of object to enumerate. * @param array the array of object to enumerate.
* @return the enumeration over the array of objects. * @return the enumeration over the array of objects.
*/ */
public static Enumeration fromArray(Object[] array){
public static Enumeration fromArray(Object[] array) {
return new ArrayEnumeration(array); return new ArrayEnumeration(array);
} }


@@ -84,7 +84,7 @@ public final class Enumerations {
* @param enums the array of enumerations. * @param enums the array of enumerations.
* @return the enumeration over the array of enumerations. * @return the enumeration over the array of enumerations.
*/ */
public static Enumeration fromCompound(Enumeration[] enums){
public static Enumeration fromCompound(Enumeration[] enums) {
return new CompoundEnumeration(enums); return new CompoundEnumeration(enums);
} }


@@ -96,18 +96,18 @@ public final class Enumerations {
* @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
*/ */
class ArrayEnumeration implements Enumeration { class ArrayEnumeration implements Enumeration {
/** object array */ /** object array */
private Object[] array; private Object[] array;
/** current index */ /** current index */
private int pos; private int pos;
/** /**
* Initialize a new enumeration that wraps an array. * Initialize a new enumeration that wraps an array.
* @param array the array of object to enumerate. * @param array the array of object to enumerate.
*/ */
public ArrayEnumeration(Object[] array){
public ArrayEnumeration(Object[] array) {
this.array = array; this.array = array;
this.pos = 0; this.pos = 0;
} }
@@ -142,11 +142,11 @@ class ArrayEnumeration implements Enumeration {
* Convenient enumeration over an array of enumeration. For example: * Convenient enumeration over an array of enumeration. For example:
* <pre> * <pre>
* Enumeration e1 = v1.elements(); * Enumeration e1 = v1.elements();
* while (e1.hasMoreElements()){
* while (e1.hasMoreElements()) {
* // do something * // do something
* } * }
* Enumeration e2 = v2.elements(); * Enumeration e2 = v2.elements();
* while (e2.hasMoreElements()){
* while (e2.hasMoreElements()) {
* // do the same thing * // do the same thing
* } * }
* </pre> * </pre>
@@ -154,7 +154,7 @@ class ArrayEnumeration implements Enumeration {
* <pre> * <pre>
* Enumeration[] enums = { v1.elements(), v2.elements() }; * Enumeration[] enums = { v1.elements(), v2.elements() };
* Enumeration e = Enumerations.fromCompound(enums); * Enumeration e = Enumerations.fromCompound(enums);
* while (e.hasMoreElements()){
* while (e.hasMoreElements()) {
* // do something * // do something
* } * }
* </pre> * </pre>
@@ -163,17 +163,17 @@ class ArrayEnumeration implements Enumeration {
* <pre> * <pre>
* Enumeration[] enums = { v1.elements(), null, v2.elements() }; // a null enumeration in the array * Enumeration[] enums = { v1.elements(), null, v2.elements() }; // a null enumeration in the array
* Enumeration e = Enumerations.fromCompound(enums); * Enumeration e = Enumerations.fromCompound(enums);
* while (e.hasMoreElements()){
* while (e.hasMoreElements()) {
* // do something * // do something
* } * }
* </pre> * </pre>
* @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
*/ */
class CompoundEnumeration implements Enumeration { class CompoundEnumeration implements Enumeration {
/** enumeration array */ /** enumeration array */
private Enumeration[] enumArray; private Enumeration[] enumArray;
/** index in the enums array */ /** index in the enums array */
private int index = 0; private int index = 0;




+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -911,7 +911,7 @@ public class JUnitTask extends Task {
* @since Ant 1.2 * @since Ant 1.2
*/ */
protected ExecuteWatchdog createWatchdog() throws BuildException { protected ExecuteWatchdog createWatchdog() throws BuildException {
if (timeout == null){
if (timeout == null) {
return null; return null;
} }
return new ExecuteWatchdog(timeout.intValue()); return new ExecuteWatchdog(timeout.intValue());
@@ -922,7 +922,7 @@ public class JUnitTask extends Task {
* *
* @since Ant 1.3 * @since Ant 1.3
*/ */
protected OutputStream getDefaultOutput(){
protected OutputStream getDefaultOutput() {
return new LogOutputStream(this, Project.MSG_INFO); return new LogOutputStream(this, Project.MSG_INFO);
} }


@@ -932,7 +932,7 @@ public class JUnitTask extends Task {
* *
* @since Ant 1.3 * @since Ant 1.3
*/ */
protected Enumeration getIndividualTests(){
protected Enumeration getIndividualTests() {
final int count = batchTests.size(); final int count = batchTests.size();
final Enumeration[] enums = new Enumeration[ count + 1]; final Enumeration[] enums = new Enumeration[ count + 1];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@@ -954,7 +954,7 @@ public class JUnitTask extends Task {
/** /**
* @since Ant 1.3 * @since Ant 1.3
*/ */
private FormatterElement[] mergeFormatters(JUnitTest test){
private FormatterElement[] mergeFormatters(JUnitTest test) {
Vector feVector = (Vector) formatters.clone(); Vector feVector = (Vector) formatters.clone();
test.addFormattersTo(feVector); test.addFormattersTo(feVector);
FormatterElement[] feArray = new FormatterElement[feVector.size()]; FormatterElement[] feArray = new FormatterElement[feVector.size()];
@@ -968,7 +968,7 @@ public class JUnitTask extends Task {
* *
* @since Ant 1.3 * @since Ant 1.3
*/ */
protected File getOutput(FormatterElement fe, JUnitTest test){
protected File getOutput(FormatterElement fe, JUnitTest test) {
if (fe.getUseFile()) { if (fe.getUseFile()) {
String filename = test.getOutfile() + fe.getExtension(); String filename = test.getOutfile() + fe.getExtension();
File destFile = new File(test.getTodir(), filename); File destFile = new File(test.getTodir(), filename);


+ 15
- 15
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java View File

@@ -76,10 +76,10 @@ import org.apache.tools.ant.Project;
* @see JUnitTestRunner * @see JUnitTestRunner
*/ */
public class JUnitTest extends BaseTest implements Cloneable { public class JUnitTest extends BaseTest implements Cloneable {
/** the name of the test case */ /** the name of the test case */
private String name = null; private String name = null;
/** the name of the result file */ /** the name of the result file */
private String outfile = null; private String outfile = null;


@@ -99,7 +99,7 @@ public class JUnitTest extends BaseTest implements Cloneable {
this.name = name; this.name = name;
} }


public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure,
public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure,
boolean filtertrace) { boolean filtertrace) {
this.name = name; this.name = name;
this.haltOnError = haltOnError; this.haltOnError = haltOnError;
@@ -107,7 +107,7 @@ public class JUnitTest extends BaseTest implements Cloneable {
this.filtertrace = filtertrace; this.filtertrace = filtertrace;
} }


/**
/**
* Set the name of the test class. * Set the name of the test class.
*/ */
public void setName(String value) { public void setName(String value) {
@@ -121,7 +121,7 @@ public class JUnitTest extends BaseTest implements Cloneable {
outfile = value; outfile = value;
} }


/**
/**
* Get the name of the test class. * Get the name of the test class.
*/ */
public String getName() { public String getName() {
@@ -130,7 +130,7 @@ public class JUnitTest extends BaseTest implements Cloneable {


/** /**
* Get the name of the output file * Get the name of the output file
*
*
* @return the name of the output file. * @return the name of the output file.
*/ */
public String getOutfile() { public String getOutfile() {
@@ -150,15 +150,15 @@ public class JUnitTest extends BaseTest implements Cloneable {
public long runCount() { public long runCount() {
return runs; return runs;
} }
public long failureCount() { public long failureCount() {
return failures; return failures;
} }
public long errorCount() { public long errorCount() {
return errors; return errors;
} }
public long getRunTime() { public long getRunTime() {
return runTime; return runTime;
} }
@@ -166,9 +166,9 @@ public class JUnitTest extends BaseTest implements Cloneable {
public Properties getProperties() { public Properties getProperties() {
return props; return props;
} }
public void setProperties(Hashtable p) {
props = new Properties();
public void setProperties(Hashtable p) {
props = new Properties();
for (Enumeration enum = p.keys(); enum.hasMoreElements();) { for (Enumeration enum = p.keys(); enum.hasMoreElements();) {
Object key = enum.nextElement(); Object key = enum.nextElement();
props.put(key, p.get(key)); props.put(key, p.get(key));
@@ -178,7 +178,7 @@ public class JUnitTest extends BaseTest implements Cloneable {
public boolean shouldRun(Project p) { public boolean shouldRun(Project p) {
if (ifProperty != null && p.getProperty(ifProperty) == null) { if (ifProperty != null && p.getProperty(ifProperty) == null) {
return false; return false;
} else if (unlessProperty != null &&
} else if (unlessProperty != null &&
p.getProperty(unlessProperty) != null) { p.getProperty(unlessProperty) != null) {
return false; return false;
} }
@@ -195,9 +195,9 @@ public class JUnitTest extends BaseTest implements Cloneable {
/** /**
* Convenient method to add formatters to a vector * Convenient method to add formatters to a vector
*/ */
void addFormattersTo(Vector v){
void addFormattersTo(Vector v) {
final int count = formatters.size(); final int count = formatters.size();
for (int i = 0; i < count; i++){
for (int i = 0; i < count; i++) {
v.addElement(formatters.elementAt(i)); v.addElement(formatters.elementAt(i));
} }
} }


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java View File

@@ -247,7 +247,7 @@ public class JUnitTestRunner implements TestListener {
// know exactly what is the cause, but we're doing exactly // know exactly what is the cause, but we're doing exactly
// the same as JUnit TestRunner do. We swallow the exceptions. // the same as JUnit TestRunner do. We swallow the exceptions.
} }
if (suiteMethod != null){
if (suiteMethod != null) {
// if there is a suite method available, then try // if there is a suite method available, then try
// to extract the suite from it. If there is an error // to extract the suite from it. If there is an error
// here it will be caught below and reported. // here it will be caught below and reported.


+ 12
- 12
src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java View File

@@ -114,7 +114,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
/** /**
* Generate a report based on the document created by the merge. * Generate a report based on the document created by the merge.
*/ */
public AggregateTransformer createReport(){
public AggregateTransformer createReport() {
AggregateTransformer transformer = new AggregateTransformer(this); AggregateTransformer transformer = new AggregateTransformer(this);
transformers.addElement(transformer); transformers.addElement(transformer);
return transformer; return transformer;
@@ -126,7 +126,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
* @param value the name of the file. * @param value the name of the file.
* @see #setTodir(File) * @see #setTodir(File)
*/ */
public void setTofile(String value){
public void setTofile(String value) {
toFile = value; toFile = value;
} }


@@ -137,7 +137,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
* @param value the directory where to write the results, absolute or * @param value the directory where to write the results, absolute or
* relative. * relative.
*/ */
public void setTodir(File value){
public void setTodir(File value) {
toDir = value; toDir = value;
} }


@@ -161,7 +161,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
// write the document // write the document
try { try {
writeDOMTree(rootElement.getOwnerDocument(), destFile); writeDOMTree(rootElement.getOwnerDocument(), destFile);
} catch (IOException e){
} catch (IOException e) {
throw new BuildException("Unable to write test aggregate to '" + destFile + "'", e); throw new BuildException("Unable to write test aggregate to '" + destFile + "'", e);
} }
// apply transformation // apply transformation
@@ -179,11 +179,11 @@ public class XMLResultAggregator extends Task implements XMLConstants {
* the <tt>todir</tt> and <tt>tofile</tt> attributes. * the <tt>todir</tt> and <tt>tofile</tt> attributes.
* @return the destination file where should be written the result file. * @return the destination file where should be written the result file.
*/ */
protected File getDestinationFile(){
if (toFile == null){
protected File getDestinationFile() {
if (toFile == null) {
toFile = DEFAULT_FILENAME; toFile = DEFAULT_FILENAME;
} }
if (toDir == null){
if (toDir == null) {
toDir = getProject().resolveFile(DEFAULT_DIR); toDir = getProject().resolveFile(DEFAULT_DIR);
} }
return new File(toDir, toFile); return new File(toDir, toFile);
@@ -235,7 +235,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
(new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " ");
wri.flush(); wri.flush();
// writers do not throw exceptions, so check for them. // writers do not throw exceptions, so check for them.
if (wri.checkError()){
if (wri.checkError()) {
throw new IOException("Error while writing DOM content"); throw new IOException("Error while writing DOM content");
} }
} finally { } finally {
@@ -270,7 +270,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
//XXX there seems to be a bug in xerces 1.3.0 that doesn't like file object //XXX there seems to be a bug in xerces 1.3.0 that doesn't like file object
// will investigate later. It does not use the given directory but // will investigate later. It does not use the given directory but
// the vm dir instead ? Works fine with crimson. // the vm dir instead ? Works fine with crimson.
Document testsuiteDoc
Document testsuiteDoc
= builder.parse("file:///" + files[i].getAbsolutePath()); = builder.parse("file:///" + files[i].getAbsolutePath());
Element elem = testsuiteDoc.getDocumentElement(); Element elem = testsuiteDoc.getDocumentElement();
// make sure that this is REALLY a testsuite. // make sure that this is REALLY a testsuite.
@@ -280,12 +280,12 @@ public class XMLResultAggregator extends Task implements XMLConstants {
// issue a warning. // issue a warning.
log("the file " + files[i] + " is not a valid testsuite XML document", Project.MSG_WARN); log("the file " + files[i] + " is not a valid testsuite XML document", Project.MSG_WARN);
} }
} catch (SAXException e){
} catch (SAXException e) {
// a testcase might have failed and write a zero-length document, // a testcase might have failed and write a zero-length document,
// It has already failed, but hey.... mm. just put a warning // It has already failed, but hey.... mm. just put a warning
log("The file " + files[i] + " is not a valid XML document. It is possibly corrupted.", Project.MSG_WARN); log("The file " + files[i] + " is not a valid XML document. It is possibly corrupted.", Project.MSG_WARN);
log(StringUtils.getStackTrace(e), Project.MSG_DEBUG); log(StringUtils.getStackTrace(e), Project.MSG_DEBUG);
} catch (IOException e){
} catch (IOException e) {
log("Error while accessing file " + files[i] + ": " + e.getMessage(), Project.MSG_ERR); log("Error while accessing file " + files[i] + ": " + e.getMessage(), Project.MSG_ERR);
} }
} }
@@ -304,7 +304,7 @@ public class XMLResultAggregator extends Task implements XMLConstants {
* modify the original node to change the name attribute and add * modify the original node to change the name attribute and add
* a package one. * a package one.
*/ */
protected void addTestSuite(Element root, Element testsuite){
protected void addTestSuite(Element root, Element testsuite) {
String fullclassname = testsuite.getAttribute(ATTR_NAME); String fullclassname = testsuite.getAttribute(ATTR_NAME);
int pos = fullclassname.lastIndexOf('.'); int pos = fullclassname.lastIndexOf('.');




+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java View File

@@ -76,13 +76,13 @@ abstract class XalanExecutor {
protected AggregateTransformer caller; protected AggregateTransformer caller;


/** set the caller for this object. */ /** set the caller for this object. */
private final void setCaller(AggregateTransformer caller){
private final void setCaller(AggregateTransformer caller) {
this.caller = caller; this.caller = caller;
} }


/** get the appropriate stream based on the format (frames/noframes) */ /** get the appropriate stream based on the format (frames/noframes) */
protected OutputStream getOutputStream() throws IOException { protected OutputStream getOutputStream() throws IOException {
if (AggregateTransformer.FRAMES.equals(caller.format)){
if (AggregateTransformer.FRAMES.equals(caller.format)) {
// dummy output for the framed report // dummy output for the framed report
// it's all done by extension... // it's all done by extension...
return new ByteArrayOutputStream(); return new ByteArrayOutputStream();
@@ -109,7 +109,7 @@ abstract class XalanExecutor {
procVersion = Class.forName("org.apache.xalan.processor.XSLProcessorVersion"); procVersion = Class.forName("org.apache.xalan.processor.XSLProcessorVersion");
executor = (XalanExecutor) Class.forName( executor = (XalanExecutor) Class.forName(
"org.apache.tools.ant.taskdefs.optional.junit.Xalan2Executor").newInstance(); "org.apache.tools.ant.taskdefs.optional.junit.Xalan2Executor").newInstance();
} catch (Exception xalan2missing){
} catch (Exception xalan2missing) {
StringWriter swr = new StringWriter(); StringWriter swr = new StringWriter();
xalan2missing.printStackTrace(new PrintWriter(swr)); xalan2missing.printStackTrace(new PrintWriter(swr));
caller.task.log("Didn't find Xalan2.", Project.MSG_DEBUG); caller.task.log("Didn't find Xalan2.", Project.MSG_DEBUG);
@@ -118,7 +118,7 @@ abstract class XalanExecutor {
procVersion = Class.forName("org.apache.xalan.xslt.XSLProcessorVersion"); procVersion = Class.forName("org.apache.xalan.xslt.XSLProcessorVersion");
executor = (XalanExecutor) Class.forName( executor = (XalanExecutor) Class.forName(
"org.apache.tools.ant.taskdefs.optional.junit.Xalan1Executor").newInstance(); "org.apache.tools.ant.taskdefs.optional.junit.Xalan1Executor").newInstance();
} catch (Exception xalan1missing){
} catch (Exception xalan1missing) {
swr = new StringWriter(); swr = new StringWriter();
xalan1missing.printStackTrace(new PrintWriter(swr)); xalan1missing.printStackTrace(new PrintWriter(swr));
caller.task.log("Didn't find Xalan1.", Project.MSG_DEBUG); caller.task.log("Didn't find Xalan1.", Project.MSG_DEBUG);
@@ -137,7 +137,7 @@ abstract class XalanExecutor {
try { try {
Field f = procVersion.getField("S_VERSION"); Field f = procVersion.getField("S_VERSION");
return f.get(null).toString(); return f.get(null).toString();
} catch (Exception e){
} catch (Exception e) {
return "?"; return "?";
} }
} }


+ 16
- 16
src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java View File

@@ -70,7 +70,7 @@ import org.apache.tools.ant.types.Path;
* <p> * <p>
* <i>maudit</i> performs static analysis of the Java source code and byte code files to find and report * <i>maudit</i> performs static analysis of the Java source code and byte code files to find and report
* errors of style and potential problems related to performance, maintenance and robustness. * errors of style and potential problems related to performance, maintenance and robustness.
* As a convenience, a stylesheet is given in <tt>etc</tt> directory, so that an HTML report
* As a convenience, a stylesheet is given in <tt>etc</tt> directory, so that an HTML report
* can be generated from the XML file. * can be generated from the XML file.
* *
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
@@ -135,16 +135,16 @@ public class MAudit extends AbstractMetamataTask {
super("com.metamata.gui.rc.MAudit"); super("com.metamata.gui.rc.MAudit");
} }


/**
/**
* The XML file to which the Audit result should be written to; required * The XML file to which the Audit result should be written to; required
*/ */
public void setTofile(File outFile) { public void setTofile(File outFile) {
this.outFile = outFile; this.outFile = outFile;
} }


/** /**
* Automatically fix certain errors
* Automatically fix certain errors
* (those marked as fixable in the manual); * (those marked as fixable in the manual);
* optional, default=false * optional, default=false
*/ */
@@ -153,7 +153,7 @@ public class MAudit extends AbstractMetamataTask {
} }


/** /**
* Creates listing file for each audited file; optional, default false.
* Creates listing file for each audited file; optional, default false.
* When set, a .maudit file will be generated in the * When set, a .maudit file will be generated in the
* same location as the source file. * same location as the source file.
*/ */
@@ -162,9 +162,9 @@ public class MAudit extends AbstractMetamataTask {
} }


/** /**
* Finds declarations unused in search paths; optional, default false.
* Finds declarations unused in search paths; optional, default false.
* It will look for unused global declarations * It will look for unused global declarations
* in the source code within a use domain specified by the
* in the source code within a use domain specified by the
* <tt>searchpath</tt> element. * <tt>searchpath</tt> element.
*/ */
public void setUnused(boolean flag) { public void setUnused(boolean flag) {
@@ -181,7 +181,7 @@ public class MAudit extends AbstractMetamataTask {
} }


/** /**
* flag to tell the task to exit after the first error.
* flag to tell the task to exit after the first error.
* internal/testing only * internal/testing only
* @ant.attribute ignore="true" * @ant.attribute ignore="true"
*/ */
@@ -214,9 +214,9 @@ public class MAudit extends AbstractMetamataTask {
this.fullsemanticize = flag; this.fullsemanticize = flag;
} }


/**
/**
* classpath for additional audit rules * classpath for additional audit rules
* these must be placed before metamata.jar !!
* these must be placed before metamata.jar !!
*/ */
public Path createRulespath() { public Path createRulespath() {
if (rulesPath == null) { if (rulesPath == null) {
@@ -225,9 +225,9 @@ public class MAudit extends AbstractMetamataTask {
return rulesPath; return rulesPath;
} }


/**
* search path to use for unused global declarations;
* required when <tt>unused</tt> is set.
/**
* search path to use for unused global declarations;
* required when <tt>unused</tt> is set.
*/ */
public Path createSearchpath() { public Path createSearchpath() {
if (searchPath == null) { if (searchPath == null) {
@@ -333,10 +333,10 @@ public class MAudit extends AbstractMetamataTask {
} catch (IOException e) { } catch (IOException e) {
throw new BuildException(e); throw new BuildException(e);
} finally { } finally {
if (out == null){
if (out == null) {
try { try {
out.close(); out.close();
} catch (IOException e){
} catch (IOException e) {
} }
} }
} }
@@ -350,7 +350,7 @@ public class MAudit extends AbstractMetamataTask {
// the .maudit files match the .java files // the .maudit files match the .java files
// we'll use includedFiles to get the .maudit files. // we'll use includedFiles to get the .maudit files.


/*if (out != null){
/*if (out != null) {
// close it if not closed by the handler... // close it if not closed by the handler...
}*/ }*/
} }


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAuditParser.java View File

@@ -82,7 +82,7 @@ final class MAuditParser {
/** matcher that will be used to extract the info from the line */ /** matcher that will be used to extract the info from the line */
private final RegexpMatcher matcher; private final RegexpMatcher matcher;


MAuditParser(){
MAuditParser() {
/** the matcher should be the Oro one. I don't know about the other one */ /** the matcher should be the Oro one. I don't know about the other one */
matcher = (new RegexpMatcherFactory()).newRegexpMatcher(); matcher = (new RegexpMatcherFactory()).newRegexpMatcher();
matcher.setPattern(AUDIT_PATTERN); matcher.setPattern(AUDIT_PATTERN);
@@ -95,9 +95,9 @@ final class MAuditParser {
* or <tt>null</tt> if it could not parse it. (might be a * or <tt>null</tt> if it could not parse it. (might be a
* message info or copyright or summary). * message info or copyright or summary).
*/ */
Violation parseLine(String line){
Violation parseLine(String line) {
Vector matches = matcher.getGroups(line); Vector matches = matcher.getGroups(line);
if (matches == null){
if (matches == null) {
return null; return null;
} }
final String file = (String) matches.elementAt(1); final String file = (String) matches.elementAt(1);


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAuditStreamHandler.java View File

@@ -205,7 +205,7 @@ class MAuditStreamHandler implements ExecuteStreamHandler {
DOMElementWriter domWriter = new DOMElementWriter(); DOMElementWriter domWriter = new DOMElementWriter();
try { try {
domWriter.write(rootElement, xmlOut); domWriter.write(rootElement, xmlOut);
} catch (IOException e){
} catch (IOException e) {
throw new BuildException(e); throw new BuildException(e);
} }
} }


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/metamata/MMetricsStreamHandler.java View File

@@ -413,7 +413,7 @@ class MetricsElement {
while ((pos = line.indexOf('\t')) != -1) { while ((pos = line.indexOf('\t')) != -1) {
String token = line.substring(0, pos); String token = line.substring(0, pos);
// only parse what coudl be a valid number. ie not constructs nor no value // only parse what coudl be a valid number. ie not constructs nor no value
/*if (metrics.size() != 0 || token.length() != 0){
/*if (metrics.size() != 0 || token.length() != 0) {
Number num = METAMATA_NF.parse(token); // parse with Metamata NF Number num = METAMATA_NF.parse(token); // parse with Metamata NF
token = NEUTRAL_NF.format(num.doubleValue()); // and format with a neutral NF token = NEUTRAL_NF.format(num.doubleValue()); // and format with a neutral NF
}*/ }*/


+ 21
- 21
src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java View File

@@ -93,17 +93,17 @@ public class MParse extends AbstractMetamataTask {
} }


/** set verbose mode */ /** set verbose mode */
public void setVerbose(boolean flag){
public void setVerbose(boolean flag) {
verbose = flag; verbose = flag;
} }


/** set scanner debug mode; optional, default false */ /** set scanner debug mode; optional, default false */
public void setDebugscanner(boolean flag){
public void setDebugscanner(boolean flag) {
debugscanner = flag; debugscanner = flag;
} }


/** set parser debug mode; optional, default false */ /** set parser debug mode; optional, default false */
public void setDebugparser(boolean flag){
public void setDebugparser(boolean flag) {
debugparser = flag; debugparser = flag;
} }


@@ -132,7 +132,7 @@ public class MParse extends AbstractMetamataTask {
} }


/** return the default stream handler for this task */ /** return the default stream handler for this task */
protected ExecuteStreamHandler createStreamHandler(){
protected ExecuteStreamHandler createStreamHandler() {
return new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_INFO); return new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_INFO);
} }


@@ -145,7 +145,7 @@ public class MParse extends AbstractMetamataTask {
// set the classpath as the jar files // set the classpath as the jar files
File[] jars = getMetamataLibs(); File[] jars = getMetamataLibs();
final Path classPath = cmdl.createClasspath(getProject()); final Path classPath = cmdl.createClasspath(getProject());
for (int i = 0; i < jars.length; i++){
for (int i = 0; i < jars.length; i++) {
classPath.createPathElement().setLocation(jars[i]); classPath.createPathElement().setLocation(jars[i]);
} }


@@ -186,14 +186,14 @@ public class MParse extends AbstractMetamataTask {
if (process.execute() != 0) { if (process.execute() != 0) {
throw new BuildException("Metamata task failed."); throw new BuildException("Metamata task failed.");
} }
} catch (IOException e){
} catch (IOException e) {
throw new BuildException("Failed to launch Metamata task: ", e); throw new BuildException("Failed to launch Metamata task: ", e);
} }
} }


/** clean up all the mess that we did with temporary objects */ /** clean up all the mess that we did with temporary objects */
protected void cleanUp(){
if (optionsFile != null){
protected void cleanUp() {
if (optionsFile != null) {
optionsFile.delete(); optionsFile.delete();
optionsFile = null; optionsFile = null;
} }
@@ -216,7 +216,7 @@ public class MParse extends AbstractMetamataTask {
* forked process do it for you. * forked process do it for you.
* @return array of jars/zips needed to run metamata. * @return array of jars/zips needed to run metamata.
*/ */
protected File[] getMetamataLibs(){
protected File[] getMetamataLibs() {
Vector files = new Vector(); Vector files = new Vector();
files.addElement(new File(metamataHome, "lib/metamata.jar")); files.addElement(new File(metamataHome, "lib/metamata.jar"));
files.addElement(new File(metamataHome, "bin/lib/JavaCC.zip")); files.addElement(new File(metamataHome, "bin/lib/JavaCC.zip"));
@@ -233,15 +233,15 @@ public class MParse extends AbstractMetamataTask {
*/ */
protected void checkOptions() throws BuildException { protected void checkOptions() throws BuildException {
// check that the home is ok. // check that the home is ok.
if (metamataHome == null || !metamataHome.exists()){
if (metamataHome == null || !metamataHome.exists()) {
throw new BuildException("'metamatahome' must point to Metamata home directory."); throw new BuildException("'metamatahome' must point to Metamata home directory.");
} }
metamataHome = getProject().resolveFile(metamataHome.getPath()); metamataHome = getProject().resolveFile(metamataHome.getPath());


// check that the needed jar exists. // check that the needed jar exists.
File[] jars = getMetamataLibs(); File[] jars = getMetamataLibs();
for (int i = 0; i < jars.length; i++){
if (!jars[i].exists()){
for (int i = 0; i < jars.length; i++) {
if (!jars[i].exists()) {
throw new BuildException(jars[i] throw new BuildException(jars[i]
+ " does not exist. Check your metamata installation."); + " does not exist. Check your metamata installation.");
} }
@@ -261,20 +261,20 @@ public class MParse extends AbstractMetamataTask {
*/ */
protected Vector getOptions() { protected Vector getOptions() {
Vector options = new Vector(); Vector options = new Vector();
if (verbose){
if (verbose) {
options.addElement("-verbose"); options.addElement("-verbose");
} }
if (debugscanner){
if (debugscanner) {
options.addElement("-ds"); options.addElement("-ds");
} }
if (debugparser){
if (debugparser) {
options.addElement("-dp"); options.addElement("-dp");
} }
if (classPath != null){
if (classPath != null) {
options.addElement("-classpath"); options.addElement("-classpath");
options.addElement(classPath.toString()); options.addElement(classPath.toString());
} }
if (sourcePath != null){
if (sourcePath != null) {
options.addElement("-sourcepath"); options.addElement("-sourcepath");
options.addElement(sourcePath.toString()); options.addElement(sourcePath.toString());
} }
@@ -294,17 +294,17 @@ public class MParse extends AbstractMetamataTask {
try { try {
fw = new FileWriter(tofile); fw = new FileWriter(tofile);
PrintWriter pw = new PrintWriter(fw); PrintWriter pw = new PrintWriter(fw);
for (int i = 0; i < options.length; i++){
for (int i = 0; i < options.length; i++) {
pw.println(options[i]); pw.println(options[i]);
} }
pw.flush(); pw.flush();
} catch (IOException e){
} catch (IOException e) {
throw new BuildException("Error while writing options file " + tofile, e); throw new BuildException("Error while writing options file " + tofile, e);
} finally { } finally {
if (fw != null){
if (fw != null) {
try { try {
fw.close(); fw.close();
} catch (IOException ignored){}
} catch (IOException ignored) {}
} }
} }
} }


+ 8
- 8
src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java View File

@@ -135,7 +135,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
try { try {
audioInputStream = AudioSystem.getAudioInputStream(file); audioInputStream = AudioSystem.getAudioInputStream(file);
} catch (UnsupportedAudioFileException uafe) { } catch (UnsupportedAudioFileException uafe) {
project.log("Audio format is not yet supported: "
project.log("Audio format is not yet supported: "
+ uafe.getMessage()); + uafe.getMessage());
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
@@ -205,7 +205,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
/** /**
* Fired before any targets are started. * Fired before any targets are started.
*/ */
public void buildStarted(BuildEvent event){
public void buildStarted(BuildEvent event) {
} }


/** /**
@@ -214,7 +214,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* *
* @see BuildEvent#getException() * @see BuildEvent#getException()
*/ */
public void buildFinished(BuildEvent event){
public void buildFinished(BuildEvent event) {
if (event.getException() == null && fileSuccess != null) { if (event.getException() == null && fileSuccess != null) {
// build successfull! // build successfull!
play(event.getProject(), fileSuccess, loopsSuccess, durationSuccess); play(event.getProject(), fileSuccess, loopsSuccess, durationSuccess);
@@ -228,7 +228,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* *
* @see BuildEvent#getTarget() * @see BuildEvent#getTarget()
*/ */
public void targetStarted(BuildEvent event){
public void targetStarted(BuildEvent event) {
} }


/** /**
@@ -237,7 +237,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* *
* @see BuildEvent#getException() * @see BuildEvent#getException()
*/ */
public void targetFinished(BuildEvent event){
public void targetFinished(BuildEvent event) {
} }


/** /**
@@ -245,7 +245,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* *
* @see BuildEvent#getTask() * @see BuildEvent#getTask()
*/ */
public void taskStarted(BuildEvent event){
public void taskStarted(BuildEvent event) {
} }


/** /**
@@ -254,7 +254,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* *
* @see BuildEvent#getException() * @see BuildEvent#getException()
*/ */
public void taskFinished(BuildEvent event){
public void taskFinished(BuildEvent event) {
} }


/** /**
@@ -263,7 +263,7 @@ public class AntSoundPlayer implements LineListener, BuildListener {
* @see BuildEvent#getMessage() * @see BuildEvent#getMessage()
* @see BuildEvent#getPriority() * @see BuildEvent#getPriority()
*/ */
public void messageLogged(BuildEvent event){
public void messageLogged(BuildEvent event) {
} }
} }



+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java View File

@@ -105,7 +105,7 @@ public class SoundTask extends Task {
public SoundTask() { public SoundTask() {
} }


public void init(){
public void init() {
} }


public void execute() { public void execute() {


+ 10
- 10
src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashScreen.java View File

@@ -82,13 +82,13 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
init(null); init(null);
setText(msg); setText(msg);
} }
public SplashScreen(ImageIcon img) { public SplashScreen(ImageIcon img) {
init(img); init(img);
} }


protected void init(ImageIcon img) { protected void init(ImageIcon img) {
JPanel pan = (JPanel) getContentPane(); JPanel pan = (JPanel) getContentPane();
JLabel piccy; JLabel piccy;
if (img == null) { if (img == null) {
@@ -96,7 +96,7 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
} else { } else {
piccy = new JLabel(img); piccy = new JLabel(img);
} }
piccy.setBorder(BorderFactory.createLineBorder(Color.black, 1)); piccy.setBorder(BorderFactory.createLineBorder(Color.black, 1));
text = new JLabel("Building....", JLabel.CENTER); text = new JLabel("Building....", JLabel.CENTER);
text.setFont(new Font("Sans-Serif", Font.BOLD, 12)); text.setFont(new Font("Sans-Serif", Font.BOLD, 12));
@@ -138,16 +138,16 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener {
pb.setValue(total); pb.setValue(total);
} }


public void buildStarted(BuildEvent event){ actionPerformed(null);}
public void buildFinished(BuildEvent event){
public void buildStarted(BuildEvent event) { actionPerformed(null);}
public void buildFinished(BuildEvent event) {
pb.setValue(max); pb.setValue(max);
setVisible(false); setVisible(false);
dispose(); dispose();
} }
public void targetStarted(BuildEvent event){actionPerformed(null);}
public void targetFinished(BuildEvent event){actionPerformed(null);}
public void taskStarted(BuildEvent event){actionPerformed(null);}
public void taskFinished(BuildEvent event){actionPerformed(null);}
public void messageLogged(BuildEvent event){actionPerformed(null);}
public void targetStarted(BuildEvent event) {actionPerformed(null);}
public void targetFinished(BuildEvent event) {actionPerformed(null);}
public void taskStarted(BuildEvent event) {actionPerformed(null);}
public void taskFinished(BuildEvent event) {actionPerformed(null);}
public void messageLogged(BuildEvent event) {actionPerformed(null);}
} }



+ 29
- 29
src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java View File

@@ -64,13 +64,13 @@ import javax.swing.ImageIcon;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
/** /**
* Creates a splash screen. The splash screen is displayed * Creates a splash screen. The splash screen is displayed
* for the duration of the build and includes a handy progress bar as * for the duration of the build and includes a handy progress bar as
* well. Use in conjunction with the sound task to provide interest * well. Use in conjunction with the sound task to provide interest
* whilst waiting for your builds to complete... * whilst waiting for your builds to complete...
* @since Ant1.5
* @since Ant1.5
* @author Les Hughes (leslie.hughes@rubus.com) * @author Les Hughes (leslie.hughes@rubus.com)
*/ */
public class SplashTask extends Task { public class SplashTask extends Task {
@@ -92,10 +92,10 @@ public class SplashTask extends Task {
public void setImageURL(String imgurl) { public void setImageURL(String imgurl) {
this.imgurl = imgurl; this.imgurl = imgurl;
} }
/** /**
* flag to enable proxy settings; optional, deprecated : consider * flag to enable proxy settings; optional, deprecated : consider
* using &lt;setproxy&gt; instead
* using &lt;setproxy&gt; instead
* @deprecated use org.apache.tools.ant.taskdefs.optional.SetProxy * @deprecated use org.apache.tools.ant.taskdefs.optional.SetProxy
*/ */
public void setUseproxy(boolean useProxy) { public void setUseproxy(boolean useProxy) {
@@ -105,31 +105,31 @@ public class SplashTask extends Task {
/** /**
* name of proxy; optional. * name of proxy; optional.
*/ */
public void setProxy(String proxy){
public void setProxy(String proxy) {
this.proxy = proxy; this.proxy = proxy;
} }
/** /**
* Proxy port; optional, default 80.
* Proxy port; optional, default 80.
*/ */
public void setPort(String port){
public void setPort(String port) {
this.port = port; this.port = port;
} }


/** /**
* Proxy user; optional, default =none.
* Proxy user; optional, default =none.
*/ */
public void setUser(String user){
public void setUser(String user) {
this.user = user; this.user = user;
} }
/** /**
* Proxy password; required if <tt>user</tt> is set. * Proxy password; required if <tt>user</tt> is set.
*/ */
public void setPassword(String password){
public void setPassword(String password) {
this.password = password; this.password = password;
} }
/** /**
* how long to show the splash screen in milliseconds, * how long to show the splash screen in milliseconds,
* optional; default 5000 ms. * optional; default 5000 ms.
@@ -137,7 +137,7 @@ public class SplashTask extends Task {
public void setShowduration(int duration) { public void setShowduration(int duration) {
this.showDuration = duration; this.showDuration = duration;
} }


public void execute() throws BuildException { public void execute() throws BuildException {
if (splash != null) { if (splash != null) {
@@ -146,33 +146,33 @@ public class SplashTask extends Task {
splash.dispose(); splash.dispose();
splash = null; splash = null;
} }
log("Creating new SplashScreen", Project.MSG_VERBOSE); log("Creating new SplashScreen", Project.MSG_VERBOSE);
InputStream in = null; InputStream in = null;


if (imgurl != null) { if (imgurl != null) {
try { try {
URLConnection conn = null; URLConnection conn = null;
if (useProxy && if (useProxy &&
(proxy != null && proxy.length() > 0) && (proxy != null && proxy.length() > 0) &&
(port != null && port.length() > 0)) { (port != null && port.length() > 0)) {
log("Using proxied Connection", Project.MSG_DEBUG); log("Using proxied Connection", Project.MSG_DEBUG);
System.getProperties().put("http.proxySet", "true"); System.getProperties().put("http.proxySet", "true");
System.getProperties().put("http.proxyHost", proxy); System.getProperties().put("http.proxyHost", proxy);
System.getProperties().put("http.proxyPort", port); System.getProperties().put("http.proxyPort", port);
URL url = new URL(imgurl); URL url = new URL(imgurl);
conn = url.openConnection(); conn = url.openConnection();
if (user != null && user.length() > 0) { if (user != null && user.length() > 0) {
String encodedcreds =
String encodedcreds =
new sun.misc.BASE64Encoder().encode((new String(user + ":" + password)).getBytes()); new sun.misc.BASE64Encoder().encode((new String(user + ":" + password)).getBytes());
conn.setRequestProperty("Proxy-Authorization",
conn.setRequestProperty("Proxy-Authorization",
encodedcreds); encodedcreds);
} }
} else { } else {
System.getProperties().put("http.proxySet", "false"); System.getProperties().put("http.proxySet", "false");
System.getProperties().put("http.proxyHost", ""); System.getProperties().put("http.proxyHost", "");
@@ -183,16 +183,16 @@ public class SplashTask extends Task {
} }
conn.setDoInput(true); conn.setDoInput(true);
conn.setDoOutput(false); conn.setDoOutput(false);
in = conn.getInputStream(); in = conn.getInputStream();


// Catch everything - some of the above return nulls, throw exceptions or generally misbehave // Catch everything - some of the above return nulls, throw exceptions or generally misbehave
// in the event of a problem etc // in the event of a problem etc
} catch (Throwable ioe) { } catch (Throwable ioe) {
log("Unable to download image, trying default Ant Logo",
log("Unable to download image, trying default Ant Logo",
Project.MSG_DEBUG); Project.MSG_DEBUG);
log("(Exception was \"" + ioe.getMessage() + "\"",
log("(Exception was \"" + ioe.getMessage() + "\"",
Project.MSG_DEBUG); Project.MSG_DEBUG);
} }
} }
@@ -210,10 +210,10 @@ public class SplashTask extends Task {
while ((data = din.read()) != -1) { while ((data = din.read()) != -1) {
bout.write((byte) data); bout.write((byte) data);
} }
log("Got ByteArray, creating splash", Project.MSG_DEBUG); log("Got ByteArray, creating splash", Project.MSG_DEBUG);
ImageIcon img = new ImageIcon(bout.toByteArray()); ImageIcon img = new ImageIcon(bout.toByteArray());
splash = new SplashScreen(img); splash = new SplashScreen(img);
success = true; success = true;
} catch (Exception e) { } catch (Exception e) {
@@ -240,6 +240,6 @@ public class SplashTask extends Task {
Thread.currentThread().sleep(showDuration); Thread.currentThread().sleep(showDuration);
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
} }
} }

+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java View File

@@ -256,7 +256,7 @@ public class Symlink extends Task {
linksToStore.put(alink.getName(), linksToStore.put(alink.getName(),
alink.getCanonicalPath()); alink.getCanonicalPath());
} catch (IOException ioe) { } catch (IOException ioe) {
handleError("Couldn't get canonical "
handleError("Couldn't get canonical "
+ "name of a parent link"); + "name of a parent link");
} }
} }
@@ -541,7 +541,7 @@ public class Symlink extends Task {
return; return;
} }
if (link == null) { if (link == null) {
handleError("Must define the link "
handleError("Must define the link "
+ "name for symlink!"); + "name for symlink!");
return; return;
} }
@@ -573,7 +573,7 @@ public class Symlink extends Task {
* Simultaneously get included directories and included files. * Simultaneously get included directories and included files.
* *
* @param ds The scanner with which to get the files and directories. * @param ds The scanner with which to get the files and directories.
* @return A vector of <code>String</code> objects containing the
* @return A vector of <code>String</code> objects containing the
* included file names and directory names. * included file names and directory names.
*/ */


@@ -772,7 +772,7 @@ public class Symlink extends Task {


// loop through the files identified by each file set // loop through the files identified by each file set
// and load their contents. // and load their contents.
for (int j = 0; j < includedFiles.length; j++){
for (int j = 0; j < includedFiles.length; j++) {
File inc = new File(workingDir + File.separator File inc = new File(workingDir + File.separator
+ includedFiles[j]); + includedFiles[j]);
String inDir; String inDir;


+ 7
- 9
src/main/org/apache/tools/ant/types/optional/ScriptFilter.java View File

@@ -73,10 +73,7 @@ import org.apache.tools.ant.BuildException;
* The script is meant to use get self.token and * The script is meant to use get self.token and
* set self.token in the reply. * set self.token in the reply.
*/ */

public class ScriptFilter
extends TokenFilter.ChainableReaderFilter
{
public class ScriptFilter extends TokenFilter.ChainableReaderFilter {
/** The language - attribute of element */ /** The language - attribute of element */
private String language; private String language;
/** The script - inline text or external file */ /** The script - inline text or external file */
@@ -132,12 +129,14 @@ public class ScriptFilter
* @exception BuildException if someting goes wrong * @exception BuildException if someting goes wrong
*/ */
private void init() throws BuildException { private void init() throws BuildException {
if (initialized)
if (initialized) {
return; return;
}
initialized = true; initialized = true;
if (language == null)
if (language == null) {
throw new BuildException( throw new BuildException(
"scriptfilter: language is not defined"); "scriptfilter: language is not defined");
}


try { try {
addBeans(getProject().getProperties()); addBeans(getProject().getProperties());
@@ -151,14 +150,13 @@ public class ScriptFilter


manager = new BSFManager (); manager = new BSFManager ();


for (Enumeration e = beans.keys() ; e.hasMoreElements() ;) {
for (Enumeration e = beans.keys(); e.hasMoreElements();) {
String key = (String) e.nextElement(); String key = (String) e.nextElement();
Object value = beans.get(key); Object value = beans.get(key);
manager.declareBean(key, value, value.getClass()); manager.declareBean(key, value, value.getClass());
} }


}
catch (BSFException e) {
} catch (BSFException e) {
Throwable t = e; Throwable t = e;
Throwable te = e.getTargetException(); Throwable te = e.getTargetException();
if (te != null) { if (te != null) {


Loading…
Cancel
Save