summaryrefslogtreecommitdiffstats
path: root/archiva-cli
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-05-01 13:53:14 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-05-01 13:53:14 +0000
commit42ced36dd2b918a6229b371d18740254ad813fd4 (patch)
tree5f8d1b31b1e8b46c278bc2979b971835b40408d2 /archiva-cli
parent9a692f3cc7acd9ad51e4fda442b2a4c858efa679 (diff)
parent4c9789b2284a3d8bde67405fe8651fbf674dbca8 (diff)
downloadarchiva-42ced36dd2b918a6229b371d18740254ad813fd4.tar.gz
archiva-42ced36dd2b918a6229b371d18740254ad813fd4.zip
Making archiva-jpox-database-refactor branch the new trunk.
See archiva-dev mailing list thread ... http://www.nabble.com/-VOTE--Merge-Archiva-Database-Branch-to-Trunk-tf3648867.html git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@534090 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-cli')
-rw-r--r--archiva-cli/pom.xml54
-rw-r--r--archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java61
-rw-r--r--archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java242
-rw-r--r--archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java95
-rw-r--r--archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java124
-rw-r--r--archiva-cli/src/main/resources/META-INF/plexus/components.xml50
-rw-r--r--archiva-cli/src/main/resources/log4j.properties10
7 files changed, 601 insertions, 35 deletions
diff --git a/archiva-cli/pom.xml b/archiva-cli/pom.xml
index dd891dc4d..0fdf11f83 100644
--- a/archiva-cli/pom.xml
+++ b/archiva-cli/pom.xml
@@ -18,29 +18,56 @@
~ 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>
<parent>
- <artifactId>archiva</artifactId>
<groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-cli</artifactId>
- <name>Archiva CLI</name>
+ <name>Archiva Command Line Client</name>
<dependencies>
<dependency>
<groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-repository-layer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-core-consumers</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.archiva</groupId>
<artifactId>archiva-converter</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-digest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ <version>1.0-alpha-22</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-22</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-cli</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus.registry</groupId>
+ <artifactId>plexus-registry-commons</artifactId>
+ <version>1.0-alpha-2</version>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -55,6 +82,25 @@
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <version>1.3.5</version>
+ <executions>
+ <execution>
+ <id>merge</id>
+ <goals>
+ <goal>merge-descriptors</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor>
+ <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java
new file mode 100644
index 000000000..46500a44d
--- /dev/null
+++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java
@@ -0,0 +1,61 @@
+package org.apache.maven.archiva.cli;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.apache.maven.archiva.model.ArchivaRepository;
+
+/**
+ * AbstractProgressConsumer
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractProgressConsumer
+ extends AbstractMonitoredConsumer
+ implements RepositoryContentConsumer
+{
+ private int count = 0;
+
+ public void beginScan( ArchivaRepository repository )
+ throws ConsumerException
+ {
+ this.count = 0;
+ }
+
+ public void processFile( String path )
+ throws ConsumerException
+ {
+ count++;
+ if ( ( count % 1000 ) == 0 )
+ {
+ System.out.println( "Files Processed: " + count );
+ }
+
+ }
+
+ public void completeScan()
+ {
+ System.out.println( "Final Count of Artifacts processed by " + getId() + ": " + count );
+ }
+
+}
diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java
index 26ee4db77..e5237d264 100644
--- a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java
+++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java
@@ -20,23 +20,41 @@ package org.apache.maven.archiva.cli;
*/
import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.common.utils.DateUtil;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
import org.apache.maven.archiva.converter.RepositoryConversionException;
import org.apache.maven.archiva.converter.legacy.LegacyRepositoryConverter;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.tools.cli.AbstractCli;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
/**
+ * ArchivaCli
+ *
* @author Jason van Zyl
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
*/
public class ArchivaCli
extends AbstractCli
@@ -47,6 +65,14 @@ public class ArchivaCli
public static final char CONVERT = 'c';
+ public static final char SCAN = 's';
+
+ public static final char CONSUMERS = 'u';
+
+ public static final char LIST_CONSUMERS = 'l';
+
+ public static final char DUMP_CONFIGURATION = 'd';
+
// ----------------------------------------------------------------------------
// Properties controlling Repository conversion
// ----------------------------------------------------------------------------
@@ -57,6 +83,13 @@ public class ArchivaCli
public static final String BLACKLISTED_PATTERNS = "blacklistPatterns";
+ /**
+ * Configuration store.
+ *
+ * @plexus.requirement
+ */
+ private ArchivaConfiguration archivaConfiguration;
+
public static void main( String[] args )
throws Exception
{
@@ -68,59 +101,206 @@ public class ArchivaCli
return "META-INF/maven/org.apache.maven.archiva/archiva-cli/pom.properties";
}
+ private Option createOption( char shortOpt, String longOpt, int argCount, String description )
+ {
+ boolean hasArg = ( argCount > 0 );
+ Option opt = new Option( String.valueOf( shortOpt ), hasArg, description );
+ opt.setLongOpt( longOpt );
+ if ( hasArg )
+ {
+ opt.setArgs( argCount );
+ }
+ return opt;
+ }
+
public Options buildCliOptions( Options options )
{
- options.addOption( OptionBuilder.withLongOpt( "convert" ).hasArg().withDescription(
- "Convert a legacy Maven 1.x repository to a Maven 2.x repository using a properties file to describe the conversion." )
- .create( CONVERT ) );
+ Option convertOption = createOption( CONVERT, "convert", 1, "Convert a legacy Maven 1.x repository to a "
+ + "Maven 2.x repository using a properties file to describe the conversion." );
+ convertOption.setArgName( "conversion.properties" );
+ options.addOption( convertOption );
+
+ Option scanOption = createOption( SCAN, "scan", 1, "Scan the specified repository." );
+ scanOption.setArgName( "repository directory" );
+ options.addOption( scanOption );
+ Option consumerOption = createOption( CONSUMERS, "consumers", 1, "The consumers to use. "
+ + "(comma delimited. default: 'count-artifacts')" );
+ consumerOption.setArgName( "consumer list" );
+ options.addOption( consumerOption );
+
+ Option listConsumersOption = createOption( LIST_CONSUMERS, "listconsumers", 0, "List available consumers." );
+ options.addOption( listConsumersOption );
+
+ Option dumpConfig = createOption( DUMP_CONFIGURATION, "dumpconfig", 0, "Dump Current Configuration." );
+ options.addOption( dumpConfig );
+
return options;
}
public void invokePlexusComponent( CommandLine cli, PlexusContainer plexus )
throws Exception
{
- LegacyRepositoryConverter legacyRepositoryConverter =
- (LegacyRepositoryConverter) plexus.lookup( LegacyRepositoryConverter.ROLE );
-
if ( cli.hasOption( CONVERT ) )
{
- Properties p = new Properties();
+ doConversion( cli, plexus );
+ }
+ else if ( cli.hasOption( SCAN ) )
+ {
+ doScan( cli, plexus );
+ }
+ else if ( cli.hasOption( LIST_CONSUMERS ) )
+ {
+ dumpAvailableConsumers( plexus );
+ }
+ else if ( cli.hasOption( DUMP_CONFIGURATION ) )
+ {
+ dumpConfiguration( plexus );
+ }
+ else
+ {
+ displayHelp();
+ }
+ }
- try
- {
- p.load( new FileInputStream( cli.getOptionValue( CONVERT ) ) );
- }
- catch ( IOException e )
- {
- showFatalError( "Cannot find properties file which describes the conversion.", e, true );
- }
+ private void doScan( CommandLine cli, PlexusContainer plexus )
+ throws ConsumerException, ComponentLookupException
+ {
+ String path = cli.getOptionValue( SCAN );
- File oldRepositoryPath = new File( p.getProperty( SOURCE_REPO_PATH ) );
+ ArchivaRepository repo = new ArchivaRepository( "cliRepo", "Archiva CLI Provided Repo", "file://" + path );
- File newRepositoryPath = new File( p.getProperty( TARGET_REPO_PATH ) );
+ List consumerList = new ArrayList();
- System.out.println( "Converting " + oldRepositoryPath + " to " + newRepositoryPath );
+ consumerList.addAll( getConsumerList( cli, plexus ) );
- List fileExclusionPatterns = null;
+ RepositoryScanner scanner = new RepositoryScanner();
- String s = p.getProperty( BLACKLISTED_PATTERNS );
+ try
+ {
+ RepositoryContentStatistics stats = scanner.scan( repo, consumerList, true );
- if ( s != null )
+ SimpleDateFormat df = new SimpleDateFormat();
+ System.out.println( "" );
+ System.out.println( ".\\ Scan of " + repo.getId() + " \\.__________________________________________" );
+ System.out.println( " Repository URL : " + repo.getUrl() );
+ System.out.println( " Repository Name : " + repo.getModel().getName() );
+ System.out.println( " Repository Layout : " + repo.getModel().getLayoutName() );
+ System.out.println( " Consumers : (" + consumerList.size() + " active)" );
+ for ( Iterator iter = consumerList.iterator(); iter.hasNext(); )
{
- fileExclusionPatterns = Arrays.asList( StringUtils.split( s, "," ) );
+ RepositoryContentConsumer consumer = (RepositoryContentConsumer) iter.next();
+ System.out.println( " " + consumer.getId() + " - " + consumer.getDescription() );
}
+ System.out.println( " Duration : " + DateUtil.getDuration( stats.getDuration() ) );
+ System.out.println( " When Gathered : " + df.format( stats.getWhenGathered() ) );
+ System.out.println( " Total File Count : " + stats.getTotalFileCount() );
+ long averageMsPerFile = ( stats.getDuration() / stats.getTotalFileCount() );
+ System.out.println( " Avg Time Per File : " + DateUtil.getDuration( averageMsPerFile ) );
+ System.out.println( "______________________________________________________________" );
+ }
+ catch ( RepositoryException e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
- try
- {
- legacyRepositoryConverter.convertLegacyRepository( oldRepositoryPath, newRepositoryPath,
- fileExclusionPatterns,
- true );
- }
- catch ( RepositoryConversionException e )
+ private Collection getConsumerList( CommandLine cli, PlexusContainer plexus )
+ throws ComponentLookupException, ConsumerException
+ {
+ String specifiedConsumers = "count-artifacts";
+
+ if ( cli.hasOption( CONSUMERS ) )
+ {
+ specifiedConsumers = cli.getOptionValue( CONSUMERS );
+ }
+
+ List consumerList = new ArrayList();
+
+ Map availableConsumers = plexus.lookupMap( RepositoryContentConsumer.class );
+
+ String consumerArray[] = StringUtils.split( specifiedConsumers, ',' );
+
+ for ( int i = 0; i < consumerArray.length; i++ )
+ {
+ String specifiedConsumer = consumerArray[i];
+ if ( !availableConsumers.containsKey( specifiedConsumer ) )
{
- showFatalError( "Error converting repository.", e, true );
+ System.err.println( "Specified consumer [" + specifiedConsumer + "] not found." );
+ dumpAvailableConsumers( plexus );
+ System.exit( 1 );
}
+
+ consumerList.add( availableConsumers.get( specifiedConsumer ) );
+ }
+
+ return consumerList;
+ }
+
+ private void dumpAvailableConsumers( PlexusContainer plexus )
+ throws ComponentLookupException
+ {
+ Map availableConsumers = plexus.lookupMap( RepositoryContentConsumer.class );
+
+ System.out.println( ".\\ Available Consumer List \\.______________________________" );
+
+ for ( Iterator iter = availableConsumers.entrySet().iterator(); iter.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) iter.next();
+ String consumerHint = (String) entry.getKey();
+ RepositoryContentConsumer consumer = (RepositoryContentConsumer) entry.getValue();
+ System.out.println( " " + consumerHint + ": " + consumer.getDescription() + " ("
+ + consumer.getClass().getName() + ")" );
+ }
+ }
+
+ private void doConversion( CommandLine cli, PlexusContainer plexus )
+ throws ComponentLookupException
+ {
+ LegacyRepositoryConverter legacyRepositoryConverter = (LegacyRepositoryConverter) plexus
+ .lookup( LegacyRepositoryConverter.ROLE );
+
+ Properties p = new Properties();
+
+ try
+ {
+ p.load( new FileInputStream( cli.getOptionValue( CONVERT ) ) );
+ }
+ catch ( IOException e )
+ {
+ showFatalError( "Cannot find properties file which describes the conversion.", e, true );
}
+
+ File oldRepositoryPath = new File( p.getProperty( SOURCE_REPO_PATH ) );
+
+ File newRepositoryPath = new File( p.getProperty( TARGET_REPO_PATH ) );
+
+ System.out.println( "Converting " + oldRepositoryPath + " to " + newRepositoryPath );
+
+ List fileExclusionPatterns = null;
+
+ String s = p.getProperty( BLACKLISTED_PATTERNS );
+
+ if ( s != null )
+ {
+ fileExclusionPatterns = Arrays.asList( StringUtils.split( s, "," ) );
+ }
+
+ try
+ {
+ legacyRepositoryConverter.convertLegacyRepository( oldRepositoryPath, newRepositoryPath,
+ fileExclusionPatterns );
+ }
+ catch ( RepositoryConversionException e )
+ {
+ showFatalError( "Error converting repository.", e, true );
+ }
+ }
+
+ private void dumpConfiguration( PlexusContainer plexus ) throws ComponentLookupException
+ {
+ archivaConfiguration = (ArchivaConfiguration) plexus.lookup( ArchivaConfiguration.ROLE, "cli" );
+
+ System.out.println( "File Type Count: " + archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().size() );
}
}
diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java
new file mode 100644
index 000000000..c4583427b
--- /dev/null
+++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java
@@ -0,0 +1,95 @@
+package org.apache.maven.archiva.cli;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ArtifactCountConsumer
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role="org.apache.maven.archiva.consumers.RepositoryContentConsumer"
+ * role-hint="count-artifacts"
+ * instantiation-strategy="per-lookup"
+ */
+public class ArtifactCountConsumer
+ extends AbstractProgressConsumer
+ implements RepositoryContentConsumer
+{
+ /**
+ * @plexus.configuration default-value="count-artifacts"
+ */
+ private String id;
+
+ /**
+ * @plexus.configuration default-value="Count Artifacts"
+ */
+ private String description;
+
+ private List includes;
+
+ public ArtifactCountConsumer()
+ {
+ includes = new ArrayList();
+ includes.add( "**/*.pom" );
+ includes.add( "**/*.jar" );
+ includes.add( "**/*.war" );
+ includes.add( "**/*.ear" );
+ includes.add( "**/*.sar" );
+ includes.add( "**/*.car" );
+ includes.add( "**/*.mar" );
+ includes.add( "**/*.dtd" );
+ includes.add( "**/*.tld" );
+ includes.add( "**/*.gz" );
+ includes.add( "**/*.bz2" );
+ includes.add( "**/*.zip" );
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public boolean isPermanent()
+ {
+ return false;
+ }
+
+ public List getExcludes()
+ {
+ return null;
+ }
+
+ public List getIncludes()
+ {
+ return includes;
+ }
+
+}
diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java
new file mode 100644
index 000000000..23c66cef0
--- /dev/null
+++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java
@@ -0,0 +1,124 @@
+package org.apache.maven.archiva.cli;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.repository.project.ProjectModelException;
+import org.apache.maven.archiva.repository.project.ProjectModelReader;
+import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ProjectReaderConsumer
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role="org.apache.maven.archiva.consumers.RepositoryContentConsumer"
+ * role-hint="read-poms"
+ * instantiation-strategy="per-lookup"
+ */
+public class ProjectReaderConsumer
+ extends AbstractProgressConsumer
+ implements RepositoryContentConsumer
+{
+ /**
+ * @plexus.configuration default-value="read-poms"
+ */
+ private String id;
+
+ /**
+ * @plexus.configuration default-value="Read POMs and report anomolies."
+ */
+ private String description;
+
+ private ProjectModelReader reader;
+
+ private ArchivaRepository repo;
+
+ private List includes;
+
+ public ProjectReaderConsumer()
+ {
+ reader = new ProjectModel400Reader();
+
+ includes = new ArrayList();
+ includes.add( "**/*.pom" );
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public boolean isPermanent()
+ {
+ return false;
+ }
+
+ public List getExcludes()
+ {
+ return null;
+ }
+
+ public List getIncludes()
+ {
+ return includes;
+ }
+
+ public void beginScan( ArchivaRepository repository )
+ throws ConsumerException
+ {
+ super.beginScan( repository );
+ this.repo = repository;
+ }
+
+ public void processFile( String path )
+ throws ConsumerException
+ {
+ super.processFile( path );
+
+ File pomFile = new File( repo.getUrl().getPath(), path );
+ try
+ {
+ ArchivaProjectModel model = reader.read( pomFile );
+ if ( model == null )
+ {
+ System.err.println( "Got null model on " + pomFile );
+ }
+ }
+ catch ( ProjectModelException e )
+ {
+ System.err.println( "Unable to process: " + pomFile );
+ e.printStackTrace( System.out );
+ }
+ }
+}
diff --git a/archiva-cli/src/main/resources/META-INF/plexus/components.xml b/archiva-cli/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 000000000..ad355c655
--- /dev/null
+++ b/archiva-cli/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ 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.
+-->
+<component-set>
+ <components>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <implementation>
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+ </implementation>
+ <role-hint>commons-configuration</role-hint>
+ <configuration>
+ <properties>
+ <system />
+ <xml fileName="${appserver.base}/conf/archiva.xml"
+ config-optional="true"
+ config-name="org.apache.maven.archiva.base"
+ config-at="org.apache.maven.archiva" />
+ <xml fileName="${appserver.home}/conf/archiva.xml"
+ config-optional="true"
+ config-at="org.apache.maven.archiva" />
+ <xml fileName="${user.home}/.m2/archiva.xml"
+ config-optional="true"
+ config-name="org.apache.maven.archiva.user"
+ config-at="org.apache.maven.archiva" />
+ <xml
+ fileName="org/apache/maven/archiva/configuration/default-archiva.xml"
+ config-optional="true"
+ config-at="org.apache.maven.archiva" />
+ </properties>
+ </configuration>
+ </component>
+ </components>
+</component-set> \ No newline at end of file
diff --git a/archiva-cli/src/main/resources/log4j.properties b/archiva-cli/src/main/resources/log4j.properties
new file mode 100644
index 000000000..6d107570b
--- /dev/null
+++ b/archiva-cli/src/main/resources/log4j.properties
@@ -0,0 +1,10 @@
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=INFO, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+