From 8d229d1d604f12524fb6fb0a89d297972bddb553 Mon Sep 17 00:00:00 2001 From: James William Dumay Date: Thu, 18 Dec 2008 09:33:20 +0000 Subject: [PATCH] Somewhat working git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-obr-repository@727681 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-obr-consumer/pom.xml | 4 --- .../consumers/OBRRepositoryConsumer.java | 32 ++++--------------- .../consumers/OBRRepositoryConsumerTest.java | 11 ++++--- 3 files changed, 13 insertions(+), 34 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/pom.xml index 102f7d9e2..7798090ea 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/pom.xml @@ -31,10 +31,6 @@ 1.2-SNAPSHOT http://maven.apache.org - - org.springframework - spring-context - org.apache.archiva archiva-database diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/main/java/org/apache/archiva/consumers/OBRRepositoryConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/main/java/org/apache/archiva/consumers/OBRRepositoryConsumer.java index f7d86f407..e59187cc8 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/main/java/org/apache/archiva/consumers/OBRRepositoryConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/main/java/org/apache/archiva/consumers/OBRRepositoryConsumer.java @@ -31,11 +31,8 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.FileSet; -import org.osgi.impl.bundle.bindex.Index; +import org.apache.tools.ant.types.selectors.FilenameSelector; import org.osgi.impl.bundle.bindex.ant.BindexTask; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; /** * @@ -43,14 +40,10 @@ import org.springframework.context.ApplicationContextAware; */ public class OBRRepositoryConsumer extends AbstractMonitoredConsumer - implements KnownRepositoryContentConsumer, ApplicationContextAware + implements KnownRepositoryContentConsumer { private ManagedRepositoryContent content; - public void setApplicationContext(ApplicationContext context) throws BeansException { - throw new UnsupportedOperationException("Not supported yet."); - } - public String getDescription() { return "Produces the OSGi OBR repository index"; } @@ -84,15 +77,15 @@ public class OBRRepositoryConsumer throws ConsumerException { BindexTask task = new BindexTask(); - File temporaryBindexLocation = new File(path, ".bindex"); - temporaryBindexLocation.mkdirs(); - task.setRepositoryFile(new File(temporaryBindexLocation, "repository.xml")); + File repositoryIndexFile = new File(new File(path).getParentFile(), ".repository.xml"); + task.setRepositoryFile(repositoryIndexFile); task.setName(content.getRepository().getName()); - task.setQuiet(true); + task.setQuiet(false); task.setRoot(new File(content.getRepoRoot())); FileSet fileSet = new FileSet(); - fileSet.setIncludesfile(new File(path)); + fileSet.setDir(new File(path).getParentFile()); + fileSet.setIncludes("**/*.jar"); try { task.execute(); @@ -101,17 +94,6 @@ public class OBRRepositoryConsumer { throw new ConsumerException("Could not add jar " + path + " to obr repository.xml", e); } - finally - { - try - { - FileUtils.deleteDirectory(temporaryBindexLocation); - } - catch (IOException e) - { - throw new ConsumerException(e.getMessage(), e); - } - } } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/test/java/org/apache/archiva/consumers/OBRRepositoryConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/test/java/org/apache/archiva/consumers/OBRRepositoryConsumerTest.java index aec5a619c..deab25e76 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/test/java/org/apache/archiva/consumers/OBRRepositoryConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/test/java/org/apache/archiva/consumers/OBRRepositoryConsumerTest.java @@ -19,16 +19,15 @@ package org.apache.archiva.consumers; import java.io.File; import java.util.Date; +import junit.framework.TestCase; import org.apache.commons.io.FileUtils; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import org.codehaus.plexus.spring.PlexusToSpringUtils; /** * * @author jdumay */ -public class OBRRepositoryConsumerTest extends PlexusInSpringTestCase +public class OBRRepositoryConsumerTest extends TestCase { private OBRRepositoryConsumer consumer; @@ -43,7 +42,7 @@ public class OBRRepositoryConsumerTest extends PlexusInSpringTestCase File testRepoData = new File("src/test/resources/repository"); testRepo = new File("target/obrtestrepo").getAbsoluteFile(); testRepo.mkdirs(); - consumer = (OBRRepositoryConsumer)lookup(PlexusToSpringUtils.buildSpringId(OBRRepositoryConsumer.class)); + consumer = new OBRRepositoryConsumer(); FileUtils.copyDirectory(testRepoData, testRepo); configuration = new ManagedRepositoryConfiguration(); configuration.setName("My Test OSGi repository"); @@ -57,7 +56,7 @@ public class OBRRepositoryConsumerTest extends PlexusInSpringTestCase throws Exception { super.tearDown(); - FileUtils.deleteDirectory(testRepo); + //FileUtils.deleteDirectory(testRepo); } public void testCreatesRepositoryXml() throws Exception @@ -65,6 +64,8 @@ public class OBRRepositoryConsumerTest extends PlexusInSpringTestCase File repositoryXml = new File(configuration.getLocation(), "repository.xml"); assertFalse("repository.xml should not exist", repositoryXml.exists()); consumer.processFile(new File(testRepo, "./commons-codec/commons-codec/1.3.0/commons-codec-1.3.0.jar").getAbsolutePath()); + + assertTrue(".repository.xml iterim file should exist", new File(testRepo, "commons-codec/commons-codec/1.3.0/.repository.xml").exists()); assertTrue("repository.xml should exist", repositoryXml.exists()); } } -- 2.39.5