List artifacts = discoverer.discoverArtifacts( repository, null, false );
ArtifactRepositoryIndex index =
- indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ).getAbsolutePath(), repository );
+ indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ), repository );
long time = System.currentTimeMillis();
try
layout, null, null );
ArtifactRepositoryIndex index =
- indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ).getAbsolutePath(), repository );
+ indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ), repository );
RepositoryIndexSearcher searcher = (RepositoryIndexSearcher) embedder.lookup( RepositoryIndexSearcher.ROLE );
--- /dev/null
+<?xml version="1.0"?>
+<project>
+ <parent>
+ <artifactId>maven-repository-manager</artifactId>
+ <groupId>org.apache.maven.repository</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-configuration</artifactId>
+ <name>Maven Repository Manager Configuration</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.modello</groupId>
+ <artifactId>modello-maven-plugin</artifactId>
+ <version>1.0-alpha-8</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xpp3-writer</goal>
+ <goal>java</goal>
+ <goal>xpp3-reader</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <version>1.0.0</version>
+ <model>src/main/mdo/configuration.mdo</model>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<model>
+ <id>configuration</id>
+ <name>Configuration</name>
+ <description>
+ Configuration for the Maven Repository Manager.
+ </description>
+ <defaults>
+ <default>
+ <key>package</key>
+ <value>org.apache.maven.repository.configuration</value>
+ </default>
+ </defaults>
+ <!-- TODO! break out subtypes such as <discovery> and create a list of blacklist -->
+ <classes>
+ <class rootElement="true" xml.tagName="configuration">
+ <name>Configuration</name>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>repositoryDirectory</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ <description>
+ The location of the repository to monitor.
+ </description>
+ </field>
+ <field>
+ <name>repositoryLayout</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ <description>
+ The layout of the repository. Valid values are "default" and "legacy".
+ </description>
+ <!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->
+ <defaultValue>default</defaultValue>
+ </field>
+ <field>
+ <name>indexPath</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ The location of the Lucene index to use for the repository. The default is the .index subdirectory of
+ the repository.
+ </description>
+ </field>
+ <field>
+ <name>minimalIndexPath</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ The location of the reduced Lucene index to use for the repository. The default is the .small-index
+ subdirectory of the repository.
+ </description>
+ </field>
+ <field>
+ <name>discoveryCronExpression</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>When to run the discovery mechanism.</description>
+ <defaultValue>0 0 8 * * ?</defaultValue>
+ </field>
+ <field>
+ <name>discoverSnapshots</name>
+ <version>1.0.0</version>
+ <type>boolean</type>
+ <description>Whether to include snapshot versions in the discovery process</description>
+ <defaultValue>false</defaultValue>
+ </field>
+ <field>
+ <name>discoveryBlackListPatterns</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>Blacklisted patterns in the discovery process</description>
+ </field>
+ </fields>
+ </class>
+ </classes>
+</model>
+
+
--- /dev/null
+<?xml version="1.0"?>
+<project>
+ <parent>
+ <artifactId>maven-repository-manager</artifactId>
+ <groupId>org.apache.maven.repository</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-core</artifactId>
+ <name>Maven Repository Manager Core</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
implements RepositoryIndex
{
// TODO: can this be derived from the repository? -- probably a sensible default, but still should be configurable, but this could just be on the call to open()
- private String indexPath;
+ private File indexPath;
private boolean indexOpen;
* @param indexPath
* @param repository
*/
- protected AbstractRepositoryIndex( String indexPath, ArtifactRepository repository )
+ protected AbstractRepositoryIndex( File indexPath, ArtifactRepository repository )
{
this.repository = repository;
this.indexPath = indexPath;
/**
* @see org.apache.maven.repository.indexing.RepositoryIndex#getIndexPath()
*/
- public String getIndexPath()
+ public File getIndexPath()
{
return indexPath;
}
protected boolean indexExists()
throws RepositoryIndexException
{
- File indexDir = new File( indexPath );
-
- if ( IndexReader.indexExists( indexDir ) )
+ if ( IndexReader.indexExists( indexPath ) )
{
return true;
}
- else if ( !indexDir.exists() )
+ else if ( !indexPath.exists() )
{
return false;
}
- else if ( indexDir.isDirectory() )
+ else if ( indexPath.isDirectory() )
{
- if ( indexDir.listFiles().length > 1 )
+ if ( indexPath.listFiles().length > 1 )
{
throw new RepositoryIndexException( indexPath + " is not a valid index directory." );
}
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.digest.Digester;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
* @param repository the repository where the indexed artifacts are located
* @param digester the digester object to generate the checksum strings
*/
- public ArtifactRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
+ public ArtifactRepositoryIndex( File indexPath, ArtifactRepository repository, Digester digester )
{
super( indexPath, repository );
this.digester = digester;
IndexSearcher searcher;\r
try\r
{\r
- searcher = new IndexSearcher( index.getIndexPath() );\r
+ searcher = new IndexSearcher( index.getIndexPath().getAbsolutePath() );\r
}\r
catch ( IOException e )\r
{\r
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.digest.Digester;
+import java.io.File;
+
/**
* @author Edwin Punzalan
* @plexus.component role="org.apache.maven.repository.indexing.RepositoryIndexingFactory"
*/
private ArtifactFactory artifactFactory;
- /**
- * @see RepositoryIndexingFactory#createArtifactRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
- */
- public ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
+ public ArtifactRepositoryIndex createArtifactRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new ArtifactRepositoryIndex( indexPath, repository, digester );
}
- /**
- * @see RepositoryIndexingFactory#createPomRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
- */
- public PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
+ public PomRepositoryIndex createPomRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new PomRepositoryIndex( indexPath, repository, digester, artifactFactory );
}
- /**
- * @see RepositoryIndexingFactory#createMetadataRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
- */
- public MetadataRepositoryIndex createMetadataRepositoryIndex( String indexPath, ArtifactRepository repository )
+ public MetadataRepositoryIndex createMetadataRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new MetadataRepositoryIndex( indexPath, repository );
* @param repository the repository where the indexed artifacts are located
* @param digester the digester object to generate the checksum strings
*/
- public EclipseRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
+ public EclipseRepositoryIndex( File indexPath, ArtifactRepository repository, Digester digester )
{
super( indexPath, repository );
public File getCompressedCopy()
throws IOException
{
- File indexPath = new File( getIndexPath() );
+ File indexPath = getIndexPath();
String name = indexPath.getName();
File outputFile = new File( indexPath.getParent(), name + ".zip" );
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;\r
import org.apache.maven.artifact.repository.metadata.Versioning;\r
\r
+import java.io.File;\r
import java.io.IOException;\r
import java.util.Iterator;\r
import java.util.List;\r
* @param indexPath the path to the index\r
* @param repository the repository where the metadata to be indexed is located\r
*/\r
- public MetadataRepositoryIndex( String indexPath, ArtifactRepository repository )\r
+ public MetadataRepositoryIndex( File indexPath, ArtifactRepository repository )\r
{\r
super( indexPath, repository );\r
}\r
* @param digester the digester to be used for generating checksums
* @param artifactFactory the factory for building artifact objects
*/
- public PomRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester,
+ public PomRepositoryIndex( File indexPath, ArtifactRepository repository, Digester digester,
ArtifactFactory artifactFactory )
{
super( indexPath, repository );
import org.apache.lucene.analysis.Analyzer;
import org.apache.maven.artifact.repository.ArtifactRepository;
+import java.io.File;
import java.util.Arrays;
import java.util.List;
*
* @return the path where the index resides
*/
- String getIndexPath();
+ File getIndexPath();
/**
* Tests an index field if it is a keyword field
import org.apache.maven.artifact.repository.ArtifactRepository;
+import java.io.File;
+
/**
* @author Edwin Punzalan
* @return the ArtifactRepositoryIndex instance
* @throws RepositoryIndexException
*/
- ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
+ ArtifactRepositoryIndex createArtifactRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException;
/**
* @return the PomRepositoryIndex instance
* @throws RepositoryIndexException
*/
- PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
+ PomRepositoryIndex createPomRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException;
/**
* @return the MetadataRepositoryIndex instance
* @throws RepositoryIndexException
*/
- MetadataRepositoryIndex createMetadataRepositoryIndex( String indexPath, ArtifactRepository repository )
+ MetadataRepositoryIndex createMetadataRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException;
}
private ArtifactRepository repository;
- private String indexPath;
+ private File indexPath;
private Digester digester;
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
digester = new DefaultDigester();
- indexPath = "target/index";
+ indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}
try
{
- String notIndexDir = new File( "pom.xml" ).getAbsolutePath();
+ File notIndexDir = new File( "pom.xml" );
ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( notIndexDir, repository );
indexer.indexArtifact( artifact );
fail( "Must throw exception on non-directory index directory" );
try
{
- String notIndexDir = new File( "" ).getAbsolutePath();
+ File notIndexDir = new File( "" );
ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( notIndexDir, repository );
indexer.indexArtifact( artifact );
fail( "Must throw an exception on a non-index directory" );
assertTrue( true );
}
- indexer = factory.createArtifactRepositoryIndex( "target/index/sample", repository );
+ indexer = factory.createArtifactRepositoryIndex( getTestFile( "target/index/sample" ), repository );
try
{
private ArtifactRepository repository;
- private String indexPath;
+ private File indexPath;
private Digester digester;
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
digester = new DefaultDigester();
- indexPath = "target/index";
+ indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}
try
{
- String notIndexDir = new File( "pom.xml" ).getAbsolutePath();
+ File notIndexDir = new File( "pom.xml" );
EclipseRepositoryIndex indexer = new EclipseRepositoryIndex( notIndexDir, repository, digester );
indexer.indexArtifact( artifact );
fail( "Must throw exception on non-directory index directory" );
try
{
- String notIndexDir = new File( "" ).getAbsolutePath();
+ File notIndexDir = new File( "" );
EclipseRepositoryIndex indexer = new EclipseRepositoryIndex( notIndexDir, repository, digester );
indexer.indexArtifact( artifact );
fail( "Must throw an exception on a non-index directory" );
{
EclipseRepositoryIndex index = createTestIndex();
- IndexSearcher searcher = new IndexSearcher( index.getIndexPath() );
+ IndexSearcher searcher = new IndexSearcher( index.getIndexPath().getAbsolutePath() );
try
{
QueryParser parser = new QueryParser( "j", index.getAnalyzer() );
{\r
private ArtifactRepository repository;\r
\r
- private String indexPath;\r
+ private File indexPath;\r
\r
private ArtifactFactory artifactFactory;\r
\r
ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );\r
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );\r
\r
- indexPath = "target/index";\r
+ indexPath = getTestFile( "target/index" );\r
FileUtils.deleteDirectory( indexPath );\r
}\r
\r
private ArtifactFactory artifactFactory;
- private String indexPath;
+ private File indexPath;
private Digester digester;
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
digester = new DefaultDigester();
- indexPath = "target/index";
+ indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}
try
{
- String notIndexDir = new File( "pom.xml" ).getAbsolutePath();
+ File notIndexDir = new File( "pom.xml" );
PomRepositoryIndex indexer = factory.createPomRepositoryIndex( notIndexDir, repository );
indexer.indexPom( pom );
fail( "Must throw exception on non-directory index directory" );
try
{
- String notIndexDir = new File( "" ).getAbsolutePath();
+ File notIndexDir = new File( "" );
PomRepositoryIndex indexer = factory.createPomRepositoryIndex( notIndexDir, repository );
indexer.indexPom( pom );
fail( "Must throw an exception on a non-index directory" );
\r
private ArtifactFactory artifactFactory;\r
\r
- private String indexPath;\r
+ private File indexPath;\r
\r
/**\r
* Setup method\r
ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );\r
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );\r
\r
- indexPath = "target/index";\r
+ indexPath = getTestFile( "target/index" );\r
FileUtils.deleteDirectory( indexPath );\r
}\r
\r
{
if ( artifact.getFile() != null )
{
- //@todo remove hard-coded value; current value enables tests to pass
- String indexPath = new File( "target/.index" ).getAbsolutePath();
+ //@todo remove hard-coded value; current value enables tests to pass!
+ File indexPath = new File( "target/.index" );
RepositoryIndex index;
try
private ArtifactFactory artifactFactory;
- private String indexPath = new File( "target/.index" ).getAbsolutePath();
+ private File indexPath = getTestFile( "target/.index" );
protected void setUp()
throws Exception
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-discovery</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-configuration</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-artifact-applet</artifactId>
*/\r
\r
import com.opensymphony.xwork.Action;\r
+import org.apache.maven.repository.configuration.Configuration;\r
import org.apache.maven.repository.manager.web.execution.DiscovererExecution;\r
import org.apache.maven.repository.manager.web.job.DiscovererScheduler;\r
\r
+import java.io.File;\r
+\r
/**\r
* This is the Action class of index.jsp, which is the initial page of the web application.\r
* It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.\r
{\r
try\r
{\r
- execution.executeDiscovererIfIndexDoesNotExist();\r
- discovererScheduler.setSchedule();\r
+ Configuration configuration = new Configuration(); // TODO!\r
+ execution.executeDiscovererIfIndexDoesNotExist( new File( configuration.getIndexPath() ) );\r
+ discovererScheduler.setSchedule( configuration.getDiscoveryCronExpression() );\r
}\r
catch ( Exception e )\r
{\r
import com.opensymphony.xwork.Action;\r
import org.apache.maven.artifact.repository.ArtifactRepository;\r
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;\r
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
+import org.apache.maven.repository.configuration.Configuration;\r
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;\r
import org.apache.maven.repository.indexing.RepositoryIndexException;\r
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;\r
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;\r
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;\r
-import org.apache.maven.repository.manager.web.job.Configuration;\r
\r
import java.io.File;\r
import java.net.MalformedURLException;\r
import java.util.List;\r
+import java.util.Map;\r
\r
/**\r
* Searches for searchString in all indexed fields.\r
private ArtifactRepositoryFactory repositoryFactory;\r
\r
/**\r
- * @plexus.requirement\r
+ * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"\r
*/\r
- private Configuration configuration;\r
+ private Map repositoryLayouts;\r
\r
public String execute()\r
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException\r
{\r
if ( searchString != null && searchString.length() != 0 )\r
{\r
- String indexPath = configuration.getIndexDirectory();\r
-\r
- // TODO: reduce the amount of lookup?\r
+ Configuration configuration = new Configuration(); // TODO!\r
+ File indexPath = new File( configuration.getIndexPath() );\r
\r
+ // TODO: [!] repository should only have been instantiated once\r
File repositoryDirectory = new File( configuration.getRepositoryDirectory() );\r
String repoDir = repositoryDirectory.toURL().toString();\r
\r
+ ArtifactRepositoryLayout layout =\r
+ (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );\r
ArtifactRepository repository =\r
- repositoryFactory.createArtifactRepository( "test", repoDir, configuration.getLayout(), null, null );\r
+ repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );\r
\r
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );\r
\r
import com.opensymphony.xwork.Action;
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.configuration.Configuration;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
-import org.apache.maven.repository.manager.web.job.Configuration;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
+import java.util.Map;
/**
* Search by package name.
private RepositoryIndexingFactory factory;
/**
- * @plexus.requirement
+ * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
- private ArtifactRepositoryFactory repositoryFactory;
+ private Map repositoryLayouts;
/**
* @plexus.requirement
*/
- private RepositoryIndexSearchLayer searchLayer;
+ private ArtifactRepositoryFactory repositoryFactory;
/**
* @plexus.requirement
*/
- private Configuration configuration;
+ private RepositoryIndexSearchLayer searchLayer;
public String execute()
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
return ERROR;
}
- // TODO: better config [!]
- String indexPath = configuration.getIndexDirectory();
+ // TODO: better config - share with general [!]
+ Configuration configuration = new Configuration();
+ File indexPath = new File( configuration.getIndexPath() );
- // TODO: reduce the amount of lookup?
File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
String repoDir = repositoryDirectory.toURL().toString();
+ ArtifactRepositoryLayout layout =
+ (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
ArtifactRepository repository =
- repositoryFactory.createArtifactRepository( "repository", repoDir, configuration.getLayout(), null, null );
+ repositoryFactory.createArtifactRepository( "repository", repoDir, layout, null, null );
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.model.Model;
+import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
import org.apache.maven.repository.discovery.MetadataDiscoverer;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.PomRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
-import org.apache.maven.repository.manager.web.job.Configuration;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
/**
* This is the class that executes the discoverer and indexer.
public class DiscovererExecution
extends AbstractLogEnabled
{
- /**
- * @plexus.requirement
- */
- private Configuration config;
/**
* @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer"
*/
private ArtifactRepositoryFactory repoFactory;
+ /**
+ * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
+ */
+ private Map repositoryLayouts;
+
/**
* Executes discoverer and indexer if an index does not exist yet
*
+ * @param indexDir
* @throws MalformedURLException
* @throws RepositoryIndexException
*/
- public void executeDiscovererIfIndexDoesNotExist()
+ public void executeDiscovererIfIndexDoesNotExist( File indexDir )
throws MalformedURLException, RepositoryIndexException
{
- Properties props = config.getProperties();
- String indexPath = props.getProperty( "index.path" );
-
- File indexDir = new File( indexPath );
boolean isExisting = false;
if ( IndexReader.indexExists( indexDir ) )
public void executeDiscoverer()
throws MalformedURLException, RepositoryIndexException
{
- Properties props = config.getProperties();
- String indexPath = props.getProperty( "index.path" );
- String blacklistedPatterns = props.getProperty( "blacklist.patterns" );
- boolean includeSnapshots = Boolean.valueOf( props.getProperty( "include.snapshots" ) ).booleanValue();
- boolean convertSnapshots = Boolean.valueOf( props.getProperty( "convert.snapshots" ) ).booleanValue();
+ Configuration configuration = new Configuration(); // TODO!
+ File indexPath = new File( configuration.getIndexPath() );
+ String blacklistedPatterns = configuration.getDiscoveryBlackListPatterns();
+ boolean includeSnapshots = configuration.isDiscoverSnapshots();
- ArtifactRepository defaultRepository = getDefaultRepository();
+ ArtifactRepository defaultRepository = getDefaultRepository( configuration );
getLogger().info( "[DiscovererExecution] Started discovery and indexing.." );
- String layoutProperty = props.getProperty( "layout" );
+ String layoutProperty = configuration.getRepositoryLayout();
ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty );
List artifacts = discoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots );
indexArtifact( artifacts, indexPath, defaultRepository );
- List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, convertSnapshots );
+ List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, includeSnapshots );
indexPom( models, indexPath, defaultRepository );
MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty );
List metadataList =
metadataDiscoverer.discoverMetadata( new File( defaultRepository.getBasedir() ), blacklistedPatterns );
- indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ), config.getLayout() );
+ indexMetadata( metadataList, indexPath, defaultRepository );
getLogger().info( "[DiscovererExecution] Finished discovery and indexing." );
}
* @param indexPath the path to the index file
* @param repository the repository where the artifacts are located
*/
- protected void indexArtifact( List artifacts, String indexPath, ArtifactRepository repository )
+ protected void indexArtifact( List artifacts, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
/**
* Index the metadata in the list
*
- * @param metadataList the metadata to be indexed
- * @param indexPath the path to the index file
- * @param repositoryBase the repository where the metadata are located
+ * @param metadataList the metadata to be indexed
+ * @param indexPath the path to the index file
*/
- protected void indexMetadata( List metadataList, String indexPath, File repositoryBase,
- ArtifactRepositoryLayout layout )
+ protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException, MalformedURLException
{
- String repoDir = repositoryBase.toURL().toString();
- ArtifactRepository repository =
- repoFactory.createArtifactRepository( "repository", repoDir, layout, null, null );
-
MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
{
* @param indexPath the path to the index
* @param repository the artifact repository where the poms were discovered
*/
- protected void indexPom( List models, String indexPath, ArtifactRepository repository )
+ protected void indexPom( List models, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
PomRepositoryIndex pomIndex = indexFactory.createPomRepositoryIndex( indexPath, repository );
* @return an ArtifactRepository instance
* @throws java.net.MalformedURLException
*/
- protected ArtifactRepository getDefaultRepository()
+ protected ArtifactRepository getDefaultRepository( Configuration configuration )
throws MalformedURLException
{
- File repositoryDirectory = new File( config.getRepositoryDirectory() );
+ // TODO! share with general search action, should only instantiate once
+ File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
String repoDir = repositoryDirectory.toURL().toString();
ArtifactRepositoryFactory repoFactory = new DefaultArtifactRepositoryFactory();
- return repoFactory.createArtifactRepository( "test", repoDir, config.getLayout(), null, null );
- }
-
- /**
- * Method that sets the configuration object
- *
- * @param config
- */
- public void setConfiguration( Configuration config )
- {
- this.config = config;
- }
-
- /**
- * Returns the cofiguration
- *
- * @return a Configuration object that contains the configuration values
- */
- public Configuration getConfiguration()
- {
- return config;
+ ArtifactRepositoryLayout layout =
+ (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
+ return repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
}
}
+++ /dev/null
-package org.apache.maven.repository.manager.web.job;\r
-\r
-/*\r
- * Copyright 2005-2006 The Apache Software Foundation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;\r
-import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;\r
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;\r
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;\r
-\r
-import java.util.Properties;\r
-\r
-/**\r
- * This class contains the configuration values to be used by the scheduler\r
- *\r
- * @todo should not need to be initializable [!] Should have individual configuration items, and they could well be configured on the job itself, not in this class\r
- */\r
-public class Configuration\r
- implements Initializable\r
-{\r
-\r
- private Properties props;\r
-\r
- /**\r
- * @throws InitializationException\r
- */\r
- public void initialize()\r
- throws InitializationException\r
- {\r
- }\r
-\r
- /**\r
- * Set the properties object\r
- *\r
- * @param properties\r
- */\r
- public void setProperties( Properties properties )\r
- {\r
- this.props = properties;\r
- }\r
-\r
- /**\r
- * Returns the properties object\r
- *\r
- * @return a Properties object that contains the configuration values\r
- */\r
- public Properties getProperties()\r
- {\r
- return props;\r
- }\r
-\r
- public ArtifactRepositoryLayout getLayout()\r
- {\r
- // TODO: lookup from map [!]\r
- ArtifactRepositoryLayout layout;\r
- if ( "legacy".equals( props.getProperty( "layout" ) ) )\r
- {\r
- layout = new LegacyRepositoryLayout();\r
- }\r
- else\r
- {\r
- layout = new DefaultRepositoryLayout();\r
- }\r
- return layout;\r
- }\r
-\r
- public String getIndexDirectory()\r
- {\r
- return props.getProperty( "index.path" );\r
- }\r
-\r
- public String getRepositoryDirectory()\r
- {\r
- String repositoryDir = "";\r
- if ( "default".equals( props.getProperty( "layout" ) ) )\r
- {\r
- repositoryDir = props.getProperty( "default.repository.dir" );\r
- }\r
- else if ( "legacy".equals( props.getProperty( "layout" ) ) )\r
- {\r
- repositoryDir = props.getProperty( "legacy.repository.dir" );\r
- }\r
- return repositoryDir;\r
- }\r
-}\r
import org.quartz.SchedulerException;\r
\r
import java.text.ParseException;\r
-import java.util.Properties;\r
\r
/**\r
* This class sets the job to be executed in the plexus-quartz scheduler\r
public class DiscovererScheduler\r
extends AbstractLogEnabled\r
{\r
- /**\r
- * @plexus.requirement\r
- */\r
- private Configuration config;\r
-\r
/**\r
* @plexus.requirement\r
*/\r
/**\r
* Method that sets the schedule in the plexus-quartz scheduler\r
*\r
+ * @param cronExpression\r
* @throws ParseException\r
* @throws SchedulerException\r
*/\r
- public void setSchedule()\r
+ public void setSchedule( String cronExpression )\r
throws ParseException, SchedulerException\r
{\r
- Properties props = config.getProperties();\r
JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );\r
JobDataMap dataMap = new JobDataMap();\r
dataMap.put( AbstractJob.LOGGER, getLogger() );\r
dataMap.put( DiscovererJob.MAP_DISCOVERER_EXECUTION, execution );\r
jobDetail.setJobDataMap( dataMap );\r
\r
- CronTrigger trigger =\r
- new CronTrigger( "DiscovererTrigger", "DISCOVERER", props.getProperty( "cron.expression" ) );\r
+ CronTrigger trigger = new CronTrigger( "DiscovererTrigger", "DISCOVERER", cronExpression );\r
scheduler.scheduleJob( jobDetail, trigger );\r
}\r
-\r
- /**\r
- * Method that sets the configuration object\r
- *\r
- * @param config\r
- */\r
- public void setConfiguration( Configuration config )\r
- {\r
- this.config = config;\r
- }\r
-\r
- /**\r
- * Returns the cofiguration\r
- *\r
- * @return a Configuration object that contains the configuration values\r
- */\r
- public Configuration getConfiguration()\r
- {\r
- return config;\r
- }\r
-\r
-\r
}\r
<implementation>org.codehaus.plexus.xwork.PlexusObjectFactory</implementation>
</component>
- <component>
- <role>org.apache.maven.repository.manager.web.job.Configuration</role>
- <implementation>org.apache.maven.repository.manager.web.job.Configuration</implementation>
- <configuration>
- <properties>
- <property>
- <name>layout</name>
- <value>default</value>
- </property>
- <property>
- <name>default.repository.dir</name>
- <value>C:/TEST_REPOS/.m2/repository/</value>
- </property>
- <property>
- <name>legacy.repository.dir</name>
- <value>C:/TEST_REPOS/.maven/repository/</value>
- </property>
- <property>
- <name>index.path</name>
- <value>C:/INDEX</value>
- </property>
- <property>
- <name>cron.expression</name>
- <value>0 0 8 * * ?</value>
- </property>
- <property>
- <name>blacklist.patterns</name>
- <value>null</value>
- </property>
- <property>
- <name>include.snapshots</name>
- <value>true</value>
- </property>
- <property>
- <name>convert.snapshots</name>
- <value>true</value>
- </property>
- </properties>
- </configuration>
- </component>
-
<!--
| Logger manager
-->
~ 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">
+<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven</groupId>
<module>maven-repository-webapp</module>
<module>maven-repository-proxy</module>
<module>maven-repository-manager-site</module>
+ <module>maven-repository-core</module>
+ <module>maven-repository-configuration</module>
</modules>
<dependencies>
<dependency>
<artifactId>maven-repository-artifact-applet</artifactId>
<version>${pom.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.repository</groupId>
+ <artifactId>maven-repository-configuration</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<reporting>
</build>
</profile>
</profiles>
-</project>
+</project>
\ No newline at end of file