FIX: ivy:retrieve with sync="true" removes the .svn directory (IVY-763)

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@644532 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Maarten Coene 2008-04-03 22:19:46 +00:00
parent 2b3297b8f6
commit 6091b1a3cc
6 changed files with 40 additions and 7 deletions

View File

@ -77,6 +77,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
- IMPROVEMENT: Change allownomd and skipbuildwithoutivy into a more semantically correct name (IVY-297)
- IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher and GlobPatternMatcher
- FIX: ivy:retrieve with sync="true" removes the .svn directory (IVY-763)
- FIX: Ivy silently fails XML errors in ivyrep (IVY-579)
- FIX: Extra Attributes are not available to resolver after resolve if cache was empty (IVY-773)
- FIX: NullPointerException during ResovleEngine.downloadArtifacts. (IVY-592)

View File

@ -150,9 +150,13 @@ public class RetrieveEngine {
if (options.isSync()) {
Message.verbose("\tsyncing...");
Collection existingArtifacts = FileUtil.listAll(fileRetrieveRoot);
String[] ignorableFilenames = settings.getIgnorableFilenames();
Collection ignoreList = Arrays.asList(ignorableFilenames);
Collection existingArtifacts = FileUtil.listAll(fileRetrieveRoot, ignoreList);
Collection existingIvys = ivyRetrieveRoot == null ? null : FileUtil
.listAll(ivyRetrieveRoot);
.listAll(ivyRetrieveRoot, ignoreList);
if (fileRetrieveRoot.equals(ivyRetrieveRoot)) {
Collection target = targetArtifactsStructure;

View File

@ -25,5 +25,7 @@ public interface RetrieveEngineSettings extends ParserSettings {
boolean isCheckUpToDate();
IvyVariableContainer getVariables();
String[] getIgnorableFilenames();
}

View File

@ -1072,6 +1072,14 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
this.statusManager = statusManager;
}
/**
* Returns the file names of the files that should be ignored when
* creating a file listing.
*/
public String[] getIgnorableFilenames() {
return (String[]) listingIgnore.toArray(new String[listingIgnore.size()]);
}
/**
* Filters the names list by removing all names that should be ignored as defined by the listing
* ignore list
@ -1081,7 +1089,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
public void filterIgnore(Collection names) {
names.removeAll(listingIgnore);
}
public boolean isCheckUpToDate() {
return checkUpToDate;
}

View File

@ -304,21 +304,26 @@ public final class FileUtil {
*
* @param dir The directory from which all files, including files in subdirectory)
* are extracted.
* @param ignore a Collection of filenames which must be excluded from listing
* @return A collectoin containing all the files of the given directory and it's
* subdirectories.
*/
public static Collection listAll(File dir) {
return listAll(dir, new ArrayList());
public static Collection listAll(File dir, Collection ignore) {
return listAll(dir, new ArrayList(), ignore);
}
private static Collection listAll(File file, Collection list) {
private static Collection listAll(File file, Collection list, Collection ignore) {
if (ignore.contains(file.getName())) {
return list;
}
if (file.exists()) {
list.add(file);
}
if (file.isDirectory()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
listAll(files[i], list);
listAll(files[i], list, ignore);
}
}
return list;

View File

@ -142,6 +142,19 @@ public class IvyRetrieveTest extends TestCase {
assertFalse(new File("build/test/lib/unknown").exists()); // even conf directory should
// have been deleted
}
public void testSyncWithIgnoreList() throws Exception {
project.setProperty("ivy.dep.file", "test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml");
retrieve.setSync(true);
new File("build/test/lib/.svn").mkdirs();
new File("build/test/lib/.svn/test.txt").createNewFile();
assertTrue(new File("build/test/lib/.svn/test.txt").exists());
retrieve.execute();
assertTrue(new File("build/test/lib/.svn/test.txt").exists());
}
public void testWithAPreviousResolve() throws Exception {
// first we do a resolve in another project