From 067e7501abe0b3e222990732752bb710ca01038f Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Mon, 1 Dec 2008 13:47:06 +0000 Subject: [PATCH] [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@722073 13f79535-47bb-0310-9956-ffa450edef68 --- MRM-1025/archiva-cli/pom.xml | 6 ++ .../archiva-core-consumers/pom.xml | 15 ----- .../archiva-dependency-tree-consumer/pom.xml | 20 +++++++ .../archiva-metadata-consumer/pom.xml | 55 +++++++++++++++++++ .../ArchivaMetadataCreationConsumer.java | 29 +++------- .../archiva-base/archiva-consumers/pom.xml | 26 +++++---- .../archiva-web/archiva-webapp/pom.xml | 6 ++ 7 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml rename MRM-1025/archiva-modules/archiva-base/archiva-consumers/{archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core => archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata}/ArchivaMetadataCreationConsumer.java (88%) diff --git a/MRM-1025/archiva-cli/pom.xml b/MRM-1025/archiva-cli/pom.xml index 70f20a3ce..6fc0f2cc7 100644 --- a/MRM-1025/archiva-cli/pom.xml +++ b/MRM-1025/archiva-cli/pom.xml @@ -38,6 +38,12 @@ 1.2-SNAPSHOT runtime + + org.apache.archiva + archiva-metadata-consumer + 1.2-SNAPSHOT + runtime + org.apache.archiva archiva-xml-tools diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml index 2d1e5c78d..cbf3e0557 100644 --- a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml +++ b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml @@ -52,21 +52,6 @@ plexus-spring test - - org.apache.archiva - metadata-model - 1.2-SNAPSHOT - - - org.apache.archiva - metadata-repository-api - 1.2-SNAPSHOT - - - org.apache.archiva - metadata-repository-file - 1.2-SNAPSHOT - diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml index c675a7c6a..e417bcd5a 100644 --- a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml +++ b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml @@ -1,3 +1,23 @@ + + + 4.0.0 diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml new file mode 100644 index 000000000..98fb35656 --- /dev/null +++ b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml @@ -0,0 +1,55 @@ + + + + + 4.0.0 + + archiva-consumers + org.apache.archiva + 1.2-SNAPSHOT + + archiva-metadata-consumer + Archiva Metadata Consumer + + + org.apache.archiva + archiva-consumer-api + + + org.apache.archiva + metadata-model + 1.2-SNAPSHOT + + + org.apache.archiva + metadata-repository-api + 1.2-SNAPSHOT + + + org.apache.archiva + metadata-repository-file + 1.2-SNAPSHOT + + + org.apache.archiva + archiva-repository-layer + + + diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArchivaMetadataCreationConsumer.java b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java similarity index 88% rename from MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArchivaMetadataCreationConsumer.java rename to MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java index 593f72c6c..1a65b7c4d 100644 --- a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArchivaMetadataCreationConsumer.java +++ b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java @@ -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 includes = new ArrayList(); @@ -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 ); } diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/pom.xml b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/pom.xml index 4d6752164..5ffbb9406 100644 --- a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/pom.xml +++ b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/pom.xml @@ -1,18 +1,21 @@ @@ -35,6 +38,7 @@ archiva-lucene-consumers archiva-signature-consumers archiva-dependency-tree-consumer + archiva-metadata-consumer diff --git a/MRM-1025/archiva-modules/archiva-web/archiva-webapp/pom.xml b/MRM-1025/archiva-modules/archiva-web/archiva-webapp/pom.xml index f353e46b0..768236b3d 100644 --- a/MRM-1025/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/MRM-1025/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -70,6 +70,12 @@ org.apache.archiva archiva-database-consumers + + org.apache.archiva + archiva-metadata-consumer + 1.2-SNAPSHOT + runtime + org.apache.archiva archiva-lucene-consumers -- 2.39.5