Author: jfallows
Date: Sat Jul 9 04:46:49 2011
New Revision: 1144592
URL: http://svn.apache.org/viewvc?rev=1144592&view=rev
Log:
NPANDAY-409: Executable path ignored during command execution while building
NPanday on Linux
Modified:
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java
Modified:
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java?rev=1144592&r1=1144591&r2=1144592&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
(original)
+++
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
Sat Jul 9 04:46:49 2011
@@ -296,25 +296,29 @@ public final class PathUtil
public static boolean containsExecutable(String executablePath, String
executable) {
- File path = new File(executablePath);
- if (!path.exists())
- return false;
-
- File file = new File(path, executable);
- if (file.exists())
- return true;
+ return (getExecutable(new File(executablePath), executable) != null);
+ }
+
+ public static File getExecutable(File executablePath, String executable) {
+
+ if (executablePath == null || !executablePath.exists())
+ return null;
+
+ File executableFile = new File(executablePath, executable);
+ if (executableFile.exists())
+ return executableFile;
// TODO: handle linux/mac ?
String[] extensions = new String[] {"exe", "com", "bat", "cmd"};
for (String extension : extensions)
{
- file = new File(path, executable + "." + extension);
- if (file.exists())
- return true;
+ executableFile = new File(executablePath, executable + "." +
extension);
+ if (executableFile.exists())
+ return executableFile;
}
- return false;
+ return null;
}
public static File buildSettingsFilePath( String settingsPathOrFile )
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java?rev=1144592&r1=1144591&r2=1144592&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java
Sat Jul 9 04:46:49 2011
@@ -18,6 +18,8 @@
*/
package npanday.executable;
+import npanday.PathUtil;
+
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.cli.*;
@@ -341,6 +343,21 @@ public interface CommandExecutor
}
};
+ // NPANDAY-409
+ // On non-Windows platforms, such as Linux, "gmcs" not
resolved
+ // to gmcs.exe in working directory due to /usr/bin/gmcs
+ // but "./gmcs.exe" resolved as desired in working
directory
+ String osName = System.getProperty("os.name");
+ if (!osName.toLowerCase().contains("win"))
+ {
+ File executableFile =
PathUtil.getExecutable(workingDirectory, executable);
+ // do not prefix for internal commands, such as mkdir
+ if (executableFile != null &&
workingDirectory.equals(executableFile.getParentFile()))
+ {
+ executable = new File("./",
executableFile.getName()).toString();
+ }
+ }
+
commandline.setExecutable( executable );
commandline.addArguments( commands.toArray( new
String[commands.size()]));