Coder Social home page Coder Social logo

codspire / artifact-lookup-maven-plugin Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 347 KB

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

License: Apache License 2.0

Java 97.46% Shell 2.54%
devops maven-plugin cicd

artifact-lookup-maven-plugin's Introduction

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

artifact-lookup-maven-plugin's People

Contributors

codspire avatar rakeshnagar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vbalaut rbioteau

artifact-lookup-maven-plugin's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.