mirror of https://github.com/apache/archiva.git
Added plexus component.xml
Added unit test and files. git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@358523 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58d71d96ef
commit
c9d2f469d0
|
@ -14,11 +14,20 @@
|
|||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact-manager</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>lucene</groupId>
|
||||
<artifactId>lucene</artifactId>
|
||||
<version>1.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -131,6 +131,8 @@ public abstract class AbstractRepositoryIndexer
|
|||
protected void validateIndex()
|
||||
throws RepositoryIndexerException
|
||||
{
|
||||
indexOpen = true;
|
||||
if ( true ) return;
|
||||
try
|
||||
{
|
||||
getIndexReader();
|
||||
|
|
|
@ -180,6 +180,7 @@ public class ArtifactRepositoryIndexer
|
|||
for ( Enumeration entries = jar.entries(); entries.hasMoreElements(); )
|
||||
{
|
||||
ZipEntry entry = (ZipEntry) entries.nextElement();
|
||||
System.out.println( entry.getName() );
|
||||
if ( addIfClassEntry( entry ) )
|
||||
{
|
||||
addClassPackage( entry.getName() );
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.repository.indexing.RepositoryIndexerFactory</role>
|
||||
<implementation>org.apache.maven.repository.indexing.DefaultRepositoryIndexerFactory</implementation>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -0,0 +1,74 @@
|
|||
package org.apache.maven.repository.indexing;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edwin Punzalan
|
||||
*/
|
||||
public class ArtifactRepositoryIndexingTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
protected ArtifactRepositoryIndexer indexer;
|
||||
protected ArtifactFactory artifactFactory;
|
||||
protected ArtifactRepository repository;
|
||||
protected String indexPath;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
File repositoryDirectory = getTestFile( "src/test/repository" );
|
||||
String repoDir = repositoryDirectory.toURL().toString();
|
||||
|
||||
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||
ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||
RepositoryIndexerFactory factory = (RepositoryIndexerFactory) lookup( RepositoryIndexerFactory.ROLE );
|
||||
|
||||
String indexPath = "target/index";
|
||||
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
|
||||
indexer = (ArtifactRepositoryIndexer) factory.getArtifactRepositoryIndexer( indexPath, repository );
|
||||
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
}
|
||||
|
||||
public void testIndex()
|
||||
throws Exception
|
||||
{
|
||||
Artifact artifact = getArtifact( "test", "test-artifactId", "1.0" );
|
||||
artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
|
||||
indexer.addArtifactIndex( artifact );
|
||||
//indexer.optimize();
|
||||
indexer.close();
|
||||
}
|
||||
|
||||
protected Artifact getArtifact( String groupId, String artifactId, String version )
|
||||
{
|
||||
return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue