Browse Source

Avoid repetition

master
Gintas Grigelionis 7 years ago
parent
commit
4b14d85f11
28 changed files with 61 additions and 80 deletions
  1. +1
    -2
      src/main/org/apache/tools/ant/filters/TokenFilter.java
  2. +1
    -1
      src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Checksum.java
  4. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  5. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/Copydir.java
  6. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Definer.java
  7. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  8. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
  9. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/MakeUrl.java
  10. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
  11. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/Move.java
  12. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/Rmic.java
  13. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Tar.java
  14. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  15. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java
  16. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
  17. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
  18. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
  19. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
  20. +9
    -12
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  21. +9
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  22. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
  23. +3
    -4
      src/main/org/apache/tools/ant/types/optional/image/Scale.java
  24. +1
    -1
      src/main/org/apache/tools/ant/util/ScriptFixBSFPath.java
  25. +9
    -7
      src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
  26. +3
    -3
      src/main/org/apache/tools/ant/util/regexp/RegexpUtil.java
  27. +1
    -1
      src/main/org/apache/tools/tar/TarEntry.java
  28. +2
    -3
      src/tutorial/tasks-filesets-properties/02-fileset/src/Find.java

+ 1
- 2
src/main/org/apache/tools/ant/filters/TokenFilter.java View File

