Maven Integration for Eclipse is extensively using local index for Maven repositories. There are several repository types supported:
- remote Maven repositories, such as Central repository at http://repo1.maven.org/maven2/
- local Maven repository
- Maven projects available in the Eclipse workspace
All those indexes are managed by Nexus indexer component, which is also used by Maven integration for NetBeans, Sonatype repository manager and Nexus indexer command line tool (CLI).
Nexus indexer component provides an API to index Maven repository, merge and download index updates. It also provides an API to search through registered indexes using various search criteria, including:
- Browse through repository indexes
- Search jars by artifactId and groupId
- Search jars by the packaging type (e.g. to find Maven plugins or Archetypes)
- Search jars by sha1 (e.g. to identify arbitrary jars with actual Maven artifacts)
- Search Maven artifacts/jar by class name (e.g. resolve classpath issues from build errors or class not found exceptions)
To get list of available options you can run it without parameters:
To index repository you need to specify repository name/id and path to repository on local file system (you can't index repository over http, ftp or scp). Additional parameters can be specified to set name of the directory where index will be created as well as index type.
When index folder contains previously created index, the tool will use it as a base line and will generate chunks for the incremental updates.
The indexer types could be one of default, min or full. You can also specify list of coma-separated custom index creators. An index creator should be a regular Plexus component, where its hint property would be the index type used in the command line.
Here is a command we use to index Central Maven repository:
After scanning of Maven repository it will create index folder and several files:
A .zip and .gz files contains legacy and the new transfer formats for repository index. Files with the yyyyMMdd are the incremental chunks containing index changes from the yyyyMMdd date up to now.The .properties file contains repository id, last update timestamp and list of published incremental updates:
Those files need to be copied to /.index folder at repository root. See for example http://repo1.maven.org/maven2/.index/.
Index configuration can be declared using org.maven.ide.eclipse.indexes extension point. It allows to specify repository url or even prepackaged index bundle and install it as a custom plugin dependent on the org.maven.ide.eclipse plugin. Here is how extension point declared for Maven central repository.
Note that central.zip is the same archive as nexus-maven-repository-index.zip produced by the Nexus indexer CLI.
The following code snippet shows how to obtain NexusIndexer and IndexUpdater components from MavenEmbedder.
|This should be done once and instance reused while application is running.|
The following snippet shows how to update/download remote index:
The following snippet shows how to run search query: