Browse Source

Add a forwardslash attribute to <apply>

Submitted by:	Zdenek Wagner <wagner at cesnet dot cz>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274322 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
21eb88b560
3 changed files with 32 additions and 2 deletions
  1. +5
    -0
      WHATSNEW
  2. +9
    -1
      docs/manual/CoreTasks/apply.html
  3. +18
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java

+ 5
- 0
WHATSNEW View File

@@ -179,6 +179,11 @@ Other changes:

* New task <sync> that synchronizes two directory trees.

* <apply> has new forwardslash attribute that can force filenames to
use forward slashes (/) as file separators even on platforms with a
different separator. This is useful if you want to run certain
ported Unix tools.

Changes from Ant 1.5.2 to Ant 1.5.3
===================================



+ 9
- 1
docs/manual/CoreTasks/apply.html View File

@@ -57,6 +57,14 @@ one mapper.</p>
the <i>dest</i> attribute for target files).</td>
<td align="center" valign="top">No, default is <i>false</i></td>
</tr>
<tr>
<td valign="top">forwardslash</td>
<td valign="top">whether the absolute file names should be passed
with forward slashes even if the operating system requires other
file separator. The option is ignored if the system file separator
is a forward slash.</td>
<td align="center" valign="top">No, default is <i>false</i></td>
</tr>
<tr>
<td valign="top">os</td>
<td valign="top">list of Operating Systems on which the command may be
@@ -220,7 +228,7 @@ of all files separated by spaces.</p>
<code>.o</code>, replacing TARGETFILE with the absolute filename of
the <code>.o</code> and SOURCEFILE with the absolute name of the
<code>.c</code> file.</p>
<hr><p align="center">Copyright &copy; 2000-2002 Apache Software Foundation. All rights
<hr><p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All rights
Reserved.</p>

</body>


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -83,6 +83,7 @@ public class ExecuteOn extends ExecTask {
protected Vector filesets = new Vector();
private boolean relative = false;
private boolean parallel = false;
private boolean forwardSlash = false;
protected String type = "file";
protected Commandline.Marker srcFilePos = null;
private boolean skipEmpty = false;
@@ -144,6 +145,14 @@ public class ExecuteOn extends ExecTask {
this.destDir = destDir;
}

/**
* The source and target file names on Windows and OS/2 must use
* forward slash as file separator.
*/
public void setForwardslash(boolean forwardSlash) {
this.forwardSlash = forwardSlash;
}

/**
* Marker that indicates where the name of the source file should
* be put on the command line.
@@ -284,6 +293,7 @@ public class ExecuteOn extends ExecTask {
* @param baseDir filenames are relative to this dir
*/
protected String[] getCommandline(String[] srcFiles, File[] baseDirs) {
final char fileSeparator = File.separatorChar;
Vector targets = new Vector();
if (targetFilePos != null) {
Hashtable addedFiles = new Hashtable();
@@ -297,6 +307,9 @@ public class ExecuteOn extends ExecTask {
} else {
name = subTargets[j];
}
if (forwardSlash && fileSeparator != '/') {
name = name.replace(fileSeparator, '/');
}
if (!addedFiles.contains(name)) {
targets.addElement(name);
addedFiles.put(name, name);
@@ -380,6 +393,10 @@ public class ExecuteOn extends ExecTask {
} else {
result[srcIndex + i] = srcFiles[i];
}
if (forwardSlash && fileSeparator != '/') {
result[srcIndex + i] =
result[srcIndex + i].replace(fileSeparator, '/');
}
}
return result;
}


Loading…
Cancel
Save