]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1003] Repackage sources from org.apache.maven.archiva.. to org.apache.archiva...
authorOlivier Lamy <olamy@apache.org>
Fri, 16 Sep 2011 07:32:43 +0000 (07:32 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 16 Sep 2011 07:32:43 +0000 (07:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171413 13f79535-47bb-0310-9956-ffa450edef68

archiva-cli/pom.xml
archiva-cli/src/main/java/org/apache/archiva/cli/AbstractProgressConsumer.java [new file with mode: 0644]
archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java [new file with mode: 0644]
archiva-cli/src/main/java/org/apache/archiva/cli/ArtifactCountConsumer.java [new file with mode: 0644]
archiva-cli/src/main/java/org/apache/maven/archiva/cli/AbstractProgressConsumer.java [deleted file]
archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java [deleted file]
archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArtifactCountConsumer.java [deleted file]
archiva-cli/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/archiva/archiva-cli/1.0-SNAPSHOT/archiva-cli-1.0-SNAPSHOT.pom
archiva-modules/archiva-base/archiva-repository-scanner/src/test/repositories/default-repository/org/apache/maven/archiva/archiva-cli/1.0-SNAPSHOT/archiva-cli-1.0-SNAPSHOT.pom

index f5ab9aebeee478f73e7a8a15290c3d224f740776..998712022bbd544646d7f7771506d9d82953d9e0 100644 (file)
         <configuration>
           <archive>
             <manifest>
-              <mainClass>org.apache.maven.archiva.cli.ArchivaCli</mainClass>
+              <mainClass>org.apache.archiva.cli.ArchivaCli</mainClass>
             </manifest>
           </archive>
         </configuration>
         <artifactId>exec-maven-plugin</artifactId>
         <configuration>
           <executable>java</executable>
-          <mainClass>org.apache.maven.archiva.cli.ArchivaCli</mainClass>
+          <mainClass>org.apache.archiva.cli.ArchivaCli</mainClass>
           <arguments>
           </arguments>
         </configuration>
diff --git a/archiva-cli/src/main/java/org/apache/archiva/cli/AbstractProgressConsumer.java b/archiva-cli/src/main/java/org/apache/archiva/cli/AbstractProgressConsumer.java
new file mode 100644 (file)
index 0000000..a5ef331
--- /dev/null
@@ -0,0 +1,79 @@
+package org.apache.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.archiva.admin.model.beans.ManagedRepository;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+
+import java.util.Date;
+
+/**
+ * AbstractProgressConsumer 
+ *
+ * @version $Id$
+ */
+public abstract class AbstractProgressConsumer
+    extends AbstractMonitoredConsumer
+    implements RepositoryContentConsumer
+{
+    private int count = 0;
+
+    public void beginScan( ManagedRepository repository, Date whenGathered )
+        throws ConsumerException
+    {
+        this.count = 0;
+    }
+
+    public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
+        throws ConsumerException
+    {
+        beginScan( repository, whenGathered );
+    }
+
+    public void processFile( String path )
+        throws ConsumerException
+    {
+        count++;
+        if ( ( count % 1000 ) == 0 )
+        {
+            System.out.println( "Files Processed: " + count );
+        }
+
+    }
+
+    public void processFile( String path, boolean executeOnEntireRepo )
+        throws ConsumerException
+    {
+        processFile( path );
+    }
+
+    public void completeScan()
+    {
+        System.out.println( "Final Count of Artifacts processed by " + getId() + ": " + count );
+    }
+
+    public void completeScan( boolean executeOnEntireRepo )
+    {
+        completeScan();
+    }
+
+}
diff --git a/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java b/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java
new file mode 100644 (file)
index 0000000..e8fbb3c
--- /dev/null
@@ -0,0 +1,328 @@
+package org.apache.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 com.sampullara.cli.Args;
+import com.sampullara.cli.Argument;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
+import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
+import org.apache.archiva.converter.RepositoryConversionException;
+import org.apache.archiva.converter.legacy.LegacyRepositoryConverter;
+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.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.apache.maven.artifact.manager.WagonManager;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * ArchivaCli
+ *
+ * @version $Id$
+ * @todo add back reading of archiva.xml from a given location
+ */
+public class ArchivaCli
+{
+    // ----------------------------------------------------------------------------
+    // Properties controlling Repository conversion
+    // ----------------------------------------------------------------------------
+
+    public static final String SOURCE_REPO_PATH = "sourceRepositoryPath";
+
+    public static final String TARGET_REPO_PATH = "targetRepositoryPath";
+
+    public static final String BLACKLISTED_PATTERNS = "blacklistPatterns";
+
+    public static final String POM_PROPERTIES = "/META-INF/maven/org.apache.archiva/archiva-cli/pom.properties";
+
+    private static String getVersion()
+        throws IOException
+    {
+        InputStream pomStream = ArchivaCli.class.getResourceAsStream( POM_PROPERTIES );
+        if ( pomStream == null )
+        {
+            throw new IOException( "Failed to load " + POM_PROPERTIES );
+        }
+
+        try
+        {
+            Properties properties = new Properties();
+            properties.load( pomStream );
+            return properties.getProperty( "version" );
+        }
+        finally
+        {
+            IOUtils.closeQuietly( pomStream );
+        }
+    }
+
+    private ClassPathXmlApplicationContext applicationContext;
+
+    public ArchivaCli()
+    {
+        applicationContext =
+            new ClassPathXmlApplicationContext( new String[]{ "classpath*:/META-INF/spring-context.xml" } );
+    }
+
+    public static void main( String[] args )
+        throws Exception
+    {
+        Commands command = new Commands();
+
+        try
+        {
+            Args.parse( command, args );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            System.err.println( e.getMessage() );
+            Args.usage( command );
+            return;
+        }
+
+        new ArchivaCli().execute( command );
+    }
+
+    private void execute( Commands command )
+        throws Exception
+    {
+        if ( command.help )
+        {
+            Args.usage( command );
+        }
+        else if ( command.version )
+        {
+            System.out.print( "Version: " + getVersion() );
+        }
+        else if ( command.convert )
+        {
+            doConversion( command.properties );
+        }
+        else if ( command.scan )
+        {
+            if ( command.repository == null )
+            {
+                System.err.println( "The repository must be specified." );
+                Args.usage( command );
+                return;
+            }
+
+            doScan( command.repository, command.consumers.split( "," ) );
+        }
+        else if ( command.listConsumers )
+        {
+            dumpAvailableConsumers();
+        }
+        else
+        {
+            Args.usage( command );
+        }
+    }
+
+    private void doScan( String path, String[] consumers )
+        throws ConsumerException, MalformedURLException, PlexusSisuBridgeException
+    {
+        // hack around poorly configurable project builder by pointing all repositories back at this location to be self
+        // contained
+        PlexusSisuBridge plexusSisuBridge = applicationContext.getBean( PlexusSisuBridge.class );
+        WagonManager wagonManager = plexusSisuBridge.lookup( WagonManager.class );
+        wagonManager.addMirror( "internal", "*", new File( path ).toURL().toExternalForm() );
+
+        ManagedRepository repo = new ManagedRepository();
+        repo.setId( "cliRepo" );
+        repo.setName( "Archiva CLI Provided Repo" );
+        repo.setLocation( path );
+
+        List<KnownRepositoryContentConsumer> knownConsumerList = new ArrayList<KnownRepositoryContentConsumer>();
+
+        knownConsumerList.addAll( getConsumerList( consumers ) );
+
+        List<InvalidRepositoryContentConsumer> invalidConsumerList = Collections.emptyList();
+
+        List<String> ignoredContent = new ArrayList<String>();
+        ignoredContent.addAll( Arrays.asList( RepositoryScanner.IGNORABLE_CONTENT ) );
+
+        RepositoryScanner scanner = (RepositoryScanner) lookup( RepositoryScanner.class );
+
+        try
+        {
+            RepositoryScanStatistics stats = scanner.scan( repo, knownConsumerList, invalidConsumerList, ignoredContent,
+                                                           RepositoryScanner.FRESH_SCAN );
+
+            System.out.println( "\n" + stats.toDump( repo ) );
+        }
+        catch ( RepositoryScannerException e )
+        {
+            e.printStackTrace( System.err );
+        }
+    }
+
+    private Object lookup( Class<?> clazz )
+        throws PlexusSisuBridgeException
+    {
+        PlexusSisuBridge plexusSisuBridge = applicationContext.getBean( PlexusSisuBridge.class );
+        return plexusSisuBridge.lookup( clazz );
+    }
+
+    private List<KnownRepositoryContentConsumer> getConsumerList( String[] consumers )
+        throws ConsumerException, PlexusSisuBridgeException
+    {
+        List<KnownRepositoryContentConsumer> consumerList = new ArrayList<KnownRepositoryContentConsumer>();
+
+        Map<String, KnownRepositoryContentConsumer> availableConsumers = getConsumers();
+
+        for ( String specifiedConsumer : consumers )
+        {
+            if ( !availableConsumers.containsKey( specifiedConsumer ) )
+            {
+                System.err.println( "Specified consumer [" + specifiedConsumer + "] not found." );
+                dumpAvailableConsumers();
+                System.exit( 1 );
+            }
+
+            consumerList.add( availableConsumers.get( specifiedConsumer ) );
+        }
+
+        return consumerList;
+    }
+
+    private void dumpAvailableConsumers()
+        throws PlexusSisuBridgeException
+    {
+        Map<String, KnownRepositoryContentConsumer> availableConsumers = getConsumers();
+
+        System.out.println( ".\\ Available Consumer List \\.______________________________" );
+
+        for ( Map.Entry<String, KnownRepositoryContentConsumer> entry : availableConsumers.entrySet() )
+        {
+            String consumerHint = (String) entry.getKey();
+            RepositoryContentConsumer consumer = (RepositoryContentConsumer) entry.getValue();
+            System.out.println(
+                "  " + consumerHint + ": " + consumer.getDescription() + " (" + consumer.getClass().getName() + ")" );
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private Map<String, KnownRepositoryContentConsumer> getConsumers()
+        throws PlexusSisuBridgeException
+    {
+        Map<String, KnownRepositoryContentConsumer> beans =
+            applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class );
+        // we use a naming conventions knownRepositoryContentConsumer#hint
+        // with plexus we used only hint so remove before#
+
+        Map<String, KnownRepositoryContentConsumer> smallNames =
+            new HashMap<String, KnownRepositoryContentConsumer>( beans.size() );
+
+        for ( Map.Entry<String, KnownRepositoryContentConsumer> entry : beans.entrySet() )
+        {
+            smallNames.put( StringUtils.substringAfterLast( entry.getKey(), "#" ), entry.getValue() );
+        }
+
+        return smallNames;
+    }
+
+    private void doConversion( String properties )
+        throws FileNotFoundException, IOException, RepositoryConversionException, PlexusSisuBridgeException
+    {
+        LegacyRepositoryConverter legacyRepositoryConverter =
+            (LegacyRepositoryConverter) lookup( LegacyRepositoryConverter.class );
+
+        Properties p = new Properties();
+
+        FileInputStream fis = new FileInputStream( properties );
+
+        try
+        {
+            p.load( fis );
+        }
+        finally
+        {
+            IOUtils.closeQuietly( fis );
+        }
+
+        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<String> fileExclusionPatterns = null;
+
+        String s = p.getProperty( BLACKLISTED_PATTERNS );
+
+        if ( s != null )
+        {
+            fileExclusionPatterns = Arrays.asList( StringUtils.split( s, "," ) );
+        }
+
+        legacyRepositoryConverter.convertLegacyRepository( oldRepositoryPath, newRepositoryPath,
+                                                           fileExclusionPatterns );
+    }
+
+    private static class Commands
+    {
+        @Argument( description = "Display help information", value = "help", alias = "h" )
+        private boolean help;
+
+        @Argument( description = "Display version information", value = "version", alias = "v" )
+        private boolean version;
+
+        @Argument( description = "List available consumers", value = "listconsumers", alias = "l" )
+        private boolean listConsumers;
+
+        @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" )
+        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" )
+        private boolean convert;
+
+        @Argument( description = "The properties file for the conversion", value = "properties" )
+        private String properties = "conversion.properties";
+
+        @Argument( description = "The repository to scan", value = "repository" )
+        private String repository;
+    }
+}
diff --git a/archiva-cli/src/main/java/org/apache/archiva/cli/ArtifactCountConsumer.java b/archiva-cli/src/main/java/org/apache/archiva/cli/ArtifactCountConsumer.java
new file mode 100644 (file)
index 0000000..865e992
--- /dev/null
@@ -0,0 +1,95 @@
+package org.apache.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.KnownRepositoryContentConsumer;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ArtifactCountConsumer
+ *
+ * @version $Id$
+ */
+@Service("knownRepositoryContentConsumer#count-artifacts")
+@Scope("prototype")
+public class ArtifactCountConsumer
+    extends AbstractProgressConsumer
+    implements KnownRepositoryContentConsumer
+{
+    /**
+     * default-value="count-artifacts"
+     */
+    private String id = "count-artifacts";
+
+    /**
+     * default-value="Count Artifacts"
+     */
+    private String description = "Count Artifacts";
+
+    private List<String> includes;
+
+    public ArtifactCountConsumer()
+    {
+        // TODO: shouldn't this use filetypes?
+        includes = new ArrayList<String>();
+        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<String> getExcludes()
+    {
+        return null;
+    }
+
+    public List<String> getIncludes()
+    {
+        return includes;
+    }
+
+}
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
deleted file mode 100644 (file)
index a28d25b..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-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.archiva.admin.model.beans.ManagedRepository;
-import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
-import org.apache.maven.archiva.consumers.ConsumerException;
-import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
-
-import java.util.Date;
-
-/**
- * AbstractProgressConsumer 
- *
- * @version $Id$
- */
-public abstract class AbstractProgressConsumer
-    extends AbstractMonitoredConsumer
-    implements RepositoryContentConsumer
-{
-    private int count = 0;
-
-    public void beginScan( ManagedRepository repository, Date whenGathered )
-        throws ConsumerException
-    {
-        this.count = 0;
-    }
-
-    public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
-        throws ConsumerException
-    {
-        beginScan( repository, whenGathered );
-    }
-
-    public void processFile( String path )
-        throws ConsumerException
-    {
-        count++;
-        if ( ( count % 1000 ) == 0 )
-        {
-            System.out.println( "Files Processed: " + count );
-        }
-
-    }
-
-    public void processFile( String path, boolean executeOnEntireRepo )
-        throws ConsumerException
-    {
-        processFile( path );
-    }
-
-    public void completeScan()
-    {
-        System.out.println( "Final Count of Artifacts processed by " + getId() + ": " + count );
-    }
-
-    public void completeScan( boolean executeOnEntireRepo )
-    {
-        completeScan();
-    }
-
-}
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
deleted file mode 100644 (file)
index 9bafcca..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-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 com.sampullara.cli.Args;
-import com.sampullara.cli.Argument;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
-import org.apache.archiva.converter.RepositoryConversionException;
-import org.apache.archiva.converter.legacy.LegacyRepositoryConverter;
-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.consumers.ConsumerException;
-import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
-import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
-import org.apache.maven.artifact.manager.WagonManager;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * ArchivaCli
- *
- * @version $Id$
- * @todo add back reading of archiva.xml from a given location
- */
-public class ArchivaCli
-{
-    // ----------------------------------------------------------------------------
-    // Properties controlling Repository conversion
-    // ----------------------------------------------------------------------------
-
-    public static final String SOURCE_REPO_PATH = "sourceRepositoryPath";
-
-    public static final String TARGET_REPO_PATH = "targetRepositoryPath";
-
-    public static final String BLACKLISTED_PATTERNS = "blacklistPatterns";
-
-    public static final String POM_PROPERTIES = "/META-INF/maven/org.apache.archiva/archiva-cli/pom.properties";
-
-    private static String getVersion()
-        throws IOException
-    {
-        InputStream pomStream = ArchivaCli.class.getResourceAsStream( POM_PROPERTIES );
-        if ( pomStream == null )
-        {
-            throw new IOException( "Failed to load " + POM_PROPERTIES );
-        }
-
-        try
-        {
-            Properties properties = new Properties();
-            properties.load( pomStream );
-            return properties.getProperty( "version" );
-        }
-        finally
-        {
-            IOUtils.closeQuietly( pomStream );
-        }
-    }
-
-    private ClassPathXmlApplicationContext applicationContext;
-
-    public ArchivaCli()
-    {
-        applicationContext =
-            new ClassPathXmlApplicationContext( new String[]{ "classpath*:/META-INF/spring-context.xml" } );
-    }
-
-    public static void main( String[] args )
-        throws Exception
-    {
-        Commands command = new Commands();
-
-        try
-        {
-            Args.parse( command, args );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            System.err.println( e.getMessage() );
-            Args.usage( command );
-            return;
-        }
-
-        new ArchivaCli().execute( command );
-    }
-
-    private void execute( Commands command )
-        throws Exception
-    {
-        if ( command.help )
-        {
-            Args.usage( command );
-        }
-        else if ( command.version )
-        {
-            System.out.print( "Version: " + getVersion() );
-        }
-        else if ( command.convert )
-        {
-            doConversion( command.properties );
-        }
-        else if ( command.scan )
-        {
-            if ( command.repository == null )
-            {
-                System.err.println( "The repository must be specified." );
-                Args.usage( command );
-                return;
-            }
-
-            doScan( command.repository, command.consumers.split( "," ) );
-        }
-        else if ( command.listConsumers )
-        {
-            dumpAvailableConsumers();
-        }
-        else
-        {
-            Args.usage( command );
-        }
-    }
-
-    private void doScan( String path, String[] consumers )
-        throws ConsumerException, MalformedURLException, PlexusSisuBridgeException
-    {
-        // hack around poorly configurable project builder by pointing all repositories back at this location to be self
-        // contained
-        PlexusSisuBridge plexusSisuBridge = applicationContext.getBean( PlexusSisuBridge.class );
-        WagonManager wagonManager = plexusSisuBridge.lookup( WagonManager.class );
-        wagonManager.addMirror( "internal", "*", new File( path ).toURL().toExternalForm() );
-
-        ManagedRepository repo = new ManagedRepository();
-        repo.setId( "cliRepo" );
-        repo.setName( "Archiva CLI Provided Repo" );
-        repo.setLocation( path );
-
-        List<KnownRepositoryContentConsumer> knownConsumerList = new ArrayList<KnownRepositoryContentConsumer>();
-
-        knownConsumerList.addAll( getConsumerList( consumers ) );
-
-        List<InvalidRepositoryContentConsumer> invalidConsumerList = Collections.emptyList();
-
-        List<String> ignoredContent = new ArrayList<String>();
-        ignoredContent.addAll( Arrays.asList( RepositoryScanner.IGNORABLE_CONTENT ) );
-
-        RepositoryScanner scanner = (RepositoryScanner) lookup( RepositoryScanner.class );
-
-        try
-        {
-            RepositoryScanStatistics stats = scanner.scan( repo, knownConsumerList, invalidConsumerList, ignoredContent,
-                                                           RepositoryScanner.FRESH_SCAN );
-
-            System.out.println( "\n" + stats.toDump( repo ) );
-        }
-        catch ( RepositoryScannerException e )
-        {
-            e.printStackTrace( System.err );
-        }
-    }
-
-    private Object lookup( Class<?> clazz )
-        throws PlexusSisuBridgeException
-    {
-        PlexusSisuBridge plexusSisuBridge = applicationContext.getBean( PlexusSisuBridge.class );
-        return plexusSisuBridge.lookup( clazz );
-    }
-
-    private List<KnownRepositoryContentConsumer> getConsumerList( String[] consumers )
-        throws ConsumerException, PlexusSisuBridgeException
-    {
-        List<KnownRepositoryContentConsumer> consumerList = new ArrayList<KnownRepositoryContentConsumer>();
-
-        Map<String, KnownRepositoryContentConsumer> availableConsumers = getConsumers();
-
-        for ( String specifiedConsumer : consumers )
-        {
-            if ( !availableConsumers.containsKey( specifiedConsumer ) )
-            {
-                System.err.println( "Specified consumer [" + specifiedConsumer + "] not found." );
-                dumpAvailableConsumers();
-                System.exit( 1 );
-            }
-
-            consumerList.add( availableConsumers.get( specifiedConsumer ) );
-        }
-
-        return consumerList;
-    }
-
-    private void dumpAvailableConsumers()
-        throws PlexusSisuBridgeException
-    {
-        Map<String, KnownRepositoryContentConsumer> availableConsumers = getConsumers();
-
-        System.out.println( ".\\ Available Consumer List \\.______________________________" );
-
-        for ( Map.Entry<String, KnownRepositoryContentConsumer> entry : availableConsumers.entrySet() )
-        {
-            String consumerHint = (String) entry.getKey();
-            RepositoryContentConsumer consumer = (RepositoryContentConsumer) entry.getValue();
-            System.out.println(
-                "  " + consumerHint + ": " + consumer.getDescription() + " (" + consumer.getClass().getName() + ")" );
-        }
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private Map<String, KnownRepositoryContentConsumer> getConsumers()
-        throws PlexusSisuBridgeException
-    {
-        Map<String, KnownRepositoryContentConsumer> beans =
-            applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class );
-        // we use a naming conventions knownRepositoryContentConsumer#hint
-        // with plexus we used only hint so remove before#
-
-        Map<String, KnownRepositoryContentConsumer> smallNames =
-            new HashMap<String, KnownRepositoryContentConsumer>( beans.size() );
-
-        for ( Map.Entry<String, KnownRepositoryContentConsumer> entry : beans.entrySet() )
-        {
-            smallNames.put( StringUtils.substringAfterLast( entry.getKey(), "#" ), entry.getValue() );
-        }
-
-        return smallNames;
-    }
-
-    private void doConversion( String properties )
-        throws FileNotFoundException, IOException, RepositoryConversionException, PlexusSisuBridgeException
-    {
-        LegacyRepositoryConverter legacyRepositoryConverter =
-            (LegacyRepositoryConverter) lookup( LegacyRepositoryConverter.class );
-
-        Properties p = new Properties();
-
-        FileInputStream fis = new FileInputStream( properties );
-
-        try
-        {
-            p.load( fis );
-        }
-        finally
-        {
-            IOUtils.closeQuietly( fis );
-        }
-
-        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<String> fileExclusionPatterns = null;
-
-        String s = p.getProperty( BLACKLISTED_PATTERNS );
-
-        if ( s != null )
-        {
-            fileExclusionPatterns = Arrays.asList( StringUtils.split( s, "," ) );
-        }
-
-        legacyRepositoryConverter.convertLegacyRepository( oldRepositoryPath, newRepositoryPath,
-                                                           fileExclusionPatterns );
-    }
-
-    private static class Commands
-    {
-        @Argument( description = "Display help information", value = "help", alias = "h" )
-        private boolean help;
-
-        @Argument( description = "Display version information", value = "version", alias = "v" )
-        private boolean version;
-
-        @Argument( description = "List available consumers", value = "listconsumers", alias = "l" )
-        private boolean listConsumers;
-
-        @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" )
-        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" )
-        private boolean convert;
-
-        @Argument( description = "The properties file for the conversion", value = "properties" )
-        private String properties = "conversion.properties";
-
-        @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
deleted file mode 100644 (file)
index fd66db0..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-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.KnownRepositoryContentConsumer;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ArtifactCountConsumer
- *
- * @version $Id$
- */
-@Service("knownRepositoryContentConsumer#count-artifacts")
-@Scope("prototype")
-public class ArtifactCountConsumer
-    extends AbstractProgressConsumer
-    implements KnownRepositoryContentConsumer
-{
-    /**
-     * default-value="count-artifacts"
-     */
-    private String id = "count-artifacts";
-
-    /**
-     * default-value="Count Artifacts"
-     */
-    private String description = "Count Artifacts";
-
-    private List<String> includes;
-
-    public ArtifactCountConsumer()
-    {
-        // TODO: shouldn't this use filetypes?
-        includes = new ArrayList<String>();
-        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<String> getExcludes()
-    {
-        return null;
-    }
-
-    public List<String> getIncludes()
-    {
-        return includes;
-    }
-
-}
index 11fa0dda2c57de98ed729ecda3cb108a3232c90c..02898785524bcce213ac89dac4046788f3cddb08 100644 (file)
@@ -28,6 +28,6 @@
        default-lazy-init="true">
 
   <context:annotation-config/>
-  <context:component-scan base-package="org.apache.maven.archiva.cli"/>
+  <context:component-scan base-package="org.apache.archiva.cli"/>
 
 </beans>
\ No newline at end of file
index 115bc99ea2203209667566aa116e46deb8a39e9a..3041a9f8df9418e6be922ecf0ef01631743666ee 100644 (file)
@@ -58,7 +58,7 @@
           <descriptor>src/main/assembly/archiva-cli-assembly.xml</descriptor>
           <archive>
             <manifest>
-              <mainClass>org.apache.maven.archiva.cli.ArchivaCli</mainClass>
+              <mainClass>org.apache.archiva.cli.ArchivaCli</mainClass>
             </manifest>
           </archive>
         </configuration>
index 115bc99ea2203209667566aa116e46deb8a39e9a..3041a9f8df9418e6be922ecf0ef01631743666ee 100644 (file)
@@ -58,7 +58,7 @@
           <descriptor>src/main/assembly/archiva-cli-assembly.xml</descriptor>
           <archive>
             <manifest>
-              <mainClass>org.apache.maven.archiva.cli.ArchivaCli</mainClass>
+              <mainClass>org.apache.archiva.cli.ArchivaCli</mainClass>
             </manifest>
           </archive>
         </configuration>