Browse Source

Merge pull request #115 from twogee/duplications

Remove duplicated code
master
Stefan Bodewig GitHub 4 years ago
parent
commit
40d9c2b28e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 53 deletions
  1. +3
    -6
      src/main/org/apache/tools/ant/Main.java
  2. +1
    -2
      src/main/org/apache/tools/ant/PropertyHelper.java
  3. +0
    -2
      src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java
  4. +0
    -2
      src/main/org/apache/tools/ant/listener/Log4jListener.java
  5. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/KeySubst.java
  6. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  7. +0
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/Http.java
  8. +4
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/ClassNameReader.java
  9. +4
    -11
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  10. +4
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  11. +2
    -7
      src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java

+ 3
- 6
src/main/org/apache/tools/ant/Main.java View File

@@ -440,9 +440,6 @@ public class Main implements AntMain {
if (searchForFile) {
if (searchForThis != null) {
buildFile = findBuildFile(System.getProperty("user.dir"), searchForThis);
if (buildFile == null) {
throw new BuildException("Could not locate a build file!");
}
} else {
// no search file specified: so search an existing default file
final Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers();
@@ -454,9 +451,9 @@ public class Main implements AntMain {
}
buildFile = findBuildFile(System.getProperty("user.dir"), searchForThis);
} while (buildFile == null && it.hasNext());
if (buildFile == null) {
throw new BuildException("Could not locate a build file!");
}
}
if (buildFile == null) {
throw new BuildException("Could not locate a build file!");
}
} else {
// no build file specified: so search an existing default file


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

@@ -1048,12 +1048,11 @@ public class PropertyHelper implements GetProperty {
if (value.charAt(pos + 1) == '$') {
//backwards compatibility two $ map to one mode
fragments.addElement("$");
prev = pos + 2;
} else {
//new behaviour: $X maps to $X for all values of X!='$'
fragments.addElement(value.substring(pos, pos + 2));
prev = pos + 2;
}
prev = pos + 2;
} else {
//property found, extract its name or bail on a typo
int endName = value.indexOf('}', pos);


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

@@ -282,8 +282,6 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger {
}
break;
case Project.MSG_VERBOSE:
log.debug(message);
break;
case Project.MSG_DEBUG:
log.debug(message);
break;


+ 0
- 2
src/main/org/apache/tools/ant/listener/Log4jListener.java View File

@@ -155,8 +155,6 @@ public class Log4jListener implements BuildListener {
log.info(event.getMessage());
break;
case Project.MSG_VERBOSE:
log.debug(event.getMessage());
break;
case Project.MSG_DEBUG:
log.debug(event.getMessage());
break;


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

@@ -72,13 +72,11 @@ public class KeySubst extends Task {
String newline = null;
line = br.readLine();
while (line != null) {
if (line.isEmpty()) {
bw.newLine();
} else {
if (!line.isEmpty()) {
newline = KeySubst.replace(line, replacements);
bw.write(newline);
bw.newLine();
}
bw.newLine();
line = br.readLine();
}
bw.flush();


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

@@ -623,10 +623,8 @@ public class Zip extends MatchingTask {
skipWriting = true;
executeMain();
skipWriting = false;
executeMain();
} else {
executeMain();
}
executeMain();
}

/**


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

@@ -136,8 +136,6 @@ public class Http extends ProjectComponent implements Condition {
} catch (ProtocolException pe) {
throw new BuildException("Invalid HTTP protocol: "
+ requestMethod, pe);
} catch (SocketTimeoutException ste) {
return false;
} catch (IOException e) {
return false;
}


+ 4
- 6
src/main/org/apache/tools/ant/taskdefs/optional/jlink/ClassNameReader.java View File

@@ -64,6 +64,10 @@ class ConstantPool {
break;

case INTEGER :
case FIELDREF :
case METHODREF :
case INTERFACEMETHODREF :
case NAMEANDTYPE :
values[i] = data.readInt();
break;

@@ -86,12 +90,6 @@ class ConstantPool {
values[i] = data.readUnsignedShort();
break;

case FIELDREF :
case METHODREF :
case INTERFACEMETHODREF :
case NAMEANDTYPE :
values[i] = data.readInt();
break;
default:
// Do nothing
}


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

@@ -561,9 +561,6 @@ public class FTP extends Task implements FTPTaskConfig {

}
ftp.changeToParentDirectory();
} catch (FTPConnectionClosedException ftpcce) {
throw new BuildException("Error while communicating with FTP "
+ "server: ", ftpcce);
} catch (IOException e) {
throw new BuildException("Error while communicating with FTP "
+ "server: ", e);
@@ -2535,16 +2532,12 @@ public class FTP extends Task implements FTPTaskConfig {

if (binary) {
ftp.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not set transfer type: %s",
ftp.getReplyString());
}
} else {
ftp.setFileType(org.apache.commons.net.ftp.FTP.ASCII_FILE_TYPE);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not set transfer type: %s",
ftp.getReplyString());
}
}
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not set transfer type: %s",
ftp.getReplyString());
}

if (passive) {


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

@@ -1812,16 +1812,12 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {

if (task.isBinary()) {
ftp.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not set transfer type: %s",
ftp.getReplyString());
}
} else {
ftp.setFileType(org.apache.commons.net.ftp.FTP.ASCII_FILE_TYPE);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not set transfer type: %s",
ftp.getReplyString());
}
}
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not set transfer type: %s",
ftp.getReplyString());
}

if (task.isPassive()) {


+ 2
- 7
src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java View File

@@ -115,16 +115,11 @@ public class DependencyVisitor extends EmptyVisitor {
// is upper case ascii. so according to the spec it's an inner class
classname = classname.substring(0, index) + "$"
+ classname.substring(index + 1);
addClass(classname);
} else {
// Add the class in dotted notation 'com.company.Class'
addClass(classname);
}
// CheckStyle:MagicNumber ON
} else {
// Add a class with no package 'Class'
addClass(classname);
}
// Add the class, with or without the package name
addClass(classname);
}
}



Loading…
Cancel
Save