mirror of https://github.com/apache/archiva.git
some progress on new indexer
Signed-off-by: olivier lamy <olamy@apache.org>
This commit is contained in:
parent
ddbb6cdaf4
commit
0bfead8264
|
@ -20,18 +20,11 @@ package org.apache.archiva.common.plexusbridge;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.index.context.IndexCreator;
|
import org.apache.maven.index.context.IndexCreator;
|
||||||
import org.apache.maven.index.creator.JarFileContentsIndexCreator;
|
|
||||||
import org.apache.maven.index.creator.MavenArchetypeArtifactInfoIndexCreator;
|
|
||||||
import org.apache.maven.index.creator.MavenPluginArtifactInfoIndexCreator;
|
|
||||||
import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator;
|
|
||||||
import org.apache.maven.index.creator.OsgiArtifactIndexCreator;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,32 +37,14 @@ public class MavenIndexerUtils
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||||
|
|
||||||
|
@Inject
|
||||||
private List<? extends IndexCreator> allIndexCreators;
|
private List<? extends IndexCreator> allIndexCreators;
|
||||||
|
|
||||||
@Inject
|
public MavenIndexerUtils()
|
||||||
public MavenIndexerUtils( PlexusSisuBridge plexusSisuBridge )
|
|
||||||
throws PlexusSisuBridgeException
|
|
||||||
{
|
{
|
||||||
allIndexCreators = new ArrayList( plexusSisuBridge.lookupList( IndexCreator.class ) );
|
|
||||||
|
|
||||||
if ( allIndexCreators == null || allIndexCreators.isEmpty() )
|
if ( allIndexCreators == null || allIndexCreators.isEmpty() )
|
||||||
{
|
{
|
||||||
// olamy when the TCL is not a URLClassLoader lookupList fail !
|
throw new RuntimeException( "cannot initiliaze IndexCreators" );
|
||||||
// when using tomcat maven plugin so adding a simple hack
|
|
||||||
log.warn( "using lookupList from sisu plexus failed so build indexCreator manually" );
|
|
||||||
|
|
||||||
allIndexCreators =
|
|
||||||
Arrays.asList( plexusSisuBridge.lookup( IndexCreator.class, OsgiArtifactIndexCreator.ID ),
|
|
||||||
plexusSisuBridge.lookup( IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID ),
|
|
||||||
plexusSisuBridge.lookup( IndexCreator.class, MinimalArtifactInfoIndexCreator.ID ),
|
|
||||||
plexusSisuBridge.lookup( IndexCreator.class, JarFileContentsIndexCreator.ID ),
|
|
||||||
plexusSisuBridge.lookup( IndexCreator.class, MavenPluginArtifactInfoIndexCreator.ID ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( allIndexCreators == null || allIndexCreators.isEmpty() )
|
|
||||||
{
|
|
||||||
throw new PlexusSisuBridgeException( "no way to initiliaze IndexCreator" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug( "allIndexCreators {}", allIndexCreators );
|
log.debug( "allIndexCreators {}", allIndexCreators );
|
||||||
|
|
|
@ -28,5 +28,5 @@
|
||||||
default-lazy-init="true">
|
default-lazy-init="true">
|
||||||
|
|
||||||
<context:annotation-config/>
|
<context:annotation-config/>
|
||||||
<context:component-scan base-package="org.apache.archiva.common.plexusbridge"/>
|
<context:component-scan base-package="org.apache.archiva.common.plexusbridge,org.apache.maven.index"/>
|
||||||
</beans>
|
</beans>
|
|
@ -40,16 +40,10 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.indexer</groupId>
|
<groupId>org.apache.maven.indexer</groupId>
|
||||||
<artifactId>indexer-core</artifactId>
|
<artifactId>indexer-core</artifactId>
|
||||||
<exclusions>
|
</dependency>
|
||||||
<exclusion>
|
<dependency>
|
||||||
<groupId>org.sonatype.sisu</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>sisu-guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.sonatype.sisu</groupId>
|
|
||||||
<artifactId>sisu-guice</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.archetype</groupId>
|
<groupId>org.apache.maven.archetype</groupId>
|
||||||
|
|
|
@ -23,9 +23,6 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
import org.apache.archiva.admin.model.beans.RemoteRepository;
|
import org.apache.archiva.admin.model.beans.RemoteRepository;
|
||||||
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
||||||
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
|
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
|
||||||
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
|
|
||||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
|
||||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
|
||||||
import org.apache.archiva.configuration.Configuration;
|
import org.apache.archiva.configuration.Configuration;
|
||||||
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
|
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
|
||||||
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
||||||
|
@ -60,29 +57,15 @@ public class DefaultRemoteRepositoryAdmin
|
||||||
{
|
{
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlexusSisuBridge plexusSisuBridge;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private MavenIndexerUtils mavenIndexerUtils;
|
|
||||||
|
|
||||||
// fields
|
|
||||||
private List<? extends IndexCreator> indexCreators;
|
private List<? extends IndexCreator> indexCreators;
|
||||||
|
|
||||||
|
@Inject
|
||||||
private NexusIndexer indexer;
|
private NexusIndexer indexer;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initialize()
|
private void initialize()
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
indexCreators = mavenIndexerUtils.getAllIndexCreators();
|
|
||||||
indexer = plexusSisuBridge.lookup( NexusIndexer.class );
|
|
||||||
}
|
|
||||||
catch ( PlexusSisuBridgeException e )
|
|
||||||
{
|
|
||||||
throw new RepositoryAdminException( e.getMessage(), e );
|
|
||||||
}
|
|
||||||
for ( RemoteRepository remoteRepository : getRemoteRepositories() )
|
for ( RemoteRepository remoteRepository : getRemoteRepositories() )
|
||||||
{
|
{
|
||||||
createIndexContext( remoteRepository );
|
createIndexContext( remoteRepository );
|
||||||
|
@ -323,7 +306,7 @@ public class DefaultRemoteRepositoryAdmin
|
||||||
}
|
}
|
||||||
return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir, indexDirectory,
|
return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir, indexDirectory,
|
||||||
remoteRepository.getUrl(), calculateIndexRemoteUrl( remoteRepository ),
|
remoteRepository.getUrl(), calculateIndexRemoteUrl( remoteRepository ),
|
||||||
mavenIndexerUtils.getAllIndexCreators() );
|
indexCreators );
|
||||||
}
|
}
|
||||||
catch ( MalformedURLException e )
|
catch ( MalformedURLException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
<context:annotation-config />
|
<context:annotation-config />
|
||||||
<context:component-scan
|
<context:component-scan
|
||||||
base-package="org.apache.archiva.admin.repository,org.apache.maven.index"/>
|
base-package="org.apache.archiva.admin.repository"/>
|
||||||
|
|
||||||
<alias name="redbackRuntimeConfigurationAdmin#default" alias="userConfiguration#archiva"/>
|
<alias name="redbackRuntimeConfigurationAdmin#default" alias="userConfiguration#archiva"/>
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.archiva.metadata.repository.jcr;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import org.apache.archiva.metadata.model.MetadataFacetFactory;
|
import org.apache.archiva.metadata.model.MetadataFacetFactory;
|
||||||
import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
|
import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
20
pom.xml
20
pom.xml
|
@ -86,7 +86,7 @@
|
||||||
<javaxMailVersion>1.4</javaxMailVersion>
|
<javaxMailVersion>1.4</javaxMailVersion>
|
||||||
<!--jettyVersion>9.4.5.v20170502</jettyVersion-->
|
<!--jettyVersion>9.4.5.v20170502</jettyVersion-->
|
||||||
<jettyVersion>9.4.7-SNAPSHOT</jettyVersion>
|
<jettyVersion>9.4.7-SNAPSHOT</jettyVersion>
|
||||||
<guava.version>22.0</guava.version>
|
<guava.version>15.0</guava.version>
|
||||||
<openjpaVersion>2.4.1</openjpaVersion>
|
<openjpaVersion>2.4.1</openjpaVersion>
|
||||||
|
|
||||||
<!-- restore when we will be able to use a derby in memory database -->
|
<!-- restore when we will be able to use a derby in memory database -->
|
||||||
|
@ -318,12 +318,30 @@
|
||||||
<groupId>com.google.code.atinject</groupId>
|
<groupId>com.google.code.atinject</groupId>
|
||||||
<artifactId>atinject</artifactId>
|
<artifactId>atinject</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.sonatype.sisu</groupId>
|
||||||
|
<artifactId>sisu-guava</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.sonatype.sisu</groupId>
|
||||||
|
<artifactId>sisu-guice</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.archetype</groupId>
|
<groupId>org.apache.maven.archetype</groupId>
|
||||||
<artifactId>archetype-common</artifactId>
|
<artifactId>archetype-common</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.1</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.sonatype.sisu</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
Loading…
Reference in New Issue