Maven: do not try to index local repository if it doesn't exist

This commit is contained in:
Anton Makeev
2012-01-12 17:59:01 +01:00
parent 70401b0c44
commit 2997f460f6
2 changed files with 17 additions and 6 deletions
@@ -132,12 +132,16 @@ public class Maven2ServerIndexerImpl extends MavenRemoteObject implements MavenS
try {
if (isLocal(index)) {
indicator.setIndeterminate(true);
try {
myIndexer.scan(index, new MyScanningListener(indicator), false);
}
finally {
indicator.setIndeterminate(false);
File repository = index.getRepository();
if (repository != null && repository.exists()) {
indicator.setIndeterminate(true);
try {
myIndexer.scan(index, new MyScanningListener(indicator), false);
}
finally {
indicator.setIndeterminate(false);
}
}
}
else {
@@ -84,6 +84,13 @@ public class MavenIndicesTest extends MavenIndicesTestCase {
assertUnorderedElementsAreEqual(i.getGroupIds(), "junit");
}
public void testCreatingAndUpdatingLocalWhenNoDirectory() throws Exception {
MavenIndex i = myIndices.add("id", myRepositoryHelper.getTestDataPath("do_not_exist"), MavenIndex.Kind.LOCAL);
myIndices.updateOrRepair(i, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
assertUnorderedElementsAreEqual(i.getGroupIds());
}
public void testCreatingSeveral() throws Exception {
MavenIndex i1 = myIndices.add("id1", myRepositoryHelper.getTestDataPath("local1"), MavenIndex.Kind.LOCAL);
MavenIndex i2 = myIndices.add("id2", myRepositoryHelper.getTestDataPath("local2"), MavenIndex.Kind.LOCAL);