diff options
author | Olivier Lamy <olamy@apache.org> | 2011-06-26 20:55:15 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-06-26 20:55:15 +0000 |
commit | 0265e37707d288247edc46b1e943b5a6d0bc1c0b (patch) | |
tree | 07ded57671b8e03354cc6577cc7a1502df8602a5 | |
parent | 356f47fa89f0a2c3a87fe96fbfc23e5f308d9993 (diff) | |
download | archiva-0265e37707d288247edc46b1e943b5a6d0bc1c0b.tar.gz archiva-0265e37707d288247edc46b1e943b5a6d0bc1c0b.zip |
[MRM-1345] update use of Nexus indexer to use Maven indexer, fix archiva-scheduler-indexing compilation
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1139943 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 75 insertions, 58 deletions
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java index 64cc7c100..ecd846237 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java @@ -26,21 +26,21 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.index.ArtifactContext; +import org.apache.maven.index.ArtifactContextProducer; +import org.apache.maven.index.ArtifactInfo; +import org.apache.maven.index.DefaultArtifactContextProducer; +import org.apache.maven.index.IndexerEngine; +import org.apache.maven.index.artifact.IllegalArtifactCoordinateException; +import org.apache.maven.index.context.IndexingContext; +import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; +import org.apache.maven.index.packer.IndexPacker; +import org.apache.maven.index.packer.IndexPackingRequest; import org.codehaus.plexus.taskqueue.Task; import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; import org.codehaus.plexus.taskqueue.execution.TaskExecutor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonatype.nexus.artifact.IllegalArtifactCoordinateException; -import org.sonatype.nexus.index.ArtifactContext; -import org.sonatype.nexus.index.ArtifactContextProducer; -import org.sonatype.nexus.index.ArtifactInfo; -import org.sonatype.nexus.index.DefaultArtifactContextProducer; -import org.sonatype.nexus.index.IndexerEngine; -import org.sonatype.nexus.index.context.IndexingContext; -import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException; -import org.sonatype.nexus.index.packer.IndexPacker; -import org.sonatype.nexus.index.packer.IndexPackingRequest; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java index 4d6c361ed..fff045c81 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java @@ -24,10 +24,10 @@ import java.io.IOException; import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.index.context.DefaultIndexingContext; +import org.apache.maven.index.context.IndexingContext; +import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; import org.codehaus.plexus.taskqueue.Task; -import org.sonatype.nexus.index.context.DefaultIndexingContext; -import org.sonatype.nexus.index.context.IndexingContext; -import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException; public class ArtifactIndexingTask implements Task diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java index 199b4198e..c0c5f5f85 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java @@ -26,20 +26,23 @@ import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.TopDocs; +import org.apache.lucene.store.SimpleFSDirectory; import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.index.ArtifactInfo; +import org.apache.maven.index.FlatSearchRequest; +import org.apache.maven.index.FlatSearchResponse; +import org.apache.maven.index.IndexerEngine; +import org.apache.maven.index.MAVEN; +import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexingContext; +import org.apache.maven.index.expr.StringSearchExpression; +import org.apache.maven.index.packer.IndexPacker; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.sonatype.nexus.index.ArtifactInfo; -import org.sonatype.nexus.index.FlatSearchRequest; -import org.sonatype.nexus.index.FlatSearchResponse; -import org.sonatype.nexus.index.IndexerEngine; -import org.sonatype.nexus.index.NexusIndexer; -import org.sonatype.nexus.index.context.IndexingContext; -import org.sonatype.nexus.index.packer.IndexPacker; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -59,7 +62,7 @@ import java.util.zip.ZipInputStream; * ArchivaIndexingTaskExecutorTest */ @RunWith( SpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath*:/spring-context.xml"} ) +@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) public class ArchivaIndexingTaskExecutorTest extends TestCase { @@ -136,9 +139,8 @@ public class ArchivaIndexingTaskExecutorTest public void testAddArtifactToIndex() throws Exception { - File artifactFile = - new File( repositoryConfig.getLocation(), - "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); + File artifactFile = new File( repositoryConfig.getLocation(), + "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); @@ -146,14 +148,16 @@ public class ArchivaIndexingTaskExecutorTest indexingExecutor.executeTask( task ); BooleanQuery q = new BooleanQuery(); - q.add( indexer.constructQuery( ArtifactInfo.GROUP_ID, "org.apache.archiva" ), Occur.SHOULD ); - q.add( indexer.constructQuery( ArtifactInfo.ARTIFACT_ID, "archiva-index-methods-jar-test" ), Occur.SHOULD ); - - IndexingContext context = - indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(), - new File( repositoryConfig.getLocation() ), - new File( repositoryConfig.getLocation(), ".indexer" ), null, null, - ArchivaNexusIndexerUtil.FULL_INDEX ); + q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ), + Occur.SHOULD ); + q.add( + indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), + Occur.SHOULD ); + + IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(), + new File( repositoryConfig.getLocation() ), + new File( repositoryConfig.getLocation(), ".indexer" ), + null, null, ArchivaNexusIndexerUtil.FULL_INDEX ); context.setSearchable( true ); FlatSearchRequest request = new FlatSearchRequest( q ); @@ -177,9 +181,8 @@ public class ArchivaIndexingTaskExecutorTest public void testUpdateArtifactInIndex() throws Exception { - File artifactFile = - new File( repositoryConfig.getLocation(), - "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); + File artifactFile = new File( repositoryConfig.getLocation(), + "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); @@ -188,10 +191,14 @@ public class ArchivaIndexingTaskExecutorTest indexingExecutor.executeTask( task ); BooleanQuery q = new BooleanQuery(); - q.add( indexer.constructQuery( ArtifactInfo.GROUP_ID, "org.apache.archiva" ), Occur.SHOULD ); - q.add( indexer.constructQuery( ArtifactInfo.ARTIFACT_ID, "archiva-index-methods-jar-test" ), Occur.SHOULD ); - - IndexSearcher searcher = new IndexSearcher( repositoryConfig.getLocation() + "/.indexer" ); + q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ), + Occur.SHOULD ); + q.add( + indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), + Occur.SHOULD ); + + IndexSearcher searcher = + new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) ); TopDocs topDocs = searcher.search( q, null, 10 ); searcher.close(); @@ -207,9 +214,8 @@ public class ArchivaIndexingTaskExecutorTest public void testRemoveArtifactFromIndex() throws Exception { - File artifactFile = - new File( repositoryConfig.getLocation(), - "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); + File artifactFile = new File( repositoryConfig.getLocation(), + "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); @@ -218,10 +224,15 @@ public class ArchivaIndexingTaskExecutorTest indexingExecutor.executeTask( task ); BooleanQuery q = new BooleanQuery(); - q.add( indexer.constructQuery( ArtifactInfo.GROUP_ID, "org.apache.archiva" ), Occur.SHOULD ); - q.add( indexer.constructQuery( ArtifactInfo.ARTIFACT_ID, "archiva-index-methods-jar-test" ), Occur.SHOULD ); + q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ), + Occur.SHOULD ); + q.add( + indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), + Occur.SHOULD ); + + IndexSearcher searcher = + new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) ); - IndexSearcher searcher = new IndexSearcher( repositoryConfig.getLocation() + "/.indexer" ); TopDocs topDocs = searcher.search( q, null, 10 ); searcher.close(); @@ -244,10 +255,15 @@ public class ArchivaIndexingTaskExecutorTest indexingExecutor.executeTask( task ); q = new BooleanQuery(); - q.add( indexer.constructQuery( ArtifactInfo.GROUP_ID, "org.apache.archiva" ), Occur.SHOULD ); - q.add( indexer.constructQuery( ArtifactInfo.ARTIFACT_ID, "archiva-index-methods-jar-test" ), Occur.SHOULD ); + q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ), + Occur.SHOULD ); + q.add( + indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), + Occur.SHOULD ); + + searcher = + new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) ); - searcher = new IndexSearcher( repositoryConfig.getLocation() + "/.indexer" ); topDocs = searcher.search( q, null, 10 ); assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() ); @@ -265,9 +281,8 @@ public class ArchivaIndexingTaskExecutorTest public void testPackagedIndex() throws Exception { - File artifactFile = - new File( repositoryConfig.getLocation(), - "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); + File artifactFile = new File( repositoryConfig.getLocation(), + "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); @@ -286,13 +301,15 @@ public class ArchivaIndexingTaskExecutorTest unzipIndex( new File( repositoryConfig.getLocation(), ".index" ).getPath(), destDir.getPath() ); BooleanQuery q = new BooleanQuery(); - q.add( indexer.constructQuery( ArtifactInfo.GROUP_ID, "org.apache.archiva" ), Occur.SHOULD ); - q.add( indexer.constructQuery( ArtifactInfo.ARTIFACT_ID, "archiva-index-methods-jar-test" ), Occur.SHOULD ); - - IndexingContext context = - indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(), - new File( repositoryConfig.getLocation() ), destDir, null, null, - ArchivaNexusIndexerUtil.FULL_INDEX ); + q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ), + Occur.SHOULD ); + q.add( + indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), + Occur.SHOULD ); + + IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(), + new File( repositoryConfig.getLocation() ), destDir, null, + null, ArchivaNexusIndexerUtil.FULL_INDEX ); context.setSearchable( true ); FlatSearchRequest request = new FlatSearchRequest( q ); |