summaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-05-26 20:54:42 +0000
committerOlivier Lamy <olamy@apache.org>2011-05-26 20:54:42 +0000
commit84f7fdad794712820950be6c2e18cadf9693238e (patch)
tree7c656582179ad4a4e860ebcf31f4fb30b6c0e8a1 /archiva-modules
parent992f6a96ddabe760c5d0f8caee95128e8af6d65d (diff)
downloadarchiva-84f7fdad794712820950be6c2e18cadf9693238e.tar.gz
archiva-84f7fdad794712820950be6c2e18cadf9693238e.zip
[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
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-base/archiva-converter/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java52
-rw-r--r--archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java41
-rw-r--r--archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java50
-rw-r--r--archiva-modules/archiva-base/archiva-converter/src/test/resources/spring-context.xml31
5 files changed, 127 insertions, 51 deletions
diff --git a/archiva-modules/archiva-base/archiva-converter/pom.xml b/archiva-modules/archiva-base/archiva-converter/pom.xml
index 0552ef742..25b1888e0 100644
--- a/archiva-modules/archiva-base/archiva-converter/pom.xml
+++ b/archiva-modules/archiva-base/archiva-converter/pom.xml
@@ -45,6 +45,10 @@
<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>
</dependency>
diff --git a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
index ddeafce7a..402bb70cc 100644
--- a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
+++ b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
@@ -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,39 +30,59 @@ 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
+ * DefaultLegacyRepositoryConverter
*
* @version $Id$
- * plexus.component
+ * plexus.component
*/
-@Service("legacyRepositoryConverter#default")
+@Service( "legacyRepositoryConverter#default" )
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"
- * role-hint="artifact-legacy-to-default-converter"
+ * 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
@@ -77,15 +92,14 @@ public class DefaultLegacyRepositoryConverter
String defaultRepositoryUrl = PathUtil.toUrl( repositoryDirectory );
ManagedRepositoryConfiguration legacyRepository = new ManagedRepositoryConfiguration();
- legacyRepository.setId( "legacy");
+ legacyRepository.setId( "legacy" );
legacyRepository.setName( "Legacy Repository" );
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 );
diff --git a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java
index a7f73843d..5a9c41812 100644
--- a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java
+++ b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java
@@ -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,53 +33,63 @@ 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.
+ * into the destination repository.
*
* @version $Id$
- *
- * plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
- * role-hint="artifact-legacy-to-default-converter"
- * instantiation-strategy="per-lookup"
+ * <p/>
+ * plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ * role-hint="artifact-legacy-to-default-converter"
+ * instantiation-strategy="per-lookup"
*/
-@Service("knownRepositoryContentConsumer#artifact-legacy-to-default-converter")
-@Scope("prototype")
+@Service( "knownRepositoryContentConsumer#artifact-legacy-to-default-converter" )
+@Scope( "prototype" )
public class LegacyConverterArtifactConsumer
extends AbstractMonitoredConsumer
implements KnownRepositoryContentConsumer
{
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;
private ManagedRepositoryContent managedRepository;
-
+
private ArtifactRepository destinationRepository;
private List<String> includes;
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 )
diff --git a/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java b/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java
index e8da73550..3113639cf 100644
--- a/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java
+++ b/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java
@@ -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
{
diff --git a/archiva-modules/archiva-base/archiva-converter/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-converter/src/test/resources/spring-context.xml
new file mode 100644
index 000000000..60142d781
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-converter/src/test/resources/spring-context.xml
@@ -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> \ No newline at end of file