@@ -110,8 +110,7 @@ public class TokenFilter extends BaseFilterReader
if (line == null) { if (line == null) {
return -1; return -1;
} }
for (Enumeration<Filter> e = filters.elements(); e.hasMoreElements();) {
Filter filter = e.nextElement();
for (Filter filter : filters) {
line = filter.filter(line); line = filter.filter(line);
if (line == null) { if (line == null) {
break; break;


+ 1
- 1
src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java View File

@@ -78,7 +78,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger {
if (suffix != null) { if (suffix != null) {
suffix = suffix.replace('.', '-'); suffix = suffix.replace('.', '-');
suffix = suffix.replace(' ', '-'); suffix = suffix.replace(' ', '-');
cat = cat + "." + suffix;
cat += "." + suffix;
} }
final PrintStream tmpOut = System.out; final PrintStream tmpOut = System.out;
final PrintStream tmpErr = System.err; final PrintStream tmpErr = System.err;


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

@@ -611,7 +611,7 @@ public class Checksum extends MatchingTask implements Condition {
// two characters form the hex value. // two characters form the hex value.
for (int i = 0, j = 0; j < l; i++) { for (int i = 0, j = 0; j < l; i++) {
int f = Character.digit(data[j++], WORD) << NIBBLE; int f = Character.digit(data[j++], WORD) << NIBBLE;
f = f | Character.digit(data[j++], WORD);
f |= Character.digit(data[j++], WORD);
out[i] = (byte) (f & BYTE_MASK); out[i] = (byte) (f & BYTE_MASK);
} }




+ 2
- 4
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -505,14 +505,12 @@ public class Copy extends Task {
} }
final File fromDir = fs.getDir(getProject()); final File fromDir = fs.getDir(getProject());


final String[] srcFiles = ds.getIncludedFiles();
final String[] srcDirs = ds.getIncludedDirectories();
if (!flatten && mapperElement == null if (!flatten && mapperElement == null
&& ds.isEverythingIncluded() && !fs.hasPatterns()) { && ds.isEverythingIncluded() && !fs.hasPatterns()) {
completeDirMap.put(fromDir, destDir); completeDirMap.put(fromDir, destDir);
} }
add(fromDir, srcFiles, filesByBasedir);
add(fromDir, srcDirs, dirsByBasedir);
add(fromDir, ds.getIncludedFiles(), filesByBasedir);
add(fromDir, ds.getIncludedDirectories(), dirsByBasedir);
baseDirs.add(fromDir); baseDirs.add(fromDir);
} else { // not a fileset or contains non-file resources } else { // not a fileset or contains non-file resources




+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/Copydir.java View File

@@ -121,8 +121,7 @@ public class Copydir extends MatchingTask {
DirectoryScanner ds = super.getDirectoryScanner(srcDir); DirectoryScanner ds = super.getDirectoryScanner(srcDir);


try { try {
String[] files = ds.getIncludedFiles();
scanDir(srcDir, destDir, files);
scanDir(srcDir, destDir, ds.getIncludedFiles());
if (filecopyList.size() > 0) { if (filecopyList.size() > 0) {
log("Copying " + filecopyList.size() + " file" log("Copying " + filecopyList.size() + " file"
+ (filecopyList.size() == 1 ? "" : "s") + (filecopyList.size() == 1 ? "" : "s")


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

@@ -296,7 +296,7 @@ public abstract class Definer extends DefBase {
resource = path.substring("//".length()); resource = path.substring("//".length());
if (!resource.endsWith(".xml")) { if (!resource.endsWith(".xml")) {
//if we haven't already named an XML file, it gets antlib.xml //if we haven't already named an XML file, it gets antlib.xml
resource = resource + ANTLIB_XML;
resource += ANTLIB_XML;
} }
} else { } else {
//convert from a package to a path //convert from a package to a path


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -1186,9 +1186,8 @@ public class Javac extends MatchingTask {
} }


final DirectoryScanner ds = this.getDirectoryScanner(srcDir); final DirectoryScanner ds = this.getDirectoryScanner(srcDir);
final String[] files = ds.getIncludedFiles();


scanDir(srcDir, destDir != null ? destDir : srcDir, files);
scanDir(srcDir, destDir != null ? destDir : srcDir, ds.getIncludedFiles());
} }
} }




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

@@ -185,7 +185,7 @@ public class LoadProperties extends Task {


if (text != null && !text.isEmpty()) { if (text != null && !text.isEmpty()) {
if (!text.endsWith("\n")) { if (!text.endsWith("\n")) {
text = text + "\n";
text += "\n";
} }
ByteArrayInputStream tis = new ByteArrayInputStream( ByteArrayInputStream tis = new ByteArrayInputStream(
text.getBytes(ResourceUtils.ISO_8859_1)); text.getBytes(ResourceUtils.ISO_8859_1));


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/MakeUrl.java View File

@@ -241,7 +241,7 @@ public class MakeUrl extends Task {
url = toURL(file); url = toURL(file);
//and add any files if also defined //and add any files if also defined
if (!filesetURL.isEmpty()) { if (!filesetURL.isEmpty()) {
url = url + separator + filesetURL;
url += separator + filesetURL;
} }
} }
//add path URLs //add path URLs
@@ -250,7 +250,7 @@ public class MakeUrl extends Task {
if (url.isEmpty()) { if (url.isEmpty()) {
url = pathURL; url = pathURL;
} else { } else {
url = url + separator + pathURL;
url += separator + pathURL;
} }
} }
log("Setting " + property + " to URL " + url, Project.MSG_VERBOSE); log("Setting " + property + " to URL " + url, Project.MSG_VERBOSE);


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

@@ -113,7 +113,7 @@ public class ManifestClassPath extends Task {
} }


if (pathEntry.isDirectory() && !relPath.endsWith("/")) { if (pathEntry.isDirectory() && !relPath.endsWith("/")) {
relPath = relPath + '/';
relPath += '/';
} }
relPath = Locator.encodeURI(relPath); relPath = Locator.encodeURI(relPath);




+ 1
- 3
src/main/org/apache/tools/ant/taskdefs/Move.java View File

@@ -125,9 +125,7 @@ public class Move extends Copy {
fs.setDir(fromDir); fs.setDir(fromDir);
addFileset(fs); addFileset(fs);
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();
String[] dirs = ds.getIncludedDirectories();
scan(fromDir, toDir, files, dirs);
scan(fromDir, toDir, ds.getIncludedFiles(), ds.getIncludedDirectories());
} }
} }
} }


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/Rmic.java View File

@@ -628,8 +628,7 @@ public class Rmic extends MatchingTask {
// specific classname is not given // specific classname is not given
if (classname == null) { if (classname == null) {
DirectoryScanner ds = this.getDirectoryScanner(baseDir); DirectoryScanner ds = this.getDirectoryScanner(baseDir);
String[] files = ds.getIncludedFiles();
scanDir(baseDir, files, adapter.getMapper());
scanDir(baseDir, ds.getIncludedFiles(), adapter.getMapper());
} else { } else {
// otherwise perform a timestamp comparison - at least // otherwise perform a timestamp comparison - at least
String path = classname.replace('.', File.separatorChar) String path = classname.replace('.', File.separatorChar)


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -409,8 +409,8 @@ public class Tar extends MatchingTask {


String prefix = tarFileSet.getPrefix(this.getProject()); String prefix = tarFileSet.getPrefix(this.getProject());
// '/' is appended for compatibility with the zip task. // '/' is appended for compatibility with the zip task.
if (prefix.length() > 0 && !prefix.endsWith("/")) {
prefix = prefix + "/";
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix += "/";
} }
vPath = prefix + vPath; vPath = prefix + vPath;
} }


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

@@ -1026,7 +1026,7 @@ public class Zip extends MatchingTask {
throws IOException { throws IOException {


if (!name.endsWith("/")) { if (!name.endsWith("/")) {
name = name + "/";
name += "/";
} }


final int nextToLastSlash = name.lastIndexOf('/', name.length() - 2); final int nextToLastSlash = name.lastIndexOf('/', name.length() - 2);


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java View File

@@ -101,11 +101,11 @@ public class CvsVersion extends AbstractCvsTask {
} }
} }
String s2 = s.substring(0, i); String s2 = s.substring(0, i);
version = version + counter * Long.parseLong(s2);
version += counter * Long.parseLong(s2);
if (counter == 1) { if (counter == 1) {
break; break;
} }
counter = counter / MULTIPLY;
counter /= MULTIPLY;
} }
return version >= VERSION_1_11_2; return version >= VERSION_1_11_2;
} }


+ 1
- 3
src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java View File

@@ -664,9 +664,7 @@ public class NetRexxC extends MatchingTask {
// compile lists // compile lists
DirectoryScanner ds = getDirectoryScanner(srcDir); DirectoryScanner ds = getDirectoryScanner(srcDir);


String[] files = ds.getIncludedFiles();

scanDir(srcDir, destDir, files);
scanDir(srcDir, destDir, ds.getIncludedFiles());


// copy the source and support files // copy the source and support files
copyFilesToDestination(); copyFilesToDestination();


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java View File

@@ -151,7 +151,7 @@ public class BorlandGenerateClient extends Task {
String ejbjarname = ejbjarfile.getAbsolutePath(); String ejbjarname = ejbjarfile.getAbsolutePath();
//clientname = ejbjarfile+client.jar //clientname = ejbjarfile+client.jar
String clientname = ejbjarname.substring(0, ejbjarname.lastIndexOf(".")); String clientname = ejbjarname.substring(0, ejbjarname.lastIndexOf("."));
clientname = clientname + "client.jar";
clientname += "client.jar";
clientjarfile = new File(clientname); clientjarfile = new File(clientname);
} }




+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java View File

@@ -451,7 +451,7 @@ public class Translate extends MatchingTask {
value = value.substring(0, value.length() - 1); value = value.substring(0, value.length() - 1);
line = in.readLine(); line = in.readLine();
if (line != null) { if (line != null) {
value = value + line.trim();
value += line.trim();
} else { } else {
break; break;
} }


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java View File

@@ -133,7 +133,6 @@ public class WLJspc extends MatchingTask {
} }


compileClasspath = compileClasspath.concatSystemClasspath(); compileClasspath = compileClasspath.concatSystemClasspath();
String[] files = ds.getIncludedFiles();


