--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project-shared-configuration>
+ <!--
+This file contains additional configuration written by modules in the NetBeans IDE.
+The configuration is intended to be shared among all the users of project and
+therefore it is assumed to be part of version control checkout.
+Without this configuration present, some functionality in the IDE may be limited or fail altogether.
+-->
+ <spring-data xmlns="http://www.netbeans.org/ns/spring-data/1">
+ <config-files>
+ <config-file>src/main/resources/META-INF/spring-context.xml</config-file>
+ </config-files>
+ <config-file-groups/>
+ </spring-data>
+</project-shared-configuration>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>archiva-consumers</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <version>1.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-obr-consumer</artifactId>
+ <name>archiva-obr-consumer</name>
+ <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>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-consumer-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-layer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi.impl.bundle.bindex</groupId>
+ <artifactId>bindex</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2008 jdumay.
+ *
+ * Licensed 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.
+ * under the License.
+ */
+
+package org.apache.archiva.consumers;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+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.osgi.impl.bundle.bindex.ant.BindexTask;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ *
+ * @author jdumay
+ */
+public class OBRRepositoryConsumer
+ extends AbstractMonitoredConsumer
+ implements KnownRepositoryContentConsumer, ApplicationContextAware
+{
+ 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";
+ }
+
+ public String getId() {
+ return "create-obr-repositoryxml";
+ }
+
+ public boolean isPermanent() {
+ return false;
+ }
+
+ public void beginScan(ManagedRepositoryConfiguration repository, Date whenGathered) throws ConsumerException {
+ content = new ManagedDefaultRepositoryContent();
+ content.setRepository(repository);
+ }
+
+ public void completeScan() {
+ /** do nothing **/
+ }
+
+ public List<String> getExcludes() {
+ return null;
+ }
+
+ public List<String> getIncludes() {
+ return Arrays.asList("**/*.jar");
+ }
+
+ public void processFile(String path)
+ throws ConsumerException
+ {
+ BindexTask task = new BindexTask();
+ File temporaryBindexLocation = new File(path, ".bindex");
+ temporaryBindexLocation.mkdirs();
+ task.setRepositoryFile(new File(temporaryBindexLocation, "repository.xml"));
+ task.setName(content.getRepository().getName());
+ task.setQuiet(true);
+ task.setRoot(new File(content.getRepoRoot()));
+
+ FileSet fileSet = new FileSet();
+ fileSet.setIncludesfile(new File(path));
+ try
+ {
+ task.execute();
+ }
+ catch (BuildException e)
+ {
+ 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);
+ }
+ }
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+ <bean id="obrRepositoryConsumer" class="org.apache.archiva.consumers.OBRRepositoryConsumer"/>
+</beans>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2008 jdumay.
+ *
+ * Licensed 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.
+ * under the License.
+ */
+
+package org.apache.archiva.consumers;
+
+import java.io.File;
+import java.util.Date;
+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
+{
+ private OBRRepositoryConsumer consumer;
+
+ private File testRepo;
+
+ private ManagedRepositoryConfiguration configuration;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ File testRepoData = new File("src/test/resources/repository");
+ testRepo = new File("target/obrtestrepo").getAbsoluteFile();
+ testRepo.mkdirs();
+ consumer = (OBRRepositoryConsumer)lookup(PlexusToSpringUtils.buildSpringId(OBRRepositoryConsumer.class));
+ FileUtils.copyDirectory(testRepoData, testRepo);
+ configuration = new ManagedRepositoryConfiguration();
+ configuration.setName("My Test OSGi repository");
+ configuration.setId("test-obr-osgi-repo");
+ configuration.setLocation(testRepo.getAbsolutePath());
+ consumer.beginScan(configuration, new Date());
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ 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 should exist", repositoryXml.exists());
+ }
+}
~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ --><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.archiva</groupId>
<module>archiva-lucene-consumers</module>
<module>archiva-signature-consumers</module>
<module>archiva-dependency-tree-consumer</module>
+ <module>archiva-obr-consumer</module>
</modules>
<build>
</plugin>
</plugins>
</build>
-</project>
+</project>
\ No newline at end of file