aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-cli
diff options
context:
space:
mode:
Diffstat (limited to 'archiva-cli')
-rw-r--r--archiva-cli/pom.xml42
-rw-r--r--archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java74
-rw-r--r--archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java8
-rw-r--r--archiva-cli/src/main/java/org/apache/maven/archiva/cli/ProjectReaderConsumer.java14
4 files changed, 81 insertions, 57 deletions
diff --git a/archiva-cli/pom.xml b/archiva-cli/pom.xml
index b1d36499b..4039c4575 100644
--- a/archiva-cli/pom.xml
+++ b/archiva-cli/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva</artifactId>
- <version>1.2-MRM1025-SNAPSHOT</version>
+ <version>1.2.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-cli</artifactId>
@@ -35,13 +35,7 @@
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-dependency-tree-consumer</artifactId>
- <version>1.2-MRM1025-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-metadata-consumer</artifactId>
- <version>1.2-MRM1025-SNAPSHOT</version>
+ <version>1.2.3-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -62,17 +56,18 @@
<version>7</version>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-spring</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>compile</scope>
</dependency>
</dependencies>
<build>
@@ -80,7 +75,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
- <version>1.0.1</version>
+ <version>1.2.1</version>
<executions>
<execution>
<phase>package</phase>
@@ -90,6 +85,12 @@
<configuration>
<finalName>apache-archiva-cli-${project.version}</finalName>
<transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/spring.handlers</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
+ <resource>META-INF/spring-context.xml</resource>
+ </transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" />
</transformers>
<artifactSet>
@@ -98,7 +99,6 @@
<exclude>xml-apis:xml-apis</exclude>
<exclude>xalan:xalan</exclude>
<exclude>commons-beanutils:commons-beanutils</exclude>
- <exclude>commons-io:commons-io</exclude>
</excludes>
</artifactSet>
</configuration>
@@ -117,6 +117,16 @@
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <configuration>
+ <executable>java</executable>
+ <mainClass>org.apache.maven.archiva.cli.ArchivaCli</mainClass>
+ <arguments>
+ </arguments>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
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 2de1d973a..43cb75350 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
@@ -19,6 +19,9 @@ package org.apache.maven.archiva.cli;
* under the License.
*/
+import com.sampullara.cli.Args;
+import com.sampullara.cli.Argument;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -31,9 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
-import org.apache.archiva.repository.scanner.RepositoryScanner;
-import org.apache.archiva.repository.scanner.RepositoryScannerException;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.ConsumerException;
@@ -42,18 +43,18 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
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.repository.RepositoryException;
+import org.apache.maven.archiva.repository.scanner.RepositoryScanStatistics;
+import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
import org.apache.maven.artifact.manager.WagonManager;
import org.codehaus.plexus.spring.PlexusClassPathXmlApplicationContext;
import org.codehaus.plexus.spring.PlexusToSpringUtils;
-import com.sampullara.cli.Args;
-import com.sampullara.cli.Argument;
-
/**
* ArchivaCli
- *
- * @todo add back reading of archiva.xml from a given location
+ *
* @version $Id$
+ * @todo add back reading of archiva.xml from a given location
*/
public class ArchivaCli
{
@@ -71,7 +72,8 @@ public class ArchivaCli
throws IOException
{
Properties properties = new Properties();
- properties.load( ArchivaCli.class.getResourceAsStream( "/META-INF/maven/org.apache.archiva/archiva-cli/pom.properties" ) );
+ properties.load(
+ ArchivaCli.class.getResourceAsStream( "/META-INF/maven/org.apache.archiva/archiva-cli/pom.properties" ) );
return properties.getProperty( "version" );
}
@@ -79,9 +81,8 @@ public class ArchivaCli
public ArchivaCli()
{
- applicationContext =
- new PlexusClassPathXmlApplicationContext( new String[] { "classpath*:/META-INF/spring-context.xml",
- "classpath*:/META-INF/plexus/components.xml" } );
+ applicationContext = new PlexusClassPathXmlApplicationContext(
+ new String[]{"classpath*:/META-INF/spring-context.xml", "classpath*:/META-INF/plexus/components.xml"} );
}
public static void main( String[] args )
@@ -144,8 +145,8 @@ public class ArchivaCli
{
// hack around poorly configurable project builder by pointing all repositories back at this location to be self
// contained
- WagonManager wagonManager =
- (WagonManager) applicationContext.getBean( PlexusToSpringUtils.buildSpringId( WagonManager.class.getName() ) );
+ WagonManager wagonManager = (WagonManager) applicationContext.getBean(
+ PlexusToSpringUtils.buildSpringId( WagonManager.class.getName() ) );
wagonManager.addMirror( "internal", "*", new File( path ).toURL().toExternalForm() );
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
@@ -166,13 +167,12 @@ public class ArchivaCli
try
{
- RepositoryScanStatistics stats =
- scanner.scan( repo, knownConsumerList, invalidConsumerList, ignoredContent,
- RepositoryScanner.FRESH_SCAN );
+ RepositoryScanStatistics stats = scanner.scan( repo, knownConsumerList, invalidConsumerList, ignoredContent,
+ RepositoryScanner.FRESH_SCAN );
System.out.println( "\n" + stats.toDump( repo ) );
}
- catch ( RepositoryScannerException e )
+ catch ( RepositoryException e )
{
e.printStackTrace( System.err );
}
@@ -215,12 +215,12 @@ public class ArchivaCli
{
String consumerHint = (String) entry.getKey();
RepositoryContentConsumer consumer = (RepositoryContentConsumer) entry.getValue();
- System.out.println( " " + consumerHint + ": " + consumer.getDescription() + " ("
- + consumer.getClass().getName() + ")" );
+ System.out.println(
+ " " + consumerHint + ": " + consumer.getDescription() + " (" + consumer.getClass().getName() + ")" );
}
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private Map<String, KnownRepositoryContentConsumer> getConsumers()
{
return PlexusToSpringUtils.lookupMap( "knownRepositoryContentConsumer", applicationContext );
@@ -234,7 +234,16 @@ public class ArchivaCli
Properties p = new Properties();
- p.load( new FileInputStream( properties ) );
+ FileInputStream fis = new FileInputStream( properties );
+
+ try
+ {
+ p.load( fis );
+ }
+ finally
+ {
+ IOUtils.closeQuietly( fis );
+ }
File oldRepositoryPath = new File( p.getProperty( SOURCE_REPO_PATH ) );
@@ -251,33 +260,36 @@ public class ArchivaCli
fileExclusionPatterns = Arrays.asList( StringUtils.split( s, "," ) );
}
- legacyRepositoryConverter.convertLegacyRepository( oldRepositoryPath, newRepositoryPath, fileExclusionPatterns );
+ legacyRepositoryConverter.convertLegacyRepository( oldRepositoryPath, newRepositoryPath,
+ fileExclusionPatterns );
}
private static class Commands
{
- @Argument( description = "Display help information", value = "help", alias = "h" )
+ @Argument(description = "Display help information", value = "help", alias = "h")
private boolean help;
- @Argument( description = "Display version information", value = "version", alias = "v" )
+ @Argument(description = "Display version information", value = "version", alias = "v")
private boolean version;
- @Argument( description = "List available consumers", value = "listconsumers", alias = "l" )
+ @Argument(description = "List available consumers", value = "listconsumers", alias = "l")
private boolean listConsumers;
- @Argument( description = "The consumers to use (comma delimited)", value = "consumers", alias = "u" )
+ @Argument(description = "The consumers to use (comma delimited)", value = "consumers", alias = "u")
private String consumers = "count-artifacts";
- @Argument( description = "Scan the specified repository", value = "scan", alias = "s" )
+ @Argument(description = "Scan the specified repository", value = "scan", alias = "s")
private boolean scan;
- @Argument( description = "Convert a legacy Maven 1.x repository to a Maven 2.x repository using a properties file to describe the conversion", value = "convert", alias = "c" )
+ @Argument(
+ description = "Convert a legacy Maven 1.x repository to a Maven 2.x repository using a properties file to describe the conversion",
+ value = "convert", alias = "c")
private boolean convert;
- @Argument( description = "The properties file for the converstion", value = "properties" )
+ @Argument(description = "The properties file for the conversion", value = "properties")
private String properties = "conversion.properties";
- @Argument( description = "The repository to scan", value = "repository" )
+ @Argument(description = "The repository to scan", value = "repository")
private String repository;
}
}
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
index bb3a7146c..bfc5f6ebc 100644
--- 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
@@ -47,12 +47,12 @@ public class ArtifactCountConsumer
*/
private String description;
- private List includes;
+ private List<String> includes;
public ArtifactCountConsumer()
{
// TODO: shouldn't this use filetypes?
- includes = new ArrayList();
+ includes = new ArrayList<String>();
includes.add( "**/*.pom" );
includes.add( "**/*.jar" );
includes.add( "**/*.war" );
@@ -82,12 +82,12 @@ public class ArtifactCountConsumer
return false;
}
- public List getExcludes()
+ public List<String> getExcludes()
{
return null;
}
- public List getIncludes()
+ public List<String> 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
index e2661c99b..be19a1a01 100644
--- 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
@@ -28,9 +28,9 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.model.ArchivaProjectModel;
-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 org.apache.maven.archiva.xml.XMLException;
/**
* ProjectReaderConsumer
@@ -59,13 +59,13 @@ public class ProjectReaderConsumer
private ManagedRepositoryConfiguration repo;
- private List includes;
+ private List<String> includes;
public ProjectReaderConsumer()
{
reader = new ProjectModel400Reader();
- includes = new ArrayList();
+ includes = new ArrayList<String>();
includes.add( "**/*.pom" );
}
@@ -84,16 +84,17 @@ public class ProjectReaderConsumer
return false;
}
- public List getExcludes()
+ public List<String> getExcludes()
{
return null;
}
- public List getIncludes()
+ public List<String> getIncludes()
{
return includes;
}
+ @Override
public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered )
throws ConsumerException
{
@@ -101,6 +102,7 @@ public class ProjectReaderConsumer
this.repo = repository;
}
+ @Override
public void processFile( String path )
throws ConsumerException
{
@@ -115,7 +117,7 @@ public class ProjectReaderConsumer
System.err.println( "Got null model on " + pomFile );
}
}
- catch ( ProjectModelException e )
+ catch ( XMLException e )
{
System.err.println( "Unable to process: " + pomFile );
e.printStackTrace( System.out );