Use ant-Ivy

Source: Internet
Author: User

Apache Ivy is used to manage jar package dependencies of projects. We know that Maven already has excellent functions in this regard. If you are already using Maven, there is no need to use Ivy. But in fact, in addition to this feature, Maven also has many powerful features. If you only need to manage jar package dependencies, you can only use Ivy, and Maven is a little useless.

1. first, your machine should have installed ant and JDK, preferably ant of version 1.6 or later, and the correct ant_home, java_home and PATH variables have been configured in the computer environment variables.

2. Next, create a folder on a disk, such as disk D, to install Ivy, such as D:/antivy.

3. Visit the following link to download the build. xml file:

Http://ant.apache.org/ivy/history/latest-milestone/samples/build.xml

Save the downloaded build. xml file in D:/antivy.

4. Open the doscommand line CD to enter the Directory D:/antivy

Enter ant and press enter to start Ivy installation. However, it may fail. In some cases, the computer cannot directly download some things and the agent is required. Therefore, you need to set the ant agent before allowing the ant command and run it first:

Set ant_opts =-dhttp. proxyhost = XXX. XXX. XXX-dhttp. proxyport = 1234

Then run the ant command to install Ivy.

5. After the installation is successful, the Ivy and SRC directories under D:/antivy and an Ivy. Jar directory under Ivy will copy the jar package to ant_home/lib. (In fact, the most important thing to do is to obtainIvy. JarFile. Others are floating clouds. If you can use other methods to obtain the ivy. jar file, you can use Ivy. The simplest way is to use Maven.
Search Ivy in repo to download it, haha .)

 

6. After the above five steps, the ivy installation and configuration have actually been completed. Let's take a look at how to use Ivy in example. There are several Ivy examples for accessing the following path:

Https://svn.apache.org/repos/asf/ant/ivy/core/trunk/src/example

You can download it to hello-Ivy, save the example, and run the doscommand line to enter the root directory of the hello-Ivy project. Run the command ant as follows:

 

D: \ antivy \ SRC \ example \ hello-Ivy> ant

Buildfile: Build. xml

 

Resolve:

No ivy: settings found for the default reference 'ivy. instance'. A default insta

NCE will be used

No settings file found, using default...

: Ivy 2.0.0-beta1-20071206070608: http://ant.apache.org/ivy ::

: Loading settings: url = jar: file:/D:/tool/ANT/lib/Ivy. Jar! /Org/Apache/Ivy/C

Ore/settings/ivysettings. xml

[IVY: retrieve]: Resolving dependencies: org. Apache # Hello-Ivy; working @ shni132

 

[IVY: retrieve] confs: [Default]

[IVY: retrieve] Found commons-lang # commons-lang; 2.0 in public

[IVY: retrieve] Found commons-cli # commons-CLI; 1.0 in public

[IVY: retrieve] Found commons-logging # commons-logging; 1.0 in public

[IVY: retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-la

Ng/2.0/commons-lang-2.0.jar...

[IVY: retrieve] ......

[IVY: retrieve]... (165kb)

[IVY: retrieve] .. (0kb)

[IVY: retrieve] [successful] commons-lang # commons-lang; 2.0! Commons-lang.jar (35

55 ms)

[IVY: retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli

/1.0/commons-cli-1.0.jar...

[IVY: retrieve]... (29kb)

[IVY: retrieve] .. (0kb)

[IVY: retrieve] [successful] commons-cli # commons-CLI; 1.0! Commons-cli.jar (1559 m

S)

[IVY: retrieve] downloading http://repo1.maven.org/maven2/commons-logging/commons

-Logging/1.0/commons-logging-1.0.jar...

[IVY: retrieve]... (21kb)

[IVY: retrieve] .. (0kb)

[IVY: retrieve] [successful] commons-logging # commons-logging; 1.0! Commons-Loggin

G. Jar (1715 ms)

[IVY: retrieve]: resolution Report: Resolve 6705 MS: artifacts DL 6829 Ms

[IVY: retrieve]: evicted modules:

[IVY: retrieve] commons-lang # commons-lang; 1.0 by [commons-lang # commons-lang; 2.0]

In [Default]

---------------------------------------------------------------------

| Modules | artifacts |

| Conf | Number | search | dwnlded | evicted | Number | dwnlded |

---------------------------------------------------------------------

| Default | 4 | 3 | 0 | 1 | 3 | 3 |

---------------------------------------------------------------------

[IVY: retrieve]: Retrieving: org. Apache # Hello-Ivy

[IVY: retrieve] confs: [Default]

[IVY: retrieve] 3 artifacts copied, 0 already retrieved (216kb/78 ms)

 

Run:

[Mkdir] created dir: D: \ antivy \ SRC \ example \ hello-Ivy \ build

[Javac] compiling 1 source file to D: \ antivy \ SRC \ example \ hello-Ivy \ build

[Java] standard message: hello Ivy!

[Java] capitalized by org. Apache. commons. Lang. wordutils: hello Ivy!

 

Build successful

Total time: 16 seconds

D: \ antivy \ SRC \ example \ hello-Ivy>

This is only the first time to run ant, And the jar package needs to be downloaded. So it is slow and many things are printed, but it will be very fast when ant is run again for the second time.

7. now let's take a look at Ivy in the root directory of the hello-Ivy instance project. XML and build. XML: This is a very simple file. You will understand it, and you know that you can copy it at will, and then use it in other projects after repair, modification, and modification. For example, if we create a javaproject in eclipse, we only need to copy the two files to the root directory of the new project. Eclipse generally has built-in ant, so I use built-in ant when running ant build. In this case, we need to configure ant in eclipse and add our Ivy. jar, you know.

8. window --> preferences --> ant --> runtime --> click ant home entries or globalentries --> Add external jar to install Ivy/Ivy under Ivy. jar can be added in.

In fact, the most important thing to use Ivy is to obtainIvy. JarYou can search for ivyat at http://search.maven.org. Put the obtained jar package in ant Lib.

The second is build. XML and Ivy. XML. Here we mainly write some ant commands in build. how to edit tags in XML to configure ant commands, and Ivy. the dependency is configured in XML, and the two files can be combined into one. If you are familiar with these configurations, there will be no good looking.

 Install the ivyde plug-in eclipse

Http://www.apache.org/dist/ant/ivyde/updatesite

Help --> install new software... --> Add

Set the name:Apacheivy Update site

Location is the URL above:Http://www.apache.org/dist/ant/ivyde/updatesite

Then, select the newly added updatesite during installation, and check apacheivyde and next to start installation.

OK. Restart eclipse. After the plug-in is installed, eclipse can also manage jar packages as Maven does.

 

Of course, you can copy your own ivyde's. ZIP file to eclipse's plugin and feature.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.