//Weblogic.jspc calls System.exit() ... have to fork //Weblogic.jspc calls System.exit() ... have to fork
// Therefore, takes loads of time // Therefore, takes loads of time
@@ -164,7 +163,7 @@ public class WLJspc extends MatchingTask {
args[j++] = "-classpath"; args[j++] = "-classpath";
args[j++] = compileClasspath.toString(); args[j++] = compileClasspath.toString();


this.scanDir(files);
this.scanDir(ds.getIncludedFiles());
log("Compiling " + filesToDo.size() + " JSP files"); log("Compiling " + filesToDo.size() + " JSP files");


for (String filename : filesToDo) { for (String filename : filesToDo) {


+ 9
- 12
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -471,13 +471,10 @@ public class FTP extends Task implements FTPTaskConfig {
&& currentelement.length() > 0) { && currentelement.length() > 0) {
accountForIncludedDir(currentelement, myfile, true); accountForIncludedDir(currentelement, myfile, true);
} else { } else {
if (currentelement.length() > 0) {
if (currentelement.charAt(currentelement
.length() - 1)
if (currentelement.length() > 0
&& currentelement.charAt(currentelement.length() - 1)
!= File.separatorChar) { != File.separatorChar) {
currentelement =
currentelement + File.separatorChar;
}
currentelement += File.separatorChar;
} }
scandir(myfile.getAbsolutePath(), currentelement, true); scandir(myfile.getAbsolutePath(), currentelement, true);
} }
@@ -974,20 +971,20 @@ public class FTP extends Task implements FTPTaskConfig {
if (theFiles != null) { if (theFiles != null) {
theFile = getFile(theFiles, currentElement); theFile = getFile(theFiles, currentElement);
} }
if (!"".equals(relPath)) {
relPath = relPath + remoteFileSep;
if (relPath != null && !relPath.isEmpty()) {
relPath += remoteFileSep;
} }
if (theFile == null) { if (theFile == null) {
// hit a hidden file assume not a symlink // hit a hidden file assume not a symlink
relPath = relPath + currentElement;
currentPath = currentPath + remoteFileSep + currentElement;
relPath += currentElement;
currentPath += remoteFileSep + currentElement;
log("Hidden file " + relPath log("Hidden file " + relPath
+ " assumed to not be a symlink.", + " assumed to not be a symlink.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} else { } else {
traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink(); traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink();
relPath = relPath + theFile.getName();
currentPath = currentPath + remoteFileSep + theFile.getName();
relPath += theFile.getName();
currentPath += remoteFileSep + theFile.getName();
} }
} }
return relPath; return relPath;


+ 9
- 14
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -363,13 +363,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
&& currentelement.length() > 0) { && currentelement.length() > 0) {
accountForIncludedDir(currentelement, myfile, true); accountForIncludedDir(currentelement, myfile, true);
} else { } else {
if (currentelement.length() > 0) {
if (currentelement.charAt(currentelement
.length() - 1)
if (currentelement.length() > 0
&& currentelement.charAt(currentelement.length() - 1)
!= File.separatorChar) { != File.separatorChar) {
currentelement =
currentelement + File.separatorChar;
}
currentelement += File.separatorChar;
} }
scandir(myfile.getAbsolutePath(), currentelement, true); scandir(myfile.getAbsolutePath(), currentelement, true);
} }
@@ -875,22 +872,20 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
if (theFiles != null) { if (theFiles != null) {
theFile = getFile(theFiles, currentElement); theFile = getFile(theFiles, currentElement);
} }
if (!"".equals(relPath)) {
relPath = relPath + task.getSeparator();
if (relPath != null && !relPath.isEmpty()) {
relPath += task.getSeparator();
} }
if (theFile == null) { if (theFile == null) {
// hit a hidden file assume not a symlink // hit a hidden file assume not a symlink
relPath = relPath + currentElement;
currentPath = currentPath + task.getSeparator()
+ currentElement;
relPath += currentElement;
currentPath += task.getSeparator() + currentElement;
task.log("Hidden file " + relPath task.log("Hidden file " + relPath
+ " assumed to not be a symlink.", + " assumed to not be a symlink.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} else { } else {
traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink(); traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink();
relPath = relPath + theFile.getName();
currentPath = currentPath + task.getSeparator()
+ theFile.getName();
relPath += theFile.getName();
currentPath += task.getSeparator() + theFile.getName();
} }
} }
return relPath; return relPath;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java View File

@@ -113,7 +113,7 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
try { try {
final SftpATTRS attrs = channel.stat(remoteFile); final SftpATTRS attrs = channel.stat(remoteFile);
if (attrs.isDir() && !remoteFile.endsWith("/")) { if (attrs.isDir() && !remoteFile.endsWith("/")) {
remoteFile = remoteFile + "/";
remoteFile += "/";
} }
} catch (final SftpException ee) { } catch (final SftpException ee) {
// Ignored // Ignored


+ 3
- 4
src/main/org/apache/tools/ant/types/optional/image/Scale.java View File

@@ -95,8 +95,7 @@ public class Scale extends TransformOperation implements DrawOperation {
int percIndex = heightStr.indexOf('%'); int percIndex = heightStr.indexOf('%');
if (percIndex > 0) { if (percIndex > 0) {
yPercent = true; yPercent = true;
float height = Float.parseFloat(heightStr.substring(0, percIndex));
return height / HUNDRED;
return Float.parseFloat(heightStr.substring(0, percIndex)) / HUNDRED;
} }
yPercent = false; yPercent = false;
return Float.parseFloat(heightStr); return Float.parseFloat(heightStr);
@@ -114,10 +113,10 @@ public class Scale extends TransformOperation implements DrawOperation {
float yFl = getHeight(); float yFl = getHeight();


if (!xPercent) { if (!xPercent) {
xFl = xFl / image.getWidth();
xFl /= image.getWidth();
} }
if (!yPercent) { if (!yPercent) {
yFl = yFl / image.getHeight();
yFl /= image.getHeight();
} }


if ("width".equals(proportions)) { if ("width".equals(proportions)) {


+ 1
- 1
src/main/org/apache/tools/ant/util/ScriptFixBSFPath.java View File

@@ -58,7 +58,7 @@ public class ScriptFixBSFPath {
/** A map of languages for which the engine in located in bsf */ /** A map of languages for which the engine in located in bsf */
private static final Map<String, String> BSF_LANGUAGE_MAP = new HashMap<>(); private static final Map<String, String> BSF_LANGUAGE_MAP = new HashMap<>();
static { static {
for (int i = 0; i < BSF_LANGUAGES.length; i = i + 2) {
for (int i = 0; i < BSF_LANGUAGES.length; i += 2) {
BSF_LANGUAGE_MAP.put(BSF_LANGUAGES[i], BSF_LANGUAGES[i + 1]); BSF_LANGUAGE_MAP.put(BSF_LANGUAGES[i], BSF_LANGUAGES[i + 1]);
} }
} }


+ 9
- 7
src/main/org/apache/tools/ant/util/ScriptRunnerBase.java View File

@@ -92,15 +92,17 @@ public abstract class ScriptRunnerBase {
* @param bean the object to be stored in the script context. * @param bean the object to be stored in the script context.
*/ */
public void addBean(String key, Object bean) { public void addBean(String key, Object bean) {
boolean isValid = key.length() > 0
&& Character.isJavaIdentifierStart(key.charAt(0));

for (int i = 1; isValid && i < key.length(); i++) {
isValid = Character.isJavaIdentifierPart(key.charAt(i));
if (key.isEmpty()) {
return;
} }
if (isValid) {
beans.put(key, bean);

for (char ch : key.toCharArray()) {
if (!Character.isJavaIdentifierPart(ch)) {
return;
}
} }

beans.put(key, bean);
} }


/** /**


+ 3
- 3
src/main/org/apache/tools/ant/util/regexp/RegexpUtil.java View File

@@ -96,13 +96,13 @@ public class RegexpUtil {
boolean singleLine) { boolean singleLine) {
int options = RegexpMatcher.MATCH_DEFAULT; int options = RegexpMatcher.MATCH_DEFAULT;
if (!caseSensitive) { if (!caseSensitive) {
options = options | RegexpMatcher.MATCH_CASE_INSENSITIVE;
options |= RegexpMatcher.MATCH_CASE_INSENSITIVE;
} }
if (multiLine) { if (multiLine) {
options = options | RegexpMatcher.MATCH_MULTILINE;
options |= RegexpMatcher.MATCH_MULTILINE;
} }
if (singleLine) { if (singleLine) {
options = options | RegexpMatcher.MATCH_SINGLELINE;
options |= RegexpMatcher.MATCH_SINGLELINE;
} }
return options; return options;
} }


+ 1
- 1
src/main/org/apache/tools/tar/TarEntry.java View File

@@ -993,7 +993,7 @@ public class TarEntry implements TarConstants {
// SunOS tar -E does not add / to directory names, so fix // SunOS tar -E does not add / to directory names, so fix
// up to be consistent // up to be consistent
if (isDirectory() && !name.endsWith("/")) { if (isDirectory() && !name.endsWith("/")) {
name = name + "/";
name += "/";
} }
if (prefix.length() > 0) { if (prefix.length() > 0) {
name = prefix + "/" + name; name = prefix + "/" + name;


+ 2
- 3
src/tutorial/tasks-filesets-properties/02-fileset/src/Find.java View File

@@ -53,12 +53,11 @@ public class Find extends Task {
String foundLocation = null; String foundLocation = null;
for (FileSet fs : filesets) { for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] includedFiles = ds.getIncludedFiles();
for (String includedFile : includedFiles) {
File base = ds.getBasedir();
for (String includedFile : ds.getIncludedFiles()) {
String filename = includedFile.replace('\\','/'); String filename = includedFile.replace('\\','/');
filename = filename.substring(filename.lastIndexOf("/") + 1); filename = filename.substring(filename.lastIndexOf("/") + 1);
if (foundLocation == null && file.equals(filename)) { if (foundLocation == null && file.equals(filename)) {
File base = ds.getBasedir();
File found = new File(base, includedFile); File found = new File(base, includedFile);
foundLocation = found.getAbsolutePath(); foundLocation = found.getAbsolutePath();
} }


Loading…
Cancel
Save