Browse Source

Allow multiple <systemPath> ( system path is used to add more stuff

to the 'main' loader - for example to add junit.jar so that
<junit> optional task can work )


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273575 13f79535-47bb-0310-9956-ffa450edef68
master
Costin Manolache 22 years ago
parent
commit
67b776a8b5
1 changed files with 13 additions and 8 deletions
  1. +13
    -8
      proposal/embed/src/java/org/apache/tools/ant/taskdefs/SystemPath.java

+ 13
- 8
proposal/embed/src/java/org/apache/tools/ant/taskdefs/SystemPath.java View File

@@ -120,24 +120,29 @@ public class SystemPath extends Task {
*/ */
private void initSystemLoader(Path path) { private void initSystemLoader(Path path) {
try { try {
if( project.getReference( SYSTEM_LOADER_REF ) != null )
return; // already done that.
//if( project.getReference( SYSTEM_LOADER_REF ) != null )
// return; // already done that.
// reverse loader // reverse loader
AntClassLoader acl=new AntClassLoader( this.getClass().getClassLoader(), true );
acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional");
project.addReference( SYSTEM_LOADER_REF, acl );
AntClassLoader acl=(AntClassLoader)project.getReference(SYSTEM_LOADER_REF);
if( acl==null ) {
acl=new AntClassLoader( this.getClass().getClassLoader(), true );
acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional");
project.addReference( SYSTEM_LOADER_REF, acl );
}


String list[]=path.list(); String list[]=path.list();
for( int i=0; i<list.length; i++ ) { for( int i=0; i<list.length; i++ ) {
File f= new File( list[i] ); File f= new File( list[i] );
if( f.exists() ) { if( f.exists() ) {
acl.addPathElement(f.getAbsolutePath()); acl.addPathElement(f.getAbsolutePath());
log("Adding to class loader " + acl + " " + f.getAbsolutePath(),
Project.MSG_DEBUG);
} }
} }
// XXX find the classpath
// XXX find the classpath - add the optional jars.
String antHome=project.getProperty( "ant.home" ); String antHome=project.getProperty( "ant.home" );
File optionalJar=new File( antHome + "/lib/optional.jar" ); File optionalJar=new File( antHome + "/lib/optional.jar" );
if( optionalJar.exists() ) if( optionalJar.exists() )


Loading…
Cancel
Save