From: Jevica Arianne B. Zurbano Date: Tue, 27 Apr 2010 10:29:58 +0000 (+0000) Subject: [MRM-1345] MRM-1345 update use of Nexus indexer X-Git-Tag: archiva-1.4-M1~951 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6a2661f86613f73c19289d2edc2986f08d5b454b;p=archiva.git [MRM-1345] MRM-1345 update use of Nexus indexer * applied patch * moved the constant in a new class Submitted by: Gwen Harold Autencio updated dependency versions: * nexus-indexer 2.0.5 * plexus-utils 1.5.5 git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@938402 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java index 8ce2f2c8a..31e1e1a1c 100644 --- a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java +++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java @@ -933,7 +933,7 @@ public class LegacyToDefaultConverterTest private static String normalizeString( String path ) { - return path.trim().replaceAll( "\r\n", "\n" ).replace( '\r', '\n' ).replaceAll( "<\\?xml .+\\?>", "" ); + return path.trim().replaceAll( "\r\n", "\n" ).replace( '\r', '\n' ).replaceAll( "<\\?xml .+\\?>", "" ).replaceAll("^\\s+", ""); } private void checkSuccess( ArtifactConverter converter ) diff --git a/archiva-modules/archiva-base/archiva-common/pom.xml b/archiva-modules/archiva-base/archiva-common/pom.xml index 995be9b2f..45d0dacf3 100644 --- a/archiva-modules/archiva-base/archiva-common/pom.xml +++ b/archiva-modules/archiva-base/archiva-common/pom.xml @@ -66,6 +66,10 @@ 1.6.1 test + + org.sonatype.nexus + nexus-indexer + diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/ArchivaNexusIndexerUtil.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/ArchivaNexusIndexerUtil.java new file mode 100644 index 000000000..ebac81159 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/ArchivaNexusIndexerUtil.java @@ -0,0 +1,41 @@ +package org.apache.maven.archiva.common.utils; + +/* + * 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.util.Arrays; +import java.util.List; + +import org.sonatype.nexus.index.context.IndexCreator; +import org.sonatype.nexus.index.creator.JarFileContentsIndexCreator; +import org.sonatype.nexus.index.creator.MavenPluginArtifactInfoIndexCreator; +import org.sonatype.nexus.index.creator.MinimalArtifactInfoIndexCreator; + +/** + * ArchivaNexusIndexerUtil + * + */ +public class ArchivaNexusIndexerUtil +{ + public static final List FULL_INDEX = Arrays.asList( + new MinimalArtifactInfoIndexCreator(), + new JarFileContentsIndexCreator(), + new MavenPluginArtifactInfoIndexCreator() ); + +} diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java index 3c8f5a577..9ea86474c 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java @@ -28,6 +28,7 @@ import java.util.Set; import org.apache.archiva.indexer.util.SearchUtil; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanClause.Occur; +import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -216,7 +217,7 @@ public class NexusRepositorySearch IndexingContext context = indexer.addIndexingContext( repoConfig.getId(), repoConfig.getId(), new File( repoConfig.getLocation() ), - indexDirectory, null, null, NexusIndexer.FULL_INDEX ); + indexDirectory, null, null, ArchivaNexusIndexerUtil.FULL_INDEX ); context.setSearchable( repoConfig.isScanned() ); } else diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java index b79a116e7..b31c61491 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java @@ -25,11 +25,13 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.io.FileUtils; +import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; +import org.sonatype.nexus.artifact.IllegalArtifactCoordinateException; import org.sonatype.nexus.index.ArtifactContext; import org.sonatype.nexus.index.ArtifactContextProducer; import org.sonatype.nexus.index.NexusIndexer; @@ -85,7 +87,7 @@ public class NexusRepositorySearchTest } private void createIndexForQuickSearch() - throws IOException, UnsupportedExistingLuceneIndexException + throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException { List files = new ArrayList(); files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + @@ -126,11 +128,11 @@ public class NexusRepositorySearchTest } private void createIndex( String repository, List filesToBeIndexed ) - throws IOException, UnsupportedExistingLuceneIndexException + throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException { context = new DefaultIndexingContext( repository, repository, new File( getBasedir(), "/target/test-classes/" + repository ), new File( getBasedir(), "/target/test-classes/" + repository + "/.indexer" ), null, null, - NexusIndexer.FULL_INDEX, false ); + ArchivaNexusIndexerUtil.FULL_INDEX, false ); //indexer.addIndexingContext( repository, repository, new File( getBasedir(), "/target/test-classes/" + // repository ), new File( getBasedir(), "/target/test-classes/" + repository + "/.indexer" ), null, null, // NexusIndexer.FULL_INDEX ); 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 04ab728e9..831c86e6c 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 @@ -32,6 +32,7 @@ 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; @@ -170,6 +171,11 @@ public class ArchivaIndexingTaskExecutor throw new TaskExecutionException( "Error occurred while executing indexing task '" + indexingTask + "'", e ); } + catch ( IllegalArtifactCoordinateException e ) + { + log.error( "Error occurred while getting artifact context: " + e.getMessage() ); + throw new TaskExecutionException( "Error occurred while getting artifact context.", e ); + } } } } 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 79207e731..9b600334d 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 @@ -22,9 +22,9 @@ package org.apache.archiva.scheduler.indexing; import java.io.File; import java.io.IOException; +import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.codehaus.plexus.taskqueue.Task; -import org.sonatype.nexus.index.NexusIndexer; import org.sonatype.nexus.index.context.DefaultIndexingContext; import org.sonatype.nexus.index.context.IndexingContext; import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException; @@ -139,7 +139,7 @@ public class ArtifactIndexingTask IndexingContext context = new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory, - null, null, NexusIndexer.FULL_INDEX, false ); + null, null, ArchivaNexusIndexerUtil.FULL_INDEX, false ); context.setSearchable( repository.isScanned() ); return context; } 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 bdc934c5d..077299c39 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 @@ -35,6 +35,7 @@ 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.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.codehaus.plexus.spring.PlexusInSpringTestCase; @@ -134,7 +135,7 @@ public class ArchivaIndexingTaskExecutorTest indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(), new File( repositoryConfig.getLocation() ), new File( repositoryConfig.getLocation(), ".indexer" ), null, null, - NexusIndexer.FULL_INDEX ); + ArchivaNexusIndexerUtil.FULL_INDEX ); context.setSearchable( true ); FlatSearchRequest request = new FlatSearchRequest( q ); @@ -270,7 +271,7 @@ public class ArchivaIndexingTaskExecutorTest IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(), new File( repositoryConfig.getLocation() ), destDir, null, null, - NexusIndexer.FULL_INDEX ); + ArchivaNexusIndexerUtil.FULL_INDEX ); context.setSearchable( true ); FlatSearchRequest request = new FlatSearchRequest( q ); diff --git a/pom.xml b/pom.xml index bb7f443fa..363b1a491 100644 --- a/pom.xml +++ b/pom.xml @@ -251,7 +251,7 @@ org.sonatype.nexus nexus-indexer - 2.0.0 + 2.0.5 org.codehaus.plexus @@ -688,7 +688,7 @@ org.codehaus.plexus plexus-utils - 1.4.5 + 1.5.5 org.codehaus.plexus.cache