Can anyone explain the confia attribute of the ivy.xml dependency?

I cannot find a detailed explanation of the conf attribute of the Ivy dependency tag:

<dependency org="hibernate" name="hibernate" rev="3.1.3" conf="runtime, standalone -> runtime(*)"/> 

See this conf attribute? I can not find an explanation (that I can understand) about the right side of the character -> . Please remember that I do not know primarily about Maven, so please explain this attribute with this consideration.

Yes, I already looked at this: http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html

Thank,
Dan

+60
java apache ant ivy
Mar 16 '09 at 23:36
source share
4 answers

First of all, Ivy is not Maven ;)
Maven2 is a project and software management tool, while Ivy is just a dependency management tool.

Ivy relies heavily on a unique concept .
In ivy, a module configuration is a way to use or view a module .
For example, you may have a test and runtime configuration in your module. But you can also have mysql and oracle configuration. Or sleep mode and jdbc configuration.

In each configuration, you can declare:

  • what artifacts (jar, war, ...) are required.
  • your dependencies on other modules and indicate which configuration is up to you. This is called a configuration mapping.

Thus, the conf attribute does just that: Describes the configuration mapping for a dependency.
the displayed child is your "right side of the character -> " and is the name of the displayed dependency configuration. The wildcard character '*' can be used to indicate all configurations of this module.




Maven2 for its part has something called an area .
You can declare a dependency as part of a validation area or build time area.
Then, depending on this area, you will get a dependency artifact (only one artifact for each module in maven2) with its dependencies depending on their volume. Scopes are predefined in maven2, and you cannot change this.

It means:

Many libraries have many unnecessary dependencies loaded.
For example, Hibernate loads a bunch of JBoss JARs, and Display Tag loads all the various JARs in the web. I found that I eliminate almost as many dependencies as I added.

The problem is that hibernation can be used with multiple cache implementations, multiple connection pool implementations ... And this cannot be implemented using areas where Ivy configurations offer an elegant solution to this problem.
For example, in plus , assuming hibernate has an ivy file like this , then you can declare a dependency like this :

 <dependency org="hibernate" name="hibernate" rev="2.1.8" conf="default->proxool,oscache"/> 

to get hibernation with its proxool and oscache implementations, and like this:

 <dependency org="hibernate" name="hibernate" rev="2.1.8" conf="default->dbcp,swarmcache"/> 

to get hibernation using dbcp and swarmcache.

By mapping the default configuration of master to " proxool,oscache " or to " dbcp,swarmcache ", you determine exactly what you need from the "hibernate" module.




You can find these arguments "proxool, ..." by specifying the ivy configuration defined for each module associated with the library. For example:

 <ivy-module version="2.0"> <info organisation="ssn-src" module="pc"/> <configurations defaultconfmapping="default->default"> <conf name="default" /> <conf name="provided" description="they are provided by the env." /> <conf name="compile" extends="default,provided" /> <conf name="war" extends="default"/> </configurations> <dependencies> 

An example :

suppose modA has two configurations, the default and the test.
In practical terms, it is very unusual to want to leave the conf attribute of the dependency element.
ivy.xml for modA may have a dependency:

 <dependency org="theteam" name="modB" rev="1.0" conf="default->*" /> 

You start with a default value, not both the default and the test.

The above example makes modA default dependent on modB conf1, conf2 and conf3.
Or you can say that the default modA value depends only on modB conf1:

 <dependency org="theteam" name="modB" rev="1.0" conf="default->*conf1*" /> 
+68
Mar 17 '09 at 8:44
source share

Thanks VonC!

It helped me even more.

When it comes to tieTYT parameters (configurations), they can be found in the ivy- [revision number] .xml file in your Ivy repository under: organization name → module name.

Example configuration item from JUnit 4.6 downloaded from http://www.springsource.com/ repository / application / .

 <configurations> <conf name="compile" visibility="public" description="Compile dependencies"/> <conf name="optional" visibility="public" extends="compile" description="Optional dependencies"/> <conf name="provided" visibility="public" description="Provided dependencies"/> <conf name="runtime" visibility="public" extends="compile" description="Runtime dependencies"/> </configurations> 

In my project ivy.xml file, I have a configuration configuration test. In the dependency element, I have the following dependency:

 <dependency org="org.junit" name="com.springsource.org.junit" rev="4.6.0" conf="compile-test->compile" /> 

As you can see, my compilation configuration configuration depends on the compilation configuration in the JUnit ivy.xml file.

+13
Jul 31 '09 at 20:50
source share

I read these answers, and to be honest, I do not find them very useful. I think they can be improved, so I wrote down how I use and understand the configurations, showing a practical example:

http://wrongnotes.blogspot.com/2014/02/simplest-explanation-of-ivy.html

Unfortunately, you need to understand a little bit about maven and its dependencies, because Ivy uses Maven repositories to pull these jar files, so Ivy needs to understand Maven, and it passes it to you. But, I think, I kept it very simple, without going into details about maven.

+10
Feb 17 '14 at 22:02
source share

This helped me figure this out:

  • Ivy configuration is just a name for some subset of module artifacts.
  • Dependencies between modules are specified in terms of configuration names.
+7
May 04 '10 at 17:15
source share



All Articles