You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2011/12/05 17:27:31 UTC
svn commit: r1210517 - in /maven/indexer/trunk/indexer-core/src:
main/java/org/apache/maven/index/ test/java/org/apache/maven/index/
Author: cstamas
Date: Mon Dec 5 16:27:30 2011
New Revision: 1210517
URL: http://svn.apache.org/viewvc?rev=1210517&view=rev
Log:
MINDEXER-47: SubPath reindex fixes
Reindexing one GAV (subpath of it) of a GA removes other existing GA versions from index.
Patch provided by Marvin Froeder. Thanks.
Added:
maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java (with props)
Modified:
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ScanningResult.java
Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java?rev=1210517&r1=1210516&r2=1210517&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java Mon Dec 5 16:27:30 2011
@@ -48,7 +48,7 @@ public class DefaultScanner
{
request.getArtifactScanningListener().scanningStarted( request.getIndexingContext() );
- ScanningResult result = new ScanningResult();
+ ScanningResult result = new ScanningResult( request );
scanDirectory( request.getStartingDirectory(), request );
Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java?rev=1210517&r1=1210516&r2=1210517&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java Mon Dec 5 16:27:30 2011
@@ -166,7 +166,7 @@ class DefaultScannerListener
if ( update && !context.isReceivingUpdates() )
{
- removeDeletedArtifacts( context, result );
+ removeDeletedArtifacts( context, result, result.getRequest().getStartingPath() );
}
}
catch ( IOException ex )
@@ -232,7 +232,7 @@ class DefaultScannerListener
}
}
- private void removeDeletedArtifacts( IndexingContext context, ScanningResult result )
+ private void removeDeletedArtifacts( IndexingContext context, ScanningResult result, String contextPath )
throws IOException
{
int deleted = 0;
@@ -272,7 +272,11 @@ class DefaultScannerListener
for ( int i = 0; i < collector.getTotalHits(); i++ )
{
- indexerEngine.remove( context, ac );
+ if ( contextPath == null
+ || context.getGavCalculator().gavToPath( ac.getGav() ).startsWith( contextPath ) )
+ {
+ indexerEngine.remove( context, ac );
+ }
deleted++;
}
Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ScanningResult.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ScanningResult.java?rev=1210517&r1=1210516&r2=1210517&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ScanningResult.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ScanningResult.java Mon Dec 5 16:27:30 2011
@@ -35,6 +35,13 @@ public class ScanningResult
private List<Exception> exceptions = new ArrayList<Exception>();
+ private final ScanningRequest request;
+
+ public ScanningResult( ScanningRequest request )
+ {
+ this.request = request;
+ }
+
public void setTotalFiles( int totalFiles )
{
this.totalFiles = totalFiles;
@@ -70,4 +77,9 @@ public class ScanningResult
return exceptions;
}
+ public ScanningRequest getRequest()
+ {
+ return request;
+ }
+
}
Added: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java?rev=1210517&view=auto
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java (added)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java Mon Dec 5 16:27:30 2011
@@ -0,0 +1,73 @@
+package org.apache.maven.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Set;
+
+public class Nexus4674GavPathReindexTest
+ extends AbstractNexusIndexerTest
+{
+ protected File repo = new File( getBasedir(), "src/test/repo" );
+
+ @Override
+ protected void prepareNexusIndexer( NexusIndexer nexusIndexer )
+ throws Exception
+ {
+ context = nexusIndexer.addIndexingContext( "test-minimal", "test", repo, indexDir, null, null, MIN_CREATORS );
+
+ nexusIndexer.scan( context, "/org/slf4j/slf4j-api", null, false );
+ nexusIndexer.scan( context, "/org/slf4j/slf4j-api/1.4.1", null, true );
+ }
+
+ public void testRootGroups()
+ throws Exception
+ {
+ Set<String> rootGroups = context.getRootGroups();
+ assertEquals( rootGroups.toString(), 1, rootGroups.size() );
+
+ assertGroup( 4, "org", context );
+
+ assertGroup( 4, "org.slf4j", context );
+ }
+
+ public void testIdentify()
+ throws Exception
+ {
+ Collection<ArtifactInfo> ais;
+ File artifact;
+
+ // Using a file: this one should be unknown
+ artifact = new File( repo, "qdox/qdox/1.5/qdox-1.5.jar" );
+
+ ais = nexusIndexer.identify( artifact );
+
+ assertTrue( "Should not be able to identify it!", ais.isEmpty() );
+
+ // Using a file: this one should be known
+ artifact = new File( repo, "org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar" );
+
+ ais = nexusIndexer.identify( artifact );
+
+ assertEquals( "Should not be able to identify it!", 1, ais.size() );
+ }
+
+}
\ No newline at end of file
Propchange: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision