]> source.dussan.org Git - archiva.git/commitdiff
Somewhat working
authorJames William Dumay <jdumay@apache.org>
Thu, 18 Dec 2008 09:33:20 +0000 (09:33 +0000)
committerJames William Dumay <jdumay@apache.org>
Thu, 18 Dec 2008 09:33:20 +0000 (09:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-obr-repository@727681 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/pom.xml
archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/main/java/org/apache/archiva/consumers/OBRRepositoryConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/test/java/org/apache/archiva/consumers/OBRRepositoryConsumerTest.java

index 102f7d9e2f84831c2562c2720c13cc085cfe7e6d..7798090ea0ffb855869c9a1ec42f24840c39f9e9 100644 (file)
     <version>1.2-SNAPSHOT</version>
     <url>http://maven.apache.org</url>
     <dependencies>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-        </dependency>
         <dependency>
           <groupId>org.apache.archiva</groupId>
           <artifactId>archiva-database</artifactId>
index f7d86f4071754acb3ff01163d9441f15524674dc..e59187cc820f63a6227b7f73ede7a8754893ac8e 100644 (file)
@@ -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);
-            }
-        }
     }
 
 }
index aec5a619c268d33fa4857e8539ca92197b56f9f3..deab25e769ba1f8f8fd494c7ca47833577bac5ca 100644 (file)
@@ -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());
     }
 }