Skip to content

Maven plugin that supports "search by jar or directory" feature (equivalent to Google's 'Search by image').

License

Notifications You must be signed in to change notification settings

codspire/artifact-lookup-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Maven plugin that supports "search by jar or directory" feature (equivalent to Google's 'Search by image').

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published