Browse Source

antlib: allow a typedef in an antlib to override the classpath

unittests to follow


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276448 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
526cd172f0
1 changed files with 20 additions and 13 deletions
  1. +20
    -13
      src/main/org/apache/tools/ant/taskdefs/DefBase.java

+ 20
- 13
src/main/org/apache/tools/ant/taskdefs/DefBase.java View File

@@ -42,7 +42,7 @@ public abstract class DefBase extends AntlibDefinition {
* @ant.attribute ignore="true" * @ant.attribute ignore="true"
*/ */
public void setReverseLoader(boolean reverseLoader) { public void setReverseLoader(boolean reverseLoader) {
this.cpDelegate.setReverseLoader(reverseLoader);
getDelegate().setReverseLoader(reverseLoader);
log("The reverseloader attribute is DEPRECATED. It will be removed", log("The reverseloader attribute is DEPRECATED. It will be removed",
Project.MSG_WARN); Project.MSG_WARN);
} }
@@ -51,14 +51,14 @@ public abstract class DefBase extends AntlibDefinition {
* @return the classpath for this definition * @return the classpath for this definition
*/ */
public Path getClasspath() { public Path getClasspath() {
return cpDelegate.getClasspath();
return getDelegate().getClasspath();
} }


/** /**
* @return the reverse loader attribute of the classpath delegate. * @return the reverse loader attribute of the classpath delegate.
*/ */
public boolean isReverseLoader() { public boolean isReverseLoader() {
return cpDelegate.isReverseLoader();
return getDelegate().isReverseLoader();
} }


/** /**
@@ -66,7 +66,7 @@ public abstract class DefBase extends AntlibDefinition {
* @return the loader id * @return the loader id
*/ */
public String getLoaderId() { public String getLoaderId() {
return cpDelegate.getClassLoadId();
return getDelegate().getClassLoadId();
} }


/** /**
@@ -74,7 +74,7 @@ public abstract class DefBase extends AntlibDefinition {
* @return the class path id * @return the class path id
*/ */
public String getClasspathId() { public String getClasspathId() {
return cpDelegate.getClassLoadId();
return getDelegate().getClassLoadId();
} }


/** /**
@@ -83,7 +83,7 @@ public abstract class DefBase extends AntlibDefinition {
* @param classpath an Ant Path object containing the classpath. * @param classpath an Ant Path object containing the classpath.
*/ */
public void setClasspath(Path classpath) { public void setClasspath(Path classpath) {
this.cpDelegate.setClasspath(classpath);
getDelegate().setClasspath(classpath);
} }


/** /**
@@ -92,7 +92,7 @@ public abstract class DefBase extends AntlibDefinition {
* @return the classpath of the this definition * @return the classpath of the this definition
*/ */
public Path createClasspath() { public Path createClasspath() {
return this.cpDelegate.createClasspath();
return getDelegate().createClasspath();
} }


/** /**
@@ -101,7 +101,7 @@ public abstract class DefBase extends AntlibDefinition {
* @param r the reference to the classpath * @param r the reference to the classpath
*/ */
public void setClasspathRef(Reference r) { public void setClasspathRef(Reference r) {
this.cpDelegate.setClasspathref(r);
getDelegate().setClasspathref(r);
} }


/** /**
@@ -117,7 +117,7 @@ public abstract class DefBase extends AntlibDefinition {
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void setLoaderRef(Reference r) { public void setLoaderRef(Reference r) {
this.cpDelegate.setLoaderRef(r);
getDelegate().setLoaderRef(r);
} }


/** /**
@@ -125,11 +125,14 @@ public abstract class DefBase extends AntlibDefinition {
* @return the classloader from the cpDelegate * @return the classloader from the cpDelegate
*/ */
protected ClassLoader createLoader() { protected ClassLoader createLoader() {
if (getAntlibClassLoader() != null) {
if (getAntlibClassLoader() != null && cpDelegate == null) {
return getAntlibClassLoader(); return getAntlibClassLoader();
} }
if (cpDelegate == null) {
cpDelegate = ClasspathUtils.getDelegate(this);
}
if (createdLoader == null) { if (createdLoader == null) {
createdLoader = this.cpDelegate.getClassLoader();
createdLoader = cpDelegate.getClassLoader();
// need to load Task via system classloader or the new // need to load Task via system classloader or the new
// task we want to define will never be a Task but always // task we want to define will never be a Task but always
// be wrapped into a TaskAdapter. // be wrapped into a TaskAdapter.
@@ -144,9 +147,13 @@ public abstract class DefBase extends AntlibDefinition {
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void init() throws BuildException { public void init() throws BuildException {
this.cpDelegate = ClasspathUtils.getDelegate(this);
super.init(); super.init();
} }



private ClasspathUtils.Delegate getDelegate() {
if (cpDelegate == null) {
cpDelegate = ClasspathUtils.getDelegate(this);
}
return cpDelegate;
}
} }

Loading…
Cancel
Save