Browse Source

Take care of NetWare when searching for "java" and "javadoc", add

NetWare case for <property environment=... />.

Simplify OS based decisions.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269851 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
ab9f91736a
8 changed files with 43 additions and 26 deletions
  1. +2
    -5
      src/main/org/apache/tools/ant/taskdefs/Chmod.java
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/DependSet.java
  3. +11
    -7
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  4. +6
    -4
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  5. +16
    -4
      src/main/org/apache/tools/ant/taskdefs/condition/Os.java
  6. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  7. +5
    -2
      src/main/org/apache/tools/ant/types/CommandlineJava.java
  8. +1
    -1
      src/main/org/apache/tools/ant/util/SourceFileScanner.java

+ 2
- 5
src/main/org/apache/tools/ant/taskdefs/Chmod.java View File

@@ -55,6 +55,7 @@
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet; import org.apache.tools.ant.types.PatternSet;


@@ -202,10 +203,6 @@ public class Chmod extends ExecuteOn {
} }


protected boolean isValidOs() { protected boolean isValidOs() {
// XXX if OS=unix
return System.getProperty("path.separator").equals(":")
&& (!System.getProperty("os.name").startsWith("Mac")
|| System.getProperty("os.name").endsWith("X"))
&& super.isValidOs();
return Os.isFamily("unix") && super.isValidOs();
} }
} }

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

@@ -171,7 +171,7 @@ public class DependSet extends MatchingTask {
be able to check file modification times. be able to check file modification times.
(Windows has a max resolution of two secs for modification times) (Windows has a max resolution of two secs for modification times)
*/ */
if ((new Os("windows")).eval()) {
if (Os.isFamily("windows")) {
now += 2000; now += 2000;
} }




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

@@ -111,15 +111,15 @@ public class Execute {
// Ignore and keep try // Ignore and keep try
} }


if ( (new Os("mac")).eval() ) {
if ( Os.isFamily("mac") ) {
// Mac // Mac
shellLauncher = new MacCommandLauncher(new CommandLauncher()); shellLauncher = new MacCommandLauncher(new CommandLauncher());
} }
else if ( (new Os("os/2")).eval() ) {
else if ( Os.isFamily("os/2") ) {
// OS/2 - use same mechanism as Windows 2000 // OS/2 - use same mechanism as Windows 2000
shellLauncher = new WinNTCommandLauncher(new CommandLauncher()); shellLauncher = new WinNTCommandLauncher(new CommandLauncher());
} }
else if ( (new Os("windows")).eval() ) {
else if ( Os.isFamily("windows") ) {
// Windows. Need to determine which JDK we're running in // Windows. Need to determine which JDK we're running in


CommandLauncher baseLauncher; CommandLauncher baseLauncher;
@@ -203,13 +203,13 @@ public class Execute {
} }


private static String[] getProcEnvCommand() { private static String[] getProcEnvCommand() {
if ( (new Os("os/2")).eval() ) {
if ( Os.isFamily("os/2") ) {
// OS/2 - use same mechanism as Windows 2000 // OS/2 - use same mechanism as Windows 2000
// Not sure // Not sure
String[] cmd = {"cmd", "/c", "set" }; String[] cmd = {"cmd", "/c", "set" };
return cmd; return cmd;
} }
else if ( (new Os("windows")).eval() ) {
else if ( Os.isFamily("windows") ) {
String osname = String osname =
System.getProperty("os.name").toLowerCase(Locale.US); System.getProperty("os.name").toLowerCase(Locale.US);
// Determine if we're running under 2000/NT or 98/95 // Determine if we're running under 2000/NT or 98/95
@@ -224,14 +224,18 @@ public class Execute {
return cmd; return cmd;
} }
} }
else if ( (new Os("unix")).eval() ) {
else if ( Os.isFamily("unix") ) {
// Generic UNIX // Generic UNIX
// Alternatively one could use: /bin/sh -c env // Alternatively one could use: /bin/sh -c env
String[] cmd = {"/usr/bin/env"}; String[] cmd = {"/usr/bin/env"};
return cmd; return cmd;
}
else if ( Os.isFamily("netware") ) {
String[] cmd = {"env"};
return cmd;
} }
else { else {
// MAC OS 9 and previous, Netware
// MAC OS 9 and previous
// TODO: I have no idea how to get it, someone must fix it // TODO: I have no idea how to get it, someone must fix it
String[] cmd = null; String[] cmd = null;
return cmd; return cmd;


+ 6
- 4
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -1159,7 +1159,7 @@ public class Javadoc extends Task {
{ {
// This is the most common extension case - exe for windows and OS/2, // This is the most common extension case - exe for windows and OS/2,
// nothing for *nix. // nothing for *nix.
String extension = (new Os("dos")).eval() ? ".exe" : "";
String extension = Os.isFamily("dos") ? ".exe" : "";


// Look for javadoc in the java.home/../bin directory. Unfortunately // Look for javadoc in the java.home/../bin directory. Unfortunately
// on Windows java.home doesn't always refer to the correct location, // on Windows java.home doesn't always refer to the correct location,
@@ -1168,14 +1168,16 @@ public class Javadoc extends Task {
File jdocExecutable = new File( System.getProperty("java.home") + File jdocExecutable = new File( System.getProperty("java.home") +
"/../bin/javadoc" + extension ); "/../bin/javadoc" + extension );


if (jdocExecutable.exists())
if (jdocExecutable.exists() && !Os.isFamily("netware"))
{ {
return jdocExecutable.getAbsolutePath(); return jdocExecutable.getAbsolutePath();
} }
else else
{ {
log( "Unable to locate " + jdocExecutable.getAbsolutePath() +
". Using \"javadoc\" instead.", Project.MSG_VERBOSE );
if (!Os.isFamily("netware")) {
log( "Unable to locate " + jdocExecutable.getAbsolutePath() +
". Using \"javadoc\" instead.", Project.MSG_VERBOSE );
}
return "javadoc"; return "javadoc";
} }
} }


+ 16
- 4
src/main/org/apache/tools/ant/taskdefs/condition/Os.java View File

@@ -65,6 +65,10 @@ import java.util.Locale;
* @version $Revision$ * @version $Revision$
*/ */
public class Os implements Condition { public class Os implements Condition {
private static final String osName =
System.getProperty("os.name").toLowerCase(Locale.US);
private static final String pathSep = System.getProperty("path.separator");

private String family; private String family;


public Os() {} public Os() {}
@@ -93,8 +97,16 @@ public class Os implements Condition {
* @see Os#setFamily(String) * @see Os#setFamily(String)
*/ */
public boolean eval() throws BuildException { public boolean eval() throws BuildException {
String osName = System.getProperty("os.name").toLowerCase(Locale.US);
String pathSep = System.getProperty("path.separator");
return isFamily(family);
}

/**
* Determines if the OS on which Ant is executing matches the
* given OS family.
*
* @since 1.5
*/
public static boolean isFamily(String family) {
if (family != null) { if (family != null) {
if (family.equals("windows")) { if (family.equals("windows")) {
return osName.indexOf("windows") > -1; return osName.indexOf("windows") > -1;
@@ -103,12 +115,12 @@ public class Os implements Condition {
} else if (family.equals("netware")) { } else if (family.equals("netware")) {
return osName.indexOf("netware") > -1; return osName.indexOf("netware") > -1;
} else if (family.equals("dos")) { } else if (family.equals("dos")) {
return pathSep.equals(";");
return pathSep.equals(";") && !isFamily("netware");
} else if (family.equals("mac")) { } else if (family.equals("mac")) {
return osName.indexOf("mac") > -1; return osName.indexOf("mac") > -1;
} else if (family.equals("unix")) { } else if (family.equals("unix")) {
return pathSep.equals(":") return pathSep.equals(":")
&& (!osName.startsWith("mac") || osName.endsWith("x"));
&& (!isFamily("mac") || osName.endsWith("x"));
} }
throw new BuildException("Don\'t know how to detect os family \"" throw new BuildException("Don\'t know how to detect os family \""
+ family + "\""); + family + "\"");


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

@@ -92,7 +92,6 @@ public class Cab extends MatchingTask {
protected String archiveType = "cab"; protected String archiveType = "cab";


private static String myos; private static String myos;
private static boolean isWindows = (new Os("windows")).eval();


/** /**
* This is the name/location of where to * This is the name/location of where to
@@ -310,7 +309,7 @@ public class Cab extends MatchingTask {
log("Building "+ archiveType +": "+ cabFile.getAbsolutePath()); log("Building "+ archiveType +": "+ cabFile.getAbsolutePath());


// we must be on Windows to continue // we must be on Windows to continue
if (!isWindows) {
if (Os.isFamily("windows")) {
log("Using listcab/libcabinet", Project.MSG_VERBOSE); log("Using listcab/libcabinet", Project.MSG_VERBOSE);
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();


+ 5
- 2
src/main/org/apache/tools/ant/types/CommandlineJava.java View File

@@ -347,7 +347,7 @@ public class CommandlineJava implements Cloneable {
private String getJavaExecutableName() { private String getJavaExecutableName() {
// This is the most common extension case - exe for windows and OS/2, // This is the most common extension case - exe for windows and OS/2,
// nothing for *nix. // nothing for *nix.
String extension = (new Os("dos")).eval() ? ".exe" : "";
String extension = Os.isFamily("dos") ? ".exe" : "";


// Look for java in the java.home/../bin directory. Unfortunately // Look for java in the java.home/../bin directory. Unfortunately
// on Windows java.home doesn't always refer to the correct location, // on Windows java.home doesn't always refer to the correct location,
@@ -357,7 +357,10 @@ public class CommandlineJava implements Cloneable {
new java.io.File(System.getProperty("java.home") + new java.io.File(System.getProperty("java.home") +
"/../bin/java" + extension ); "/../bin/java" + extension );


if (jExecutable.exists()) {
if (jExecutable.exists() && !Os.isFamily("netware")) {
// NetWare may have a "java" in that directory, but 99% of
// the time, you don't want to execute it -- Jeff Tulley
// <JTULLEY@novell.com>
return jExecutable.getAbsolutePath(); return jExecutable.getAbsolutePath();
} else { } else {
return "java"; return "java";


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

@@ -107,7 +107,7 @@ public class SourceFileScanner {
be able to check file modification times. be able to check file modification times.
(Windows has a max resolution of two secs for modification times) (Windows has a max resolution of two secs for modification times)
*/ */
if ((new Os("windows")).eval()) {
if (Os.isFamily("windows")) {
now += 2000; now += 2000;
} }




Loading…
Cancel
Save