Use Ivy to manage dependencies in your project

Source: Internet
Author: User

What is Ivy?

Ivy is a tool that keeps track of the relationship that has been directly related to managing projects. Ivy is flexible and configurable to accommodate a wide variety of dependency management and build process requirements; Although Ivy is a dependency management tool, it can be tightly integrated with Apache ant to take full advantage of the powerful mission capabilities ant provides in dependency management. Ivy is an open source project that offers a lot of powerful features, but the most popular and useful feature is its flexibility, integration with ant, and transitive dependency management.

Let's look at a simple example of how Ivy manages dependencies.

Ivy.xml

<Ivy-moduleversion= "2.0">    <InfoOrganisation= "Wufengtinghai"Module= "Wufengtinghai.alm"/>    <Dependencies>        <Dependencyorg= "Org.apache.commons"name= "Commons-collections4"Rev= "4.0"/>    </Dependencies></Ivy-module>

The version in the Ivy-module element first defines the Ivy versions used by this file. In the info element you can define your own organization information and the name of the module; The dependency element defines the specific dependency information, and we use org, name, and Rev to uniquely identify the dependency. where org is the organization information, name is the module name, and Rev is the version of the module. How do we define the specific dependencies that we need in the actual development in this file? Ivy uses the Maven2 component repository by default, so we can go to mvnrepositoy.com to find the module information we need, the information is as follows

We can see that there are a variety of XML dependencies on the dependency management tool definition in the diagram.

Build.xml

Ivy and Ant integration is done by defining the Ivy task in Ant's Build file to invoke Ivy's functionality to achieve dependency management. The contents of the build file are as follows

<?XML version= "1.0" encoding= "UTF-8"?><!--====================================================================== June 6, 2015 3:09:34                                                                     Ivy Description Hou ======================================================================  -<Projectname= "Ivywithdefaultsettingbuild"default= "Default"Xmlns:ivy= "Antlib:org.apache.ivy.ant">    <Description>using Ivy's basic configuration</Description>    < Propertyname= "Libdir"value=".. /lib "></ Property>    <!--================================= Target:default ================================= /c1> -    <Targetname= "Default"Description= "description">            <Ivy:retrieve/>    </Target>    <Targetname= "Clearivycache"Description= "description">                <Ivy:cleancache/>        </Target></Project>

We can see that you only need to introduce Ivy's namespace in the build file, and then you can declare the Ivy task implementation-dependent management. The retrieve task here uses the default configuration to manage the dependencies defined in Ivy.xml.

Execute with ant command

Implemented through Ant in Eclipse

Executed through Ivyide in Eclipse.

Use Ivy to manage dependencies in your project

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.