mirror of https://github.com/apache/archiva.git
[MRM-1473] remove of plexus-spring : fix archiva converter
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1128081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
992f6a96dd
commit
84f7fdad79
|
@ -44,6 +44,10 @@
|
|||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-repository-scanner</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-plexus-bridge</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-i18n</artifactId>
|
||||
|
|
|
@ -19,12 +19,7 @@ package org.apache.maven.archiva.converter.legacy;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScanner;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScannerException;
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
|
@ -35,8 +30,17 @@ import org.apache.maven.archiva.converter.RepositoryConversionException;
|
|||
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.component.repository.exception.ComponentLookupException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DefaultLegacyRepositoryConverter
|
||||
*
|
||||
|
@ -48,26 +52,37 @@ public class DefaultLegacyRepositoryConverter
|
|||
implements LegacyRepositoryConverter
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
* plexus.requirement
|
||||
*/
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="default"
|
||||
* plexus.requirement role-hint="default"
|
||||
*/
|
||||
private ArtifactRepositoryLayout defaultLayout;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* plexus.requirement role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="artifact-legacy-to-default-converter"
|
||||
*/
|
||||
@Inject
|
||||
@Named( value = "knownRepositoryContentConsumer#artifact-legacy-to-default-converter" )
|
||||
private LegacyConverterArtifactConsumer legacyConverterConsumer;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
* plexus.requirement
|
||||
*/
|
||||
@Inject
|
||||
private RepositoryScanner repoScanner;
|
||||
|
||||
@Inject
|
||||
public DefaultLegacyRepositoryConverter( PlexusSisuBridge plexusSisuBridge )
|
||||
throws ComponentLookupException
|
||||
{
|
||||
artifactRepositoryFactory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
|
||||
defaultLayout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
|
||||
}
|
||||
|
||||
public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory,
|
||||
List<String> fileExclusionPatterns )
|
||||
throws RepositoryConversionException
|
||||
|
@ -82,10 +97,9 @@ public class DefaultLegacyRepositoryConverter
|
|||
legacyRepository.setLocation( legacyRepositoryDirectory.getAbsolutePath() );
|
||||
legacyRepository.setLayout( "legacy" );
|
||||
|
||||
ArtifactRepository repository = artifactRepositoryFactory.createArtifactRepository( "default",
|
||||
defaultRepositoryUrl,
|
||||
defaultLayout, null,
|
||||
null );
|
||||
ArtifactRepository repository =
|
||||
artifactRepositoryFactory.createArtifactRepository( "default", defaultRepositoryUrl, defaultLayout,
|
||||
null, null );
|
||||
legacyConverterConsumer.setExcludes( fileExclusionPatterns );
|
||||
legacyConverterConsumer.setDestinationRepository( repository );
|
||||
|
||||
|
|
|
@ -19,10 +19,7 @@ package org.apache.maven.archiva.converter.legacy;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
|
@ -36,17 +33,23 @@ import org.apache.maven.archiva.repository.layout.LayoutException;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* LegacyConverterArtifactConsumer - convert artifacts as they are found
|
||||
* into the destination repository.
|
||||
*
|
||||
* @version $Id$
|
||||
*
|
||||
* <p/>
|
||||
* plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="artifact-legacy-to-default-converter"
|
||||
* instantiation-strategy="per-lookup"
|
||||
|
@ -60,12 +63,13 @@ public class LegacyConverterArtifactConsumer
|
|||
private Logger log = LoggerFactory.getLogger( LegacyConverterArtifactConsumer.class );
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="legacy-to-default"
|
||||
* plexus.requirement role-hint="legacy-to-default"
|
||||
*/
|
||||
@Inject
|
||||
private ArtifactConverter artifactConverter;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
* plexus.requirement
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
|
@ -77,12 +81,15 @@ public class LegacyConverterArtifactConsumer
|
|||
|
||||
private List<String> excludes;
|
||||
|
||||
public LegacyConverterArtifactConsumer()
|
||||
@Inject
|
||||
public LegacyConverterArtifactConsumer( PlexusSisuBridge plexusSisuBridge )
|
||||
throws ComponentLookupException
|
||||
{
|
||||
includes = new ArrayList<String>();
|
||||
includes.add( "**/*.jar" );
|
||||
includes.add( "**/*.ear" );
|
||||
includes.add( "**/*.war" );
|
||||
artifactFactory = plexusSisuBridge.lookup( ArtifactFactory.class );
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
|
||||
|
@ -100,7 +107,7 @@ public class LegacyConverterArtifactConsumer
|
|||
|
||||
public void completeScan()
|
||||
{
|
||||
|
||||
// no op
|
||||
}
|
||||
|
||||
public void completeScan( boolean executeOnEntireRepo )
|
||||
|
|
|
@ -19,18 +19,26 @@ package org.apache.maven.archiva.converter;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.converter.legacy.LegacyRepositoryConverter;
|
||||
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.spring.PlexusInSpringTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Test the repository converter.
|
||||
|
@ -40,32 +48,43 @@ import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
|||
* @todo should reject if dependencies are missing - rely on reporting?
|
||||
* @todo group metadata
|
||||
*/
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
|
||||
public class RepositoryConverterTest
|
||||
extends PlexusInSpringTestCase
|
||||
extends TestCase
|
||||
{
|
||||
private ArtifactRepository sourceRepository;
|
||||
|
||||
private ManagedRepositoryConfiguration targetRepository;
|
||||
|
||||
@Inject
|
||||
@Named(value = "legacyRepositoryConverter#default")
|
||||
private LegacyRepositoryConverter repositoryConverter;
|
||||
|
||||
protected void setUp()
|
||||
@Inject
|
||||
PlexusSisuBridge plexusSisuBridge;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||
ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
|
||||
//(ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||
|
||||
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
|
||||
ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "legacy" );
|
||||
//(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
|
||||
|
||||
File sourceBase = getTestFile( "src/test/source-repository" );
|
||||
File sourceBase = new File( "src/test/source-repository" );
|
||||
sourceRepository = factory.createArtifactRepository( "source", sourceBase.toURL().toString(), layout, null,
|
||||
null );
|
||||
|
||||
layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||
layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
|
||||
//(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||
|
||||
File targetBase = getTestFile( "target/test-target-repository" );
|
||||
copyDirectoryStructure( getTestFile( "src/test/target-repository" ), targetBase );
|
||||
File targetBase = new File( "target/test-target-repository" );
|
||||
copyDirectoryStructure( new File( "src/test/target-repository" ), targetBase );
|
||||
|
||||
targetRepository = new ManagedRepositoryConfiguration();
|
||||
targetRepository.setId( "target" );
|
||||
|
@ -73,7 +92,7 @@ public class RepositoryConverterTest
|
|||
targetRepository.setLocation( targetBase.getAbsolutePath() );
|
||||
targetRepository.setLayout( "default" );
|
||||
|
||||
repositoryConverter = (LegacyRepositoryConverter) lookup( LegacyRepositoryConverter.ROLE, "default" );
|
||||
//repositoryConverter = (LegacyRepositoryConverter) lookup( LegacyRepositoryConverter.ROLE, "default" );
|
||||
}
|
||||
|
||||
protected void tearDown()
|
||||
|
@ -129,6 +148,7 @@ public class RepositoryConverterTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLegacyConversion()
|
||||
throws IOException, RepositoryConversionException
|
||||
{
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
||||
default-lazy-init="true">
|
||||
|
||||
|
||||
</beans>
|
Loading…
Reference in New Issue