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;
/**
*
*/
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";
}
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();
{
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);
- }
- }
}
}
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;
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");
throws Exception
{
super.tearDown();
- FileUtils.deleteDirectory(testRepo);
+ //FileUtils.deleteDirectory(testRepo);
}
public void testCreatesRepositoryXml() throws Exception
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());
}
}