Browse Source

Only add directories as extdirs that actually exist.

Submitted by:	Constantine P Sapuntzakis <csapuntz@stanford.edu>

push addExtdirs to Path.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269877 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
7224556927
7 changed files with 35 additions and 67 deletions
  1. +1
    -31
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java
  5. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
  6. +1
    -32
      src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  7. +29
    -0
      src/main/org/apache/tools/ant/types/Path.java

+ 1
- 31
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -229,7 +229,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
cp.append(bootclasspath); cp.append(bootclasspath);
} }
if (extdirs != null) { if (extdirs != null) {
addExtdirsToClasspath(cp);
cp.addExtdirs(extdirs);
} }
cp.append(classpath); cp.append(classpath);
cp.append(src); cp.append(src);
@@ -407,36 +407,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
} }
} }


/**
* Emulation of extdirs feature in java >= 1.2.
* This method adds all files in the given
* directories (but not in sub-directories!) to the classpath,
* so that you don't have to specify them all one by one.
* @param classpath - Path to append files to
*/
protected void addExtdirsToClasspath(Path classpath) {
if (extdirs == null) {
String extProp = System.getProperty("java.ext.dirs");
if (extProp != null) {
extdirs = new Path(project, extProp);
} else {
return;
}
}

String[] dirs = extdirs.list();
for (int i=0; i<dirs.length; i++) {
if (!dirs[i].endsWith(File.separator)) {
dirs[i] += File.separator;
}
File dir = project.resolveFile(dirs[i]);
FileSet fs = new FileSet();
fs.setDir(dir);
fs.setIncludes("*");
classpath.addFileset(fs);
}
}

/** /**
* Adds the command line arguments specifc to the current implementation. * Adds the command line arguments specifc to the current implementation.
*/ */


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

@@ -96,7 +96,7 @@ public class Gcj extends DefaultCompilerAdapter {


// gcj doesn't support an extension dir (-extdir) // gcj doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience. // so we'll emulate it for compatibility and convenience.
addExtdirsToClasspath(classpath);
classpath.addExtdirs(extdirs);


if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) { if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) {
// no bootclasspath, therefore, get one from the java runtime // no bootclasspath, therefore, get one from the java runtime


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

@@ -96,7 +96,7 @@ public class Jikes extends DefaultCompilerAdapter {


// Jikes doesn't support an extension dir (-extdir) // Jikes doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience. // so we'll emulate it for compatibility and convenience.
addExtdirsToClasspath(classpath);
classpath.addExtdirs(extdirs);


if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) { if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) {
// no bootclasspath, therefore, get one from the java runtime // no bootclasspath, therefore, get one from the java runtime


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

@@ -84,7 +84,7 @@ public class Jvc extends DefaultCompilerAdapter {


// jvc doesn't support an extension dir (-extdir) // jvc doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience. // so we'll emulate it for compatibility and convenience.
addExtdirsToClasspath(classpath);
classpath.addExtdirs(extdirs);


if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) { if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) {
// no bootclasspath, therefore, get one from the java runtime // no bootclasspath, therefore, get one from the java runtime


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

@@ -129,7 +129,7 @@ public class Kjc extends DefaultCompilerAdapter {
} }


if (extdirs != null) { if (extdirs != null) {
addExtdirsToClasspath(cp);
cp.addExtdirs(extdirs);
} }


cp.append(classpath); cp.append(classpath);


+ 1
- 32
src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -182,7 +182,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
/* /*
* XXX - This doesn't mix very well with build.systemclasspath, * XXX - This doesn't mix very well with build.systemclasspath,
*/ */
addExtdirsToClasspath(classpath);
classpath.addExtdirs(attributes.getExtdirs());
} else { } else {
cmd.createArgument().setValue("-extdirs"); cmd.createArgument().setValue("-extdirs");
cmd.createArgument().setPath(attributes.getExtdirs()); cmd.createArgument().setPath(attributes.getExtdirs());
@@ -259,37 +259,6 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE); attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
} }


/**
* Emulation of extdirs feature in java >= 1.2.
* This method adds all files in the given
* directories (but not in sub-directories!) to the classpath,
* so that you don't have to specify them all one by one.
* @param classpath - Path to append files to
*/
protected void addExtdirsToClasspath(Path classpath) {
Path extdirs = attributes.getExtdirs();
if (extdirs == null) {
String extProp = System.getProperty("java.ext.dirs");
if (extProp != null) {
extdirs = new Path(attributes.getProject(), extProp);
} else {
return;
}
}

String[] dirs = extdirs.list();
for (int i=0; i<dirs.length; i++) {
if (!dirs[i].endsWith(File.separator)) {
dirs[i] += File.separator;
}
File dir = attributes.getProject().resolveFile(dirs[i]);
FileSet fs = new FileSet();
fs.setDir(dir);
fs.setIncludes("*");
classpath.addFileset(fs);
}
}

private final static Random rand = new Random(); private final static Random rand = new Random();


/** /**


+ 29
- 0
src/main/org/apache/tools/ant/types/Path.java View File

@@ -571,4 +571,33 @@ public class Path extends DataType implements Cloneable {
} }
} }


/**
* Emulation of extdirs feature in java >= 1.2.
* This method adds all files in the given
* directories (but not in sub-directories!) to the classpath,
* so that you don't have to specify them all one by one.
* @param classpath - Path to append files to
*/
public void addExtdirs(Path extdirs) {
if (extdirs == null) {
String extProp = System.getProperty("java.ext.dirs");
if (extProp != null) {
extdirs = new Path(project, extProp);
} else {
return;
}
}

String[] dirs = extdirs.list();
for (int i=0; i<dirs.length; i++) {
File dir = project.resolveFile(dirs[i]);
if (dir.exists() && dir.isDirectory()) {
FileSet fs = new FileSet();
fs.setDir(dir);
fs.setIncludes("*");
addFileset(fs);
}
}
}

} }

Loading…
Cancel
Save