Author: brett
Date: Sun Jan 8 20:56:15 2006
New Revision: 367199
URL: http://svn.apache.org/viewcvs?rev=367199&view=rev
Log:
[MRM-46] Add a very basic CLI interface for some quick tests. These will likely
be removed at some point for something that just executes the webwork actions
Added:
maven/repository-manager/trunk/maven-repository-application/ (with props)
maven/repository-manager/trunk/maven-repository-application/pom.xml (with
props)
maven/repository-manager/trunk/maven-repository-application/src/
maven/repository-manager/trunk/maven-repository-application/src/main/
maven/repository-manager/trunk/maven-repository-application/src/main/java/
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java
(with props)
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
(with props)
maven/repository-manager/trunk/maven-repository-application/src/test/
maven/repository-manager/trunk/maven-repository-application/src/test/java/
Modified:
maven/repository-manager/trunk/pom.xml
Propchange: maven/repository-manager/trunk/maven-repository-application/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jan 8 20:56:15 2006
@@ -0,0 +1,2 @@
+target
+*.iml
Added: maven/repository-manager/trunk/maven-repository-application/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-application/pom.xml?rev=367199&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-application/pom.xml (added)
+++ maven/repository-manager/trunk/maven-repository-application/pom.xml Sun Jan
8 20:56:15 2006
@@ -0,0 +1,41 @@
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ 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
+ ~
+ ~ 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">
+ <parent>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-manager</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>maven-repository-application</artifactId>
+ <name>Maven Repository Application</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-indexer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-discovery</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/repository-manager/trunk/maven-repository-application/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/repository-manager/trunk/maven-repository-application/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added:
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java?rev=367199&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java
(added)
+++
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java
Sun Jan 8 20:56:15 2006
@@ -0,0 +1,90 @@
+package org.apache.maven.repository.manager.cli;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * 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
+ *
+ * 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.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.repository.discovery.ArtifactDiscoverer;
+import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
+import org.apache.maven.repository.indexing.RepositoryIndexException;
+import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
+import org.codehaus.classworlds.ClassWorld;
+import org.codehaus.plexus.PlexusContainerException;
+import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.embed.Embedder;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Entry point for indexing CLI.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ */
+public class IndexCli
+{
+ public static void main( String[] args )
+ throws PlexusContainerException, ComponentLookupException,
RepositoryIndexException, MalformedURLException
+ {
+ Embedder embedder = new Embedder();
+ embedder.start( new ClassWorld() );
+
+ RepositoryIndexingFactory indexFactory =
+ (RepositoryIndexingFactory) embedder.lookup(
RepositoryIndexingFactory.ROLE );
+
+ ArtifactRepositoryFactory factory =
+ (ArtifactRepositoryFactory) embedder.lookup(
ArtifactRepositoryFactory.ROLE );
+
+ ArtifactRepositoryLayout layout =
+ (ArtifactRepositoryLayout) embedder.lookup(
ArtifactRepositoryLayout.ROLE, "legacy" );
+
+ ArtifactRepository repository = factory.createArtifactRepository(
"repository",
+ new
File( args[0] ).toURL().toString(),
+
layout, null, null );
+
+ ArtifactDiscoverer discoverer = (ArtifactDiscoverer) embedder.lookup(
ArtifactDiscoverer.ROLE, "legacy" );
+
+ List artifacts = discoverer.discoverArtifacts( new File(
repository.getBasedir() ), null, false );
+
+ ArtifactRepositoryIndex index =
+ indexFactory.createArtifactRepositoryIndex( new File( args[0],
".index" ).getAbsolutePath(), repository );
+
+ long time = System.currentTimeMillis();
+ try
+ {
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
+
+ index.indexArtifact( artifact );
+ }
+ index.optimize();
+ }
+ finally
+ {
+ index.close();
+ }
+ time = System.currentTimeMillis() - time;
+
+ System.out.println( "Indexed " + artifacts.size() + " artifacts in " +
time + "ms" );
+ }
+
+}
Propchange:
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java?rev=367199&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
(added)
+++
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
Sun Jan 8 20:56:15 2006
@@ -0,0 +1,78 @@
+package org.apache.maven.repository.manager.cli;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * 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
+ *
+ * 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.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
+import org.apache.maven.repository.indexing.ArtifactRepositoryIndexSearcher;
+import org.apache.maven.repository.indexing.RepositoryIndexException;
+import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
+import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
+import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
+import org.codehaus.classworlds.ClassWorld;
+import org.codehaus.plexus.PlexusContainerException;
+import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.embed.Embedder;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+/**
+ * Entry point for indexing CLI.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ */
+public class IndexSearcherCli
+{
+ public static void main( String[] args )
+ throws PlexusContainerException, ComponentLookupException,
RepositoryIndexException, MalformedURLException,
+ RepositoryIndexSearchException
+ {
+ Embedder embedder = new Embedder();
+ embedder.start( new ClassWorld() );
+
+ RepositoryIndexingFactory indexFactory =
+ (RepositoryIndexingFactory) embedder.lookup(
RepositoryIndexingFactory.ROLE );
+
+ ArtifactRepositoryFactory factory =
+ (ArtifactRepositoryFactory) embedder.lookup(
ArtifactRepositoryFactory.ROLE );
+
+ ArtifactRepositoryLayout layout =
+ (ArtifactRepositoryLayout) embedder.lookup(
ArtifactRepositoryLayout.ROLE, "legacy" );
+
+ ArtifactRepository repository = factory.createArtifactRepository(
"repository",
+ new
File( args[0] ).toURL().toString(),
+
layout, null, null );
+
+ ArtifactRepositoryIndex index =
+ indexFactory.createArtifactRepositoryIndex( new File( args[0],
".index" ).getAbsolutePath(), repository );
+
+ ArtifactRepositoryIndexSearcher searcher =
indexFactory.createArtifactRepositoryIndexSearcher( index );
+
+ try
+ {
+ System.out.println( searcher.search( new SinglePhraseQuery(
args[1], args[2] ) ) );
+ }
+ finally
+ {
+ index.close();
+ }
+ }
+
+}
Propchange:
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/repository-manager/trunk/maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/repository-manager/trunk/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/pom.xml?rev=367199&r1=367198&r2=367199&view=diff
==============================================================================
--- maven/repository-manager/trunk/pom.xml (original)
+++ maven/repository-manager/trunk/pom.xml Sun Jan 8 20:56:15 2006
@@ -129,6 +129,7 @@
</pluginManagement>
</build>
<modules>
+ <module>maven-repository-application</module>
<module>maven-repository-discovery</module>
<module>maven-repository-reports-standard</module>
<module>maven-repository-indexer</module>
@@ -219,6 +220,11 @@
<dependency>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-discovery</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-indexer</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>