You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by pe...@apache.org on 2006/12/29 17:53:56 UTC
svn commit: r491046 -
/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
Author: peterreilly
Date: Fri Dec 29 08:53:55 2006
New Revision: 491046
URL: http://svn.apache.org/viewvc?view=rev&rev=491046
Log:
checkstyle: reduce method length
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java?view=diff&rev=491046&r1=491045&r2=491046
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java Fri Dec 29 08:53:55 2006
@@ -397,30 +397,8 @@
try {
// deal with the single file
- if (file != null) {
- if (file.exists()) {
- if (destFile == null) {
- destFile = new File(destDir, file.getName());
- }
- if (forceOverwrite || !destFile.exists()
- || (file.lastModified() - granularity
- > destFile.lastModified())) {
- fileCopyMap.put(file.getAbsolutePath(),
- new String[] {destFile.getAbsolutePath()});
- } else {
- log(file + " omitted as " + destFile
- + " is up to date.", Project.MSG_VERBOSE);
- }
- } else {
- String message = "Warning: Could not find file "
- + file.getAbsolutePath() + " to copy.";
- if (!failonerror) {
- log(message, Project.MSG_ERR);
- } else {
- throw new BuildException(message);
- }
- }
- }
+ copySingleFile();
+
// deal with the ResourceCollections
/* for historical and performance reasons we have to do
@@ -511,23 +489,7 @@
}
}
- Iterator iter = baseDirs.iterator();
- while (iter.hasNext()) {
- File f = (File) iter.next();
- List files = (List) filesByBasedir.get(f);
- List dirs = (List) dirsByBasedir.get(f);
-
- String[] srcFiles = new String[0];
- if (files != null) {
- srcFiles = (String[]) files.toArray(srcFiles);
- }
- String[] srcDirs = new String[0];
- if (dirs != null) {
- srcDirs = (String[]) dirs.toArray(srcDirs);
- }
- scan(f == NULL_FILE_PLACEHOLDER ? null : f, destDir, srcFiles,
- srcDirs);
- }
+ iterateOverBaseDirs(baseDirs, dirsByBasedir, filesByBasedir);
// do all the copy operations now...
try {
@@ -573,6 +535,54 @@
/************************************************************************
** protected and private methods
************************************************************************/
+
+ private void copySingleFile() {
+ // deal with the single file
+ if (file != null) {
+ if (file.exists()) {
+ if (destFile == null) {
+ destFile = new File(destDir, file.getName());
+ }
+ if (forceOverwrite || !destFile.exists()
+ || (file.lastModified() - granularity
+ > destFile.lastModified())) {
+ fileCopyMap.put(file.getAbsolutePath(),
+ new String[] {destFile.getAbsolutePath()});
+ } else {
+ log(file + " omitted as " + destFile
+ + " is up to date.", Project.MSG_VERBOSE);
+ }
+ } else {
+ String message = "Warning: Could not find file "
+ + file.getAbsolutePath() + " to copy.";
+ if (!failonerror) {
+ log(message, Project.MSG_ERR);
+ } else {
+ throw new BuildException(message);
+ }
+ }
+ }
+ }
+ private void iterateOverBaseDirs(
+ HashSet baseDirs, HashMap dirsByBasedir, HashMap filesByBasedir) {
+ Iterator iter = baseDirs.iterator();
+ while (iter.hasNext()) {
+ File f = (File) iter.next();
+ List files = (List) filesByBasedir.get(f);
+ List dirs = (List) dirsByBasedir.get(f);
+
+ String[] srcFiles = new String[0];
+ if (files != null) {
+ srcFiles = (String[]) files.toArray(srcFiles);
+ }
+ String[] srcDirs = new String[0];
+ if (dirs != null) {
+ srcDirs = (String[]) dirs.toArray(srcDirs);
+ }
+ scan(f == NULL_FILE_PLACEHOLDER ? null : f, destDir, srcFiles,
+ srcDirs);
+ }
+ }
/**
* Ensure we have a consistent and legal set of attributes, and set
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org