Artifact Lookup/Search Maven Plugin

Artifact Lookup/Search Plugin for Maven 3. The Lookup/Search Plugin searches a local jar/zip file in a remote repository and returns Maven dependency node if found in the remote repository.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.codspire.plugins
ArtifactId

ArtifactId

artifact-lookup-maven-plugin
Last Version

Last Version

0.6.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Artifact Lookup/Search Maven Plugin
Artifact Lookup/Search Plugin for Maven 3. The Lookup/Search Plugin searches a local jar/zip file in a remote repository and returns Maven dependency node if found in the remote repository.
Project URL

Project URL

https://github.com/codspire/artifact-lookup-maven-plugin
Source Code Management

Source Code Management

https://github.com/codspire/artifact-lookup-maven-plugin

Download artifact-lookup-maven-plugin

How to add to project

<plugin>
    <groupId>com.codspire.plugins</groupId>
    <artifactId>artifact-lookup-maven-plugin</artifactId>
    <version>0.6.0</version>
</plugin>

Dependencies

compile (9)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.3.9
commons-collections : commons-collections jar 3.2.2
commons-configuration : commons-configuration jar 1.10
commons-io : commons-io jar 2.4
org.apache.httpcomponents : httpclient jar 4.5.2
org.apache.httpcomponents : httpcore jar 4.4.4
commons-codec : commons-codec jar 1.10
org.apache.commons : commons-lang3 jar 3.4
org.apache.maven : maven-artifact jar 3.3.9

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-all jar 1.3
org.mockito : mockito-all jar 1.10.19
org.apache.maven : maven-core jar 3.3.9

Project Modules

There are no modules declared in this project.

Artifact Lookup Maven Plugin

Apache License, Version 2.0, January 2004 Maven Central Build Status Dependency Status Coverage Status Codacy Badge

This "Artifact Lookup Maven Plugin" acts as a Maven command line utility that performs checksum based search of local jar/zip files in the remote Maven repositories. The search results are returned in a pom friendly format (groupId, artifactId & version) that can be used in a pom file. Artifact Lookup Maven Plugin Info

Motivation

Ability to search a remote Maven repository by jar or directory could be quite beneficial, specially for legacy Java projects that are migrating to Maven. Such migration often involves the daunting task of locating the existing project dependencies in the remote Maven repositories which could take several days or weeks based on the size and complexity of the project. This activity becomes even harder and error prone if the jar files are scattered across many directories/sub-directories and their naming is not alignd to version based naming convention (e.g. httpclient.jar as against httpclient-4.5.2.jar).

Usage

$ mvn com.codspire.plugins:artifact-lookup-maven-plugin:lookup

Usage Options

This plugin follows a minimalistic approach. Available options are:

Name Type Description
-no parameters- N/A Searches all jar/zip files that exist in the current directory and sub-directories in remote Maven repositories based on user's effective settings.xml
artifactLocation String Local system path where artifacts are present. It could be path to specific jar/zip file or a directory. If a directory path is specified, all jar/zip files in that directory and sub-directories will be searched in the remote Maven repositories. Default value is: current directory from where the plugin is executed.
recursive boolean Flag to specify if the artifacts from sub-directories need to be searched. Default value is: true.
repositoryUrl String Resolve all qualified jar/zip files (based on other parameters) from the specified remote repositories. Supports csv format to specify multiple repositories.

Build & Installation (if you don't have direct access to Maven Central)

$ git clone https://github.com/codspire/artifact-lookup-maven-plugin.git

$ cd artifact-lookup-maven-plugin

$ mvn install

Key Points

  • Artifacts are searched based on SHA1 checksum of the file.
  • Default Maven remote repositories are determined based on user's effective Maven settings.xml file.
  • If there are more than one remote repository, the jars are sequentially searched against all repositories until the match is found.

Usage Examples

Example 1: Search all jars in a folder in default remote repository

cd to the folder that contains jar files; suppose the folder contains below jars that you'd like to search in the remote Maven repository.

$ ls
activation.jar  commons-io.jar  junit.jar

run the plugin

$ mvn com.codspire.plugins:artifact-lookup-maven-plugin:lookup
[INFO] Scanning for projects...
...
...
[INFO] ------------------------------------------------------------------------
[INFO] DEPENDENCIES
[INFO] ------------------------------------------------------------------------
[INFO]
<dependencies>
        <!-- Resolved from http://repo.maven.apache.org/maven2 -->
        <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
        </dependency>
        <!-- Resolved from http://repo.maven.apache.org/maven2 -->
        <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
                <version>1.1</version>
        </dependency>
        <!-- Resolved from http://repo.maven.apache.org/maven2 -->
        <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.4</version>
        </dependency>
</dependencies>

[INFO] ------------------------------------------------------------------------
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Example 2: Search specific jar in default remote repository

$ mvn com.codspire.plugins:artifact-lookup-maven-plugin:lookup \
-DartifactLocation=./activation.jar
[INFO] Scanning for projects...
...
...
[INFO] ------------------------------------------------------------------------
[INFO] DEPENDENCIES
[INFO] ------------------------------------------------------------------------
[INFO]
<dependencies>
        <!-- Resolved from http://repo.maven.apache.org/maven2 -->
        <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
                <version>1.1</version>
        </dependency>
</dependencies>

[INFO] ------------------------------------------------------------------------
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Example 3: Search specific jar in alternate remote repository (supersedes settings.xml)

$ mvn com.codspire.plugins:artifact-lookup-maven-plugin:lookup \
 -DartifactLocation=./activation.jar \
 -DrepositoryUrl=https://oss.sonatype.org/content/groups/public/
[INFO] Scanning for projects...
...
...
[INFO] ------------------------------------------------------------------------
[INFO] DEPENDENCIES
[INFO] ------------------------------------------------------------------------
[INFO]
<dependencies>
        <!-- Resolved from https://oss.sonatype.org/content/groups/public/ -->
        <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
                <version>1.1</version>
        </dependency>
</dependencies>

[INFO] ------------------------------------------------------------------------
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Tested With

Author

Rakesh Nagar

Rakesh Nagar

Licence

This code is released under the Apache License Version 2.0. See LICENSE

Versions

Version
0.6.0
0.5.0
0.4.0
0.2.0
artifact-lookup-maven-plugin-0.2.0