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 )
<version>1.6.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-indexer</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
--- /dev/null
+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<? extends IndexCreator> FULL_INDEX = Arrays.<IndexCreator>asList(
+ new MinimalArtifactInfoIndexCreator(),
+ new JarFileContentsIndexCreator(),
+ new MavenPluginArtifactInfoIndexCreator() );
+
+}
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;
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
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;
}
private void createIndexForQuickSearch()
- throws IOException, UnsupportedExistingLuceneIndexException
+ throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException
{
List<File> files = new ArrayList<File>();
files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 +
}
private void createIndex( String repository, List<File> 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 );
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;
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 );
+ }
}
}
}
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;
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;
}
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;
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 );
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 );
<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-indexer</artifactId>
- <version>2.0.0</version>
+ <version>2.0.5</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>1.4.5</version>
+ <version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus.cache</groupId>