Browse Source

Add OS/2 as Os family

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269846 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
0b1e459d5c
2 changed files with 15 additions and 3 deletions
  1. +2
    -1
      docs/manual/CoreTasks/condition.html
  2. +13
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/Os.java

+ 2
- 1
docs/manual/CoreTasks/condition.html View File

@@ -99,7 +99,8 @@ are redundant and will be ignored.</p>
Microsoft Windows and OS/2)</li>
<li>mac (for all Apple Macintosh systems)</li>
<li>unix (for all Unix and Unix-like operating systems)</li>
<li>netware</li>
<li>netware (for Novell Netware)</li>
<li>os/2 (for OS/2)</li>
</ul>

<h4>equals</h4>


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

@@ -56,6 +56,8 @@ package org.apache.tools.ant.taskdefs.condition;

import org.apache.tools.ant.BuildException;

import java.util.Locale;

/**
* Condition that tests the OS type.
*
@@ -65,6 +67,12 @@ import org.apache.tools.ant.BuildException;
public class Os implements Condition {
private String family;

public Os() {}

public Os(String family) {
setFamily(family);
}

/**
* Sets the desired OS family type
*
@@ -73,10 +81,11 @@ public class Os implements Condition {
* <ul><li>dos</li>
* <li>mac</li>
* <li>netware</li>
* <li>os/2</li>
* <li>unix</li>
* <li>windows</li></ul>
*/
public void setFamily(String f) {family = f.toLowerCase();}
public void setFamily(String f) {family = f.toLowerCase(Locale.US);}

/**
* Determines if the OS on which Ant is executing matches the type of
@@ -84,11 +93,13 @@ public class Os implements Condition {
* @see Os#setFamily(String)
*/
public boolean eval() throws BuildException {
String osName = System.getProperty("os.name").toLowerCase();
String osName = System.getProperty("os.name").toLowerCase(Locale.US);
String pathSep = System.getProperty("path.separator");
if (family != null) {
if (family.equals("windows")) {
return osName.indexOf("windows") > -1;
} else if (family.equals("os/2")) {
return osName.indexOf("os/2") > -1;
} else if (family.equals("netware")) {
return osName.indexOf("netware") > -1;
} else if (family.equals("dos")) {


Loading…
Cancel
Save