Piotr Gabryanczyk’s Blog

Java, Refactoring, AOP, Spring, DDD, TDD, etc.

  • Blogroll

    • I have joined Anti-IF Campaign

How to resolve java dependency from the command line without maven

Posted by Piotr Gabryanczyk on September 26, 2010

Problem

I want to be able to download java library and it’s dependencies using simple command-line tool i.e.
ivy.sh resolve jetty jetty 5.1.10

Solution

  • Download Ivy. Ivy understands maven repositories and can do the job for you.
  • Create a script ivy.sh in ivy installation directory with the following content:

    cd=`dirname $0`
    if [ "$1" == "resolve" ]; then
            shift
            echo "Resolving $1 $2 $3"
            java -jar $cd/ivy-2.2.0-rc1.jar -retrieve ./[artifact]-[revision]-[type].[ext] -dependency $*
    fi

  • Make your script executable:
    chmod a+x ivy.sh
  • Add it to the path ie. ~/.bash_profile
    export PATH=$PATH:/where/you/have/ivy.sh

Enjoy!

Advertisements

One Response to “How to resolve java dependency from the command line without maven”

  1. redolcas said

    Thank you very much! This is awesome.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: