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;

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.PatternSet;

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

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.
(Windows has a max resolution of two secs for modification times)
*/
if ((new Os("windows")).eval()) {
if (Os.isFamily("windows")) {
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
}

if ( (new Os("mac")).eval() ) {
if ( Os.isFamily("mac") ) {
// Mac
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
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

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

private static String[] getProcEnvCommand() {
if ( (new Os("os/2")).eval() ) {
if ( Os.isFamily("os/2") ) {
// OS/2 - use same mechanism as Windows 2000
// Not sure
String[] cmd = {"cmd", "/c", "set" };
return cmd;
}
else if ( (new Os("windows")).eval() ) {
else if ( Os.isFamily("windows") ) {
String osname =
System.getProperty("os.name").toLowerCase(Locale.US);
// Determine if we're running under 2000/NT or 98/95
@@ -224,14 +224,18 @@ public class Execute {
return cmd;
}
}
else if ( (new Os("unix")).eval() ) {
else if ( Os.isFamily("unix") ) {
// Generic UNIX
// Alternatively one could use: /bin/sh -c env
String[] cmd = {"/usr/bin/env"};
return cmd;
}
else if ( Os.isFamily("netware") ) {
String[] cmd = {"env"};
return cmd;
}
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
String[] cmd = null;
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,
// 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
// 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") +
"/../bin/javadoc" + extension );

if (jdocExecutable.exists())
if (jdocExecutable.exists() && !Os.isFamily("netware"))
{
return jdocExecutable.getAbsolutePath();
}
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";
}
}


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

@@ -65,6 +65,10 @@ import java.util.Locale;
* @version $Revision$
*/
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;

public Os() {}
@@ -93,8 +97,16 @@ public class Os implements Condition {
* @see Os#setFamily(String)
*/
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.equals("windows")) {
return osName.indexOf("windows") > -1;
@@ -103,12 +115,12 @@ public class Os implements Condition {
} else if (family.equals("netware")) {
return osName.indexOf("netware") > -1;
} else if (family.equals("dos")) {
return pathSep.equals(";");
return pathSep.equals(";") && !isFamily("netware");
} else if (family.equals("mac")) {
return osName.indexOf("mac") > -1;
} else if (family.equals("unix")) {
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 \""
+ 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";

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

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

// we must be on Windows to continue
if (!isWindows) {
if (Os.isFamily("windows")) {
log("Using listcab/libcabinet", Project.MSG_VERBOSE);
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() {
// This is the most common extension case - exe for windows and OS/2,
// 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
// 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") +
"/../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();
} else {
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.
(Windows has a max resolution of two secs for modification times)
*/
if ((new Os("windows")).eval()) {
if (Os.isFamily("windows")) {
now += 2000;
}



Loading…
Cancel
Save