[MRM-1025] separate metadata consumer so that it can be run from the CLI without a database

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@722073 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2008-12-01 13:47:06 +00:00
parent c648c751de
commit b15c784a54
7 changed files with 111 additions and 46 deletions

View File

@ -38,6 +38,12 @@
<version>1.2-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-metadata-consumer</artifactId>
<version>1.2-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-xml-tools</artifactId>

View File

@ -52,21 +52,6 @@
<artifactId>plexus-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency> <!-- TODO: version into parent -->
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-model</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency> <!-- TODO: version into parent -->
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency> <!-- TODO: version into parent, temporary coupling to file based repo -->
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-file</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<!-- test dependencies -->
<dependency>

View File

@ -1,3 +1,23 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>

View File

@ -0,0 +1,55 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>archiva-consumers</artifactId>
<groupId>org.apache.archiva</groupId>
<version>1.2-SNAPSHOT</version>
</parent>
<artifactId>archiva-metadata-consumer</artifactId>
<name>Archiva Metadata Consumer</name>
<dependencies>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-consumer-api</artifactId>
</dependency>
<dependency> <!-- TODO: version into parent -->
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-model</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency> <!-- TODO: version into parent -->
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency> <!-- TODO: version into parent, temporary coupling to file based repo -->
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-file</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-layer</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package org.apache.maven.archiva.consumers.core;
package org.apache.archiva.consumers.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -38,8 +38,6 @@ import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.RepositoryContentFactory;
import org.apache.maven.archiva.repository.RepositoryException;
import org.apache.maven.archiva.repository.layout.LayoutException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@ -47,7 +45,7 @@ import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
/**
* ArtifactUpdateDatabaseConsumer - Take an artifact off of disk and put it into the repository.
* Take an artifact off of disk and put it into the metadata repository.
*
* @version $Id: ArtifactUpdateDatabaseConsumer.java 718864 2008-11-19 06:33:35Z brett $
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
@ -77,13 +75,11 @@ public class ArchivaMetadataCreationConsumer
*/
private FileTypes filetypes;
private Date whenGathered;
/**
* @plexus.requirement
*/
private RepositoryContentFactory repositoryFactory;
private Date whenGathered;
private ManagedRepositoryContent repository;
private List<String> includes = new ArrayList<String>();
@ -118,16 +114,9 @@ public class ArchivaMetadataCreationConsumer
public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
throws ConsumerException
{
try
{
this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() );
this.metadataRepository = new FileMetadataRepository( new File( repository.getRepoRoot(), ".metadata" ) );
this.whenGathered = whenGathered;
}
catch ( RepositoryException e )
{
throw new ConsumerException( "Unable to start ArtifactUpdateDatabaseConsumer: " + e.getMessage(), e );
}
this.repository.setRepository( repo );
this.metadataRepository = new FileMetadataRepository( new File( repository.getRepoRoot(), ".metadata" ) );
this.whenGathered = whenGathered;
}
public void processFile( String path )
@ -145,7 +134,7 @@ public class ArchivaMetadataCreationConsumer
{
throw new ConsumerException( e.getMessage(), e );
}
File file = new File( repository.getRepoRoot(), path );
// TODO: needed in a more central place, but trying to isolate impact to start with
@ -166,7 +155,7 @@ public class ArchivaMetadataCreationConsumer
project.addBuild( build );
// TODO: store "whenGathered"
// read the metadata and update it if it is newer or doesn't exist
metadataRepository.update( project );
}

View File

@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2005-2006 The Apache Software Foundation.
~ 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
~
~ 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
~
~ 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.
~ 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">
@ -35,6 +38,7 @@
<module>archiva-lucene-consumers</module>
<module>archiva-signature-consumers</module>
<module>archiva-dependency-tree-consumer</module>
<module>archiva-metadata-consumer</module>
</modules>
<build>

View File

@ -70,6 +70,12 @@
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-database-consumers</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-metadata-consumer</artifactId>
<version>1.2-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-lucene-consumers</artifactId>