Browse Source

Remove direct call to deprecated project, location, tasktype Task field,

replaced by an accessor way into tasks.
Remove too some unused variable declaration and some unused imports.
PR: 22515
Submitted by: Emmanuel Feller ( Emmanuel dot Feller at free dot fr)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275133 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 22 years ago
parent
commit
3396e7c321
23 changed files with 63 additions and 119 deletions
  1. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/Antlib.java
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/BuildNumber.java
  3. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/Classloader.java
  4. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/Concat.java
  5. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/Definer.java
  6. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  7. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  8. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  9. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/PreSetDef.java
  10. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  11. +16
    -43
      src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
  12. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java
  13. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
  14. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
  15. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java
  16. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
  17. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
  18. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java
  19. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/unix/Chown.java
  20. +10
    -33
      src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
  21. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java
  22. +0
    -1
      src/main/org/apache/tools/ant/util/FileUtils.java
  23. +1
    -1
      src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java

+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/Antlib.java View File

@@ -123,7 +123,6 @@ public class Antlib extends Task implements TaskContainer {
// Instance
//
private ClassLoader classLoader;
private String prefix;
private String uri = "";
private List tasks = new ArrayList();



+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/BuildNumber.java View File

@@ -126,7 +126,7 @@ public class BuildNumber

final String header = "Build Number for ANT. Do not edit!";

properties.save(output, header);
properties.store(output, header);
} catch (final IOException ioe) {
final String message = "Error while writing " + myFile;



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

@@ -153,7 +153,7 @@ public class Classloader extends Task {
* the path will be added to the loader.
*/
public void setClasspathRef(Reference pathRef) throws BuildException {
classpath = (Path) pathRef.getReferencedObject(project);
classpath = (Path) pathRef.getReferencedObject(getProject());
}

/**
@@ -180,7 +180,7 @@ public class Classloader extends Task {
public void execute() {
try {
// Gump friendly - don't mess with the core loader if only classpath
if ("only".equals(project.getProperty("build.sysclasspath"))
if ("only".equals(getProject().getProperty("build.sysclasspath"))
&& (name == null || SYSTEM_LOADER_REF.equals(name))) {
log("Changing the system loader is disabled "
+ "by build.sysclasspath=only", Project.MSG_WARN);
@@ -189,7 +189,7 @@ public class Classloader extends Task {

String loaderName = (name == null) ? SYSTEM_LOADER_REF : name;

Object obj = project.getReference(loaderName);
Object obj = getProject().getReference(loaderName);
if (reset) {
// Are any other references held ? Can we 'close' the loader
// so it removes the locks on jars ?
@@ -209,7 +209,7 @@ public class Classloader extends Task {
// Construct a new class loader
Object parent = null;
if (parentName != null) {
parent = project.getReference(parentName);
parent = getProject().getReference(parentName);
if (!(parent instanceof ClassLoader)) {
parent = null;
}
@@ -223,20 +223,20 @@ public class Classloader extends Task {
// The core loader must be reverse
//reverse=true;
}
project.log("Setting parent loader " + name + " "
getProject().log("Setting parent loader " + name + " "
+ parent + " " + parentFirst, Project.MSG_DEBUG);

// The param is "parentFirst"
acl = new AntClassLoader((ClassLoader) parent,
project, classpath, parentFirst);
getProject(), classpath, parentFirst);

project.addReference(loaderName, acl);
getProject().addReference(loaderName, acl);

if (name == null) {
// This allows the core loader to load optional tasks
// without delegating
acl.addLoaderPackageRoot("org.apache.tools.ant.taskdefs.optional");
project.setCoreLoader(acl);
getProject().setCoreLoader(acl);
}
}
if (classpath != null) {


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/Concat.java View File

@@ -780,7 +780,6 @@ public class Concat extends Task {
throws IOException {

int amountRead = 0;
int iOff = off;
while (pos < sourceFiles.size() || (needAddSeparator)) {
if (needAddSeparator) {
cbuf[off] = eolString.charAt(lastPos++);


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/Definer.java View File

@@ -89,7 +89,6 @@ public abstract class Definer extends DefBase {

private int format = Format.PROPERTIES;
private boolean definerSet = false;
private ClassLoader internalClassLoader;
private int onError = OnError.FAIL;
private String adapter;
private String adaptTo;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -677,7 +677,7 @@ public class Execute {
throws IOException {
HashMap logicals = new HashMap();
String logName = null, logValue = null, newLogName;
String line, lineSep = System.getProperty("line.separator");
String line = null;
while ((line = in.readLine()) != null) {
// parse the VMS logicals into required format ("VAR=VAL[,VAL2]")
if (line.startsWith("\t=")) {


+ 2
- 3
src/main/org/apache/tools/ant/taskdefs/FixCRLF.java View File

@@ -437,9 +437,8 @@ public class FixCRLF extends MatchingTask {
} // end of try-catch

} else { // (tabs != ASIS)
int ptr;

while ((ptr = line.getNext()) < linelen) {
while (line.getNext() < linelen) {

switch (lines.getState()) {



+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -79,7 +79,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
public class MacroDef extends Task implements AntlibInterface, TaskContainer {
private UnknownElement nestedTask;
private String name;
private String componentName;
private List attributes = new ArrayList();
private Map elements = new HashMap();
private String uri;


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/PreSetDef.java View File

@@ -80,7 +80,6 @@ import org.apache.tools.ant.UnknownElement;
public class PreSetDef extends Task implements AntlibInterface, TaskContainer {
private UnknownElement nestedTask;
private String name;
private String componentName;
private String uri;

/**


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

@@ -358,19 +358,19 @@ public class SQLExec extends JDBCTask {
if (transactions.size() == 0) {
throw new BuildException("Source file or fileset, "
+ "transactions or sql statement "
+ "must be set!", location);
+ "must be set!", getLocation());
}
}

if (srcFile != null && !srcFile.exists()) {
throw new BuildException("Source file does not exist!", location);
throw new BuildException("Source file does not exist!", getLocation());
}

// deal with the filesets
for (int i = 0; i < filesets.size(); i++) {
FileSet fs = (FileSet) filesets.elementAt(i);
DirectoryScanner ds = fs.getDirectoryScanner(project);
File srcDir = fs.getDir(project);
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File srcDir = fs.getDir(getProject());

String[] srcFiles = ds.getIncludedFiles();

@@ -428,7 +428,7 @@ public class SQLExec extends JDBCTask {
// ignore
}
}
throw new BuildException(e, location);
throw new BuildException(e, getLocation());
} catch (SQLException e) {
if (!isAutocommit() && conn != null && onError.equals("abort")) {
try {
@@ -437,7 +437,7 @@ public class SQLExec extends JDBCTask {
// ignore
}
}
throw new BuildException(e, location);
throw new BuildException(e, getLocation());
} finally {
try {
if (statement != null) {
@@ -473,7 +473,7 @@ public class SQLExec extends JDBCTask {
if (!keepformat) {
line = line.trim();
}
line = project.replaceProperties(line);
line = getProject().replaceProperties(line);
if (!keepformat) {
if (line.startsWith("//")) {
continue;


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

@@ -418,59 +418,32 @@ public class EchoProperties extends Task {
/**
* JDK 1.2 allows for the safer method
* <tt>Properties.store(OutputStream, String)</tt>, which throws an
* <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
* JDK 1.0 compatible method
* <tt>Properties.save(OutputStream, String)</tt> is used instead.
* <tt>IOException</tt> on an output error.
*
*@param props the properties to record
*@param os record the properties to this output stream
*@param header prepend this header to the property output
*@exception IOException on an I/O error during a write. Only thrown
* for JDK 1.2+.
*@exception IOException on an I/O error during a write.
*/
protected void jdkSaveProperties(Properties props, OutputStream os,
String header) throws IOException {
try {
java.lang.reflect.Method m = props.getClass().getMethod(
"store", new Class[]{OutputStream.class, String.class});
m.invoke(props, new Object[]{os, header});
} catch (java.lang.reflect.InvocationTargetException ite) {
Throwable t = ite.getTargetException();
if (t instanceof IOException) {
throw (IOException) t;
}
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}

// not an expected exception. Resort to JDK 1.0 to execute
// this method
jdk10SaveProperties(props, os, header);
} catch (ThreadDeath td) {
// don't trap thread death errors.
throw td;
} catch (Throwable ex) {
// this 'store' method is not available, so resort to the JDK 1.0
// compatible method.
jdk10SaveProperties(props, os, header);
}
try {
props.store(os, header);

} catch (IOException ioe) {
throw new BuildException(ioe, getLocation());
} finally {
if (os != null) {
try {
os.close();
} catch (IOException ioex) {
log("Failed to close output stream");
}
}
}
}


/**
* Save the properties to the output stream using the JDK 1.0 compatible
* method. This won't throw an <tt>IOException</tt> on an output error.
*
*@param props the properties to record
*@param os record the properties to this output stream
*@param header prepend this header to the property output
*/
protected void jdk10SaveProperties(Properties props, OutputStream os,
String header) {
props.save(os, header);
}

/**
* Uses the DocumentBuilderFactory to get a DocumentBuilder instance.
*


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

@@ -172,10 +172,10 @@ public class CCMCheck extends Continuus {
int sizeofFileSet = filesets.size();
for (int i = 0; i < sizeofFileSet; i++) {
FileSet fs = (FileSet) filesets.elementAt(i);
DirectoryScanner ds = fs.getDirectoryScanner(project);
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] srcFiles = ds.getIncludedFiles();
for (int j = 0; j < srcFiles.length; j++) {
File src = new File(fs.getDir(project), srcFiles[j]);
File src = new File(fs.getDir(getProject()), srcFiles[j]);
setFile(src);
doit();
}


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -103,7 +103,7 @@ public abstract class Continuus extends Task {
* @param dir the directory containing the ccm executable
*/
public final void setCcmDir(String dir) {
ccmDir = getProject().translatePath(dir);
ccmDir = Project.translatePath(dir);
}

/**


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java View File

@@ -67,7 +67,6 @@ import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.filters.TokenFilter;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.util.FileUtils;


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

@@ -340,10 +340,12 @@ public class JJTree extends Task {
return (outputDirectory + "/" + optionalOutputFile).replace('\\', '/');
}

/*
* Not used anymore
private boolean isAbsolute(String fileName) {
return (fileName.startsWith("/") || (new File(fileName).isAbsolute()));
}
*/
/**
* When running JJTree from an Ant taskdesk the -OUTPUT_DIRECTORY must
* always be set. But when -OUTPUT_DIRECTORY is set, -OUTPUT_FILE is


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -237,7 +237,7 @@ public class SplashTask extends Task {
splash.toFront();
getProject().addBuildListener(splash);
try {
Thread.currentThread().sleep(showDuration);
Thread.sleep(showDuration);
} catch (InterruptedException e) {
}



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

@@ -107,7 +107,7 @@ public abstract class AbstractAccessTask
* @param cmdl A user supplied command line that we won't accept.
*/
public void setCommand(Commandline cmdl) {
throw new BuildException(taskType
throw new BuildException(getTaskType()
+ " doesn\'t support the command attribute",
getLocation());
}
@@ -119,7 +119,7 @@ public abstract class AbstractAccessTask
* @param skip A user supplied boolean we won't accept.
*/
public void setSkipEmptyFilesets(boolean skip) {
throw new BuildException(taskType + " doesn\'t support the "
throw new BuildException(getTaskType() + " doesn\'t support the "
+ "skipemptyfileset attribute",
getLocation());
}


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

@@ -116,7 +116,7 @@ public class Chgrp extends AbstractAccessTask {
* @param e User supplied executable that we won't accept.
*/
public void setExecutable(String e) {
throw new BuildException(taskType
throw new BuildException(getTaskType()
+ " doesn\'t support the executable"
+ " attribute", getLocation());
}


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -116,7 +116,7 @@ public class Chown extends AbstractAccessTask {
* @param e User supplied executable that we won't accept.
*/
public void setExecutable(String e) {
throw new BuildException(taskType
throw new BuildException(getTaskType()
+ " doesn\'t support the executable"
+ " attribute", getLocation());
}


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

@@ -67,10 +67,8 @@ package org.apache.tools.ant.taskdefs.optional.unix;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;

import java.util.Vector;
@@ -78,9 +76,6 @@ import java.util.Properties;
import java.util.Enumeration;
import java.util.Hashtable;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
@@ -457,13 +452,10 @@ public class Symlink extends Task {
/**
* Writes a properties file.
*
* In jdk 1.2+ this method will use <code>Properties.store</code>
* This method use <code>Properties.store</code>
* and thus report exceptions that occur while writing the file.
* In jdk 1.1 we are forced to use <code>Properties.save</code>
* and therefore all exceptions are masked. This method was lifted
* directly from the Proertyfile task with only slight editing.
* sticking something like this in FileUtils might be
* a good idea to avoid duplication.
*
* This is not jdk 1.1 compatible, but ant 1.6 is not anymore.
*
* @param properties The properties object to be written.
* @param propertyfile The File to write to.
@@ -475,32 +467,17 @@ public class Symlink extends Task {
String comment)
throws BuildException {

BufferedOutputStream bos = null;
FileOutputStream fos = null;
try {
bos = new BufferedOutputStream(new FileOutputStream(propertyfile));

// Properties.store is not available in JDK 1.1
Method m =
Properties.class.getMethod("store",
new Class[] {
OutputStream.class,
String.class});
m.invoke(properties, new Object[] {bos, comment});

} catch (NoSuchMethodException nsme) {
properties.save(bos, comment);
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
throw new BuildException(t, location);
} catch (IllegalAccessException iae) {
// impossible
throw new BuildException(iae, location);
fos = new FileOutputStream(propertyfile);
properties.store(fos, comment);

} catch (IOException ioe) {
throw new BuildException(ioe, location);
throw new BuildException(ioe, getLocation());
} finally {
if (bos != null) {
if (fos != null) {
try {
bos.close();
fos.close();
} catch (IOException ioex) {
log("Failed to close output stream");
}


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

@@ -124,7 +124,7 @@ public class Attrib extends ExecuteOn {
* @ant.attribute ignore="true"
*/
public void setExecutable(String e) {
throw new BuildException(taskType
throw new BuildException(getTaskType()
+ " doesn\'t support the executable attribute", getLocation());
}

@@ -132,7 +132,7 @@ public class Attrib extends ExecuteOn {
* @ant.attribute ignore="true"
*/
public void setCommand(String e) {
throw new BuildException(taskType
throw new BuildException(getTaskType()
+ " doesn\'t support the command attribute", getLocation());
}

@@ -148,7 +148,7 @@ public class Attrib extends ExecuteOn {
* @ant.attribute ignore="true"
*/
public void setSkipEmptyFilesets(boolean skip) {
throw new BuildException(taskType + " doesn\'t support the "
throw new BuildException(getTaskType() + " doesn\'t support the "
+ "skipemptyfileset attribute",
getLocation());
}


+ 0
- 1
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -80,7 +80,6 @@ import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.filters.util.ChainReaderHelper;
import org.apache.tools.ant.filters.TokenFilter;
import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.launch.Locator;


+ 1
- 1
src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java View File

@@ -136,7 +136,7 @@ public class RegexpMatcherFactory {

protected void testAvailability(String className) throws BuildException {
try {
Class implClass = Class.forName(className);
Class.forName(className);
} catch (Throwable t) {
throw new BuildException(t);
}


Loading…
Cancel
Save