Submitted by: Jeff Tulley <JTULLEY@novell.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271787 13f79535-47bb-0310-9956-ffa450edef68master
@@ -47,6 +47,32 @@ it is treated like any other Unix. | |||||
<h2>Novell Netware</h2> | <h2>Novell Netware</h2> | ||||
<p>To give the same level of sophisticated control as Ant's startup scripts on other platforms, it was decided to make the main ant startup on NetWare be via a Perl Script, "runant.pl". This is found in the bin directory (for instance - bootstrap\bin or dist\bin).</p> | |||||
<p>One important item of note is that you need to set up the following to run ant:</p> | |||||
<ul><li><code>CLASSPATH</code> - put ant.jar, crimson.jar, optional.jar, and any other needed jars on the system classpath.</li> | |||||
<li><code>ANT_OPTS</code> - On NetWare, <code>ANT_OPTS</code> needs to include a parameter of the form, <nobr>"-envCWD=<code>ANT_HOME</code>"</nobr>, with <code>ANT_HOME</code> being the fully expanded location of Ant, <b>not</b> an environment variable. This is due to the fact that the NetWare System Console has no notion of a current working directory.</li> | |||||
</ul> | |||||
<p>It is suggested that you create up an ant.ncf that sets up these parameters, and calls <code>perl ANT_HOME/dist/bin/runant.pl</code></p> | |||||
<p>The following is an example of such an NCF file(assuming ant is installed in <nobr>'sys:/jakarta-ant/'):</nobr></p> | |||||
<code> | |||||
envset CLASSPATH=SYS:/jakarta-ant/bootstrap/lib/ant.jar<br /> | |||||
envset CLASSPATH=$CLASSPATH;SYS:/jakarta-ant/lib/crimson.jar <br /> | |||||
envset CLASSPATH=$CLASSPATH;SYS:/jakarta-ant/lib/optional/junit.jar <br /> | |||||
envset CLASSPATH=$CLASSPATH;SYS:/jakarta-ant/bootstrap/lib/optional.jar <br /> | |||||
<br /> | |||||
setenv ANT_OPTS=-envCWD=sys:/jakarta-ant <br /> | |||||
envset ANT_OPTS=-envCWD=sys:/jakarta-ant <br /> | |||||
setenv ANT_HOME=sys:/jakarta-ant/dist/lib <br /> | |||||
envset ANT_HOME=sys:/jakarta-ant/dist/lib <br /> | |||||
<br /> | |||||
perl sys:/jakarta-ant/dist/bin/runant.pl <br /> | |||||
</code> | |||||
<p>Ant works on JVM version 1.3 or higher. You may have some luck running it on JVM 1.2, but serious problems have been found running Ant on JVM 1.1.7B. These problems are caused by JVM bugs that will not be fixed.</p> | |||||
<p>JVM 1.3 is supported on Novell NetWare versions 5.1 and higher.</p> | |||||
<h2>Other platforms</h2> | <h2>Other platforms</h2> | ||||
Support for other platforms is not guaranteed to be complete, as certain | Support for other platforms is not guaranteed to be complete, as certain | ||||
techniques to hide platform details from build files need to be written and | techniques to hide platform details from build files need to be written and | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -79,6 +79,7 @@ import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
import org.apache.tools.ant.filters.util.ChainReaderHelper; | import org.apache.tools.ant.filters.util.ChainReaderHelper; | ||||
import org.apache.tools.ant.types.FilterSetCollection; | import org.apache.tools.ant.types.FilterSetCollection; | ||||
import org.apache.tools.ant.taskdefs.condition.Os; | |||||
/** | /** | ||||
* This class also encapsulates methods which allow Files to be | * This class also encapsulates methods which allow Files to be | ||||
@@ -99,6 +100,8 @@ public class FileUtils { | |||||
private static Object lockReflection = new Object(); | private static Object lockReflection = new Object(); | ||||
private static java.lang.reflect.Method setLastModified = null; | private static java.lang.reflect.Method setLastModified = null; | ||||
private boolean onNetWare = Os.isFamily("netware"); | |||||
/** | /** | ||||
* Factory method. | * Factory method. | ||||
*/ | */ | ||||
@@ -445,14 +448,26 @@ public class FileUtils { | |||||
.replace('\\', File.separatorChar); | .replace('\\', File.separatorChar); | ||||
// deal with absolute files | // deal with absolute files | ||||
if (filename.startsWith(File.separator) || | |||||
(filename.length() >= 2 && | |||||
Character.isLetter(filename.charAt(0)) && | |||||
filename.charAt(1) == ':') | |||||
) { | |||||
return normalize(filename); | |||||
if (!onNetWare) { | |||||
if (filename.startsWith(File.separator) || | |||||
(filename.length() >= 2 && | |||||
Character.isLetter(filename.charAt(0)) && | |||||
filename.charAt(1) == ':') | |||||
) { | |||||
return normalize(filename); | |||||
} | |||||
} else { | |||||
// the assumption that the : will appear as the second character in | |||||
// the path name breaks down when NetWare is a supported platform. | |||||
// Netware volumes are of the pattern: "data:\" | |||||
int colon = filename.indexOf(":"); | |||||
if (filename.startsWith(File.separator) || | |||||
(colon > -1) | |||||
) { | |||||
return normalize(filename); | |||||
} | |||||
} | } | ||||
if (file == null) { | if (file == null) { | ||||
@@ -503,44 +518,59 @@ public class FileUtils { | |||||
.replace('\\', File.separatorChar); | .replace('\\', File.separatorChar); | ||||
// make sure we are dealing with an absolute path | // make sure we are dealing with an absolute path | ||||
if (!path.startsWith(File.separator) && | |||||
! (path.length() >= 2 && | |||||
Character.isLetter(path.charAt(0)) && | |||||
path.charAt(1) == ':') | |||||
) { | |||||
String msg = path + " is not an absolute path"; | |||||
throw new BuildException(msg); | |||||
int colon = path.indexOf(":"); | |||||
if (!onNetWare) { | |||||
if (!path.startsWith(File.separator) && | |||||
! (path.length() >= 2 && | |||||
Character.isLetter(path.charAt(0)) && | |||||
colon == 1) | |||||
) { | |||||
String msg = path + " is not an absolute path"; | |||||
throw new BuildException(msg); | |||||
} | |||||
} else { | |||||
if (!path.startsWith(File.separator) && | |||||
(colon == -1) | |||||
) { | |||||
String msg = path + " is not an absolute path"; | |||||
throw new BuildException(msg); | |||||
} | |||||
} | } | ||||
boolean dosWithDrive = false; | boolean dosWithDrive = false; | ||||
String root = null; | String root = null; | ||||
// Eliminate consecutive slashes after the drive spec | // Eliminate consecutive slashes after the drive spec | ||||
if (path.length() >= 2 && | |||||
Character.isLetter(path.charAt(0)) && | |||||
path.charAt(1) == ':') { | |||||
if ((!onNetWare && | |||||
path.length() >= 2 && | |||||
Character.isLetter(path.charAt(0)) && | |||||
path.charAt(1) == ':') || | |||||
(onNetWare && colon > -1) | |||||
) { | |||||
dosWithDrive = true; | dosWithDrive = true; | ||||
char[] ca = path.replace('/', '\\').toCharArray(); | char[] ca = path.replace('/', '\\').toCharArray(); | ||||
StringBuffer sb = new StringBuffer(); | |||||
sb.append(Character.toUpperCase(ca[0])).append(':'); | |||||
StringBuffer sbRoot = new StringBuffer(); | |||||
for (int i = 0; i < colon; i++) { | |||||
sbRoot.append(Character.toUpperCase(ca[i])); | |||||
} | |||||
sbRoot.append(':'); | |||||
if (colon + 1 < path.length()) { | |||||
sbRoot.append(File.separatorChar); | |||||
} | |||||
root = sbRoot.toString(); | |||||
for (int i = 2; i < ca.length; i++) { | |||||
// Eliminate consecutive slashes after the drive spec | |||||
StringBuffer sbPath = new StringBuffer(); | |||||
for (int i = colon+1; i < ca.length; i++) { | |||||
if ((ca[i] != '\\') || | if ((ca[i] != '\\') || | ||||
(ca[i] == '\\' && ca[i - 1] != '\\') | (ca[i] == '\\' && ca[i - 1] != '\\') | ||||
) { | ) { | ||||
sb.append(ca[i]); | |||||
sbPath.append(ca[i]); | |||||
} | } | ||||
} | } | ||||
path = sb.toString().replace('\\', File.separatorChar); | |||||
if (path.length() == 2) { | |||||
root = path; | |||||
path = ""; | |||||
} else { | |||||
root = path.substring(0, 3); | |||||
path = path.substring(3); | |||||
} | |||||
path = sbPath.toString().replace('\\', File.separatorChar); | |||||
} else { | } else { | ||||
if (path.length() == 1) { | if (path.length() == 1) { | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -59,6 +59,7 @@ import java.io.*; | |||||
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.taskdefs.condition.Os; | |||||
/** | /** | ||||
* Tests for org.apache.tools.ant.util.FileUtils. | * Tests for org.apache.tools.ant.util.FileUtils. | ||||
@@ -164,6 +165,29 @@ public class FileUtilsTest extends TestCase { | |||||
assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
fu.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); | fu.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); | ||||
if (Os.isFamily("netware")) { | |||||
/* | |||||
* throw in NetWare volume names | |||||
*/ | |||||
driveSpec = "SYS:"; | |||||
assertEquals(driveSpec, | |||||
fu.resolveFile(null, driveSpec + "/").getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.resolveFile(null, driveSpec + "\\").getPath()); | |||||
driveSpecLower = "sys:"; | |||||
assertEquals(driveSpec, | |||||
fu.resolveFile(null, driveSpecLower + "/").getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.resolveFile(null, driveSpecLower + "\\").getPath()); | |||||
/* | |||||
* promised to eliminate consecutive slashes after drive letter. | |||||
*/ | |||||
assertEquals(driveSpec, | |||||
fu.resolveFile(null, driveSpec + "/////").getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
} | |||||
/* | /* | ||||
* Now test some relative file name magic. | * Now test some relative file name magic. | ||||
*/ | */ | ||||
@@ -206,6 +230,8 @@ public class FileUtilsTest extends TestCase { | |||||
* throw in drive letters | * throw in drive letters | ||||
*/ | */ | ||||
String driveSpec = "C:"; | String driveSpec = "C:"; | ||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpec).getPath()); | |||||
assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
fu.normalize(driveSpec + "/").getPath()); | fu.normalize(driveSpec + "/").getPath()); | ||||
assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
@@ -223,6 +249,35 @@ public class FileUtilsTest extends TestCase { | |||||
assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
fu.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); | fu.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); | ||||
if (Os.isFamily("netware")) { | |||||
/* | |||||
* throw in NetWare volume names | |||||
*/ | |||||
driveSpec = "SYS:"; | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpec).getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpec + "/").getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpec + "\\").getPath()); | |||||
driveSpecLower = "sys:"; | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpecLower).getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpecLower + "/").getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpecLower + "\\").getPath()); | |||||
assertEquals(driveSpec + "\\junk", | |||||
fu.normalize(driveSpecLower + "\\junk").getPath()); | |||||
/* | |||||
* promised to eliminate consecutive slashes after drive letter. | |||||
*/ | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpec + "/////").getPath()); | |||||
assertEquals(driveSpec, | |||||
fu.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
} | |||||
/* | /* | ||||
* Now test some relative file name magic. | * Now test some relative file name magic. | ||||
*/ | */ | ||||