Ivy doesn't work with dynamic artifact

I used Ivy a bit, but I seem to have a lot to learn.

I have two projects. One is the web application, and the other is the library on which the web application depends. The setup is that the library project is compiled into a jar file and published using Ivy in the directory inside the project. In the web application build file, I have an ant target that causes the Ivy task to solve ant.

I would like the web application to use the dynamic resolution mode during development (on local computers of developers) and the default resolution mode for test and production assemblies. I used to add a timestamp to the library archive file so Ivy would notice changes in the file when the web application tried to resolve its dependency on it. In Eclipse, this is cumbersome because the project needs to be updated in the web application and the build path changed every time a new library is published. I believe that the publication of the so-called jar file every time, as it seems to me, requires developers to only update the project.

The problem is that the web application cannot get the dynamic jar file.

The result I get looks something like this:

resolve: [ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ :: [ivy:configure] :: loading settings :: file = /Users/richard/workspace/webapp/web/WEB-INF/config/ivy/ivysettings.xml [ivy:resolve] :: resolving dependencies :: com.webapp#webapp; working@hoth-3.local [ivy:resolve] confs: [default] [ivy:resolve] found com.webapp#library;latest.integration in local [ivy:resolve] :: resolution report :: resolve 142ms :: artifacts dl 0ms --------------------------------------------------------------------- | | modules || artifacts | | conf | number| search|dwnlded|evicted|| number|dwnlded| --------------------------------------------------------------------- | default | 1 | 0 | 0 | 0 || 0 | 0 | --------------------------------------------------------------------- [ivy:resolve] [ivy:resolve] :: problems summary :: [ivy:resolve] :::: WARNINGS [ivy:resolve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:resolve] :: UNRESOLVED DEPENDENCIES :: [ivy:resolve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:resolve] :: com.webapp#library;latest.integration: impossible to resolve dynamic revision [ivy:resolve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:resolve] :::: ERRORS [ivy:resolve] impossible to resolve dynamic revision for com.webapp#library;latest.integration: check your configuration and make sure revision is part of your pattern [ivy:resolve] [ivy:resolve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS BUILD FAILED /Users/richard/workspace/webapp/build.xml:71: impossible to resolve dependencies: resolve failed - see output for details 

The goal of the solution for solving the web application is as follows:

 <target name="resolve" depends="load-ivy"> <ivy:configure file="${ivy.dir}/ivysettings.xml" /> <ivy:resolve file="${ivy.dir}/ivy.xml" resolveMode="${ivy.resolve.mode}"/> <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" type="jar" sync="true" /> </target> 

In this case, ivy.resolve.mode is set to "dynamic" (without quotes).

The Ivy file for web applications is simple. It looks like this:

 <ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"> <info organisation="com.webapp" module="webapp"/> <dependencies> <dependency name="library" rev="${ivy.revision.default}" revConstraint="${ivy.revision.dynamic}" /> </dependencies> </ivy-module> 

At development time, ivy.revision.dynamic is set to "last.integration". Although during production or test, the value of "ivy.revision.default" is set to "1.0".

Any ideas? Please let me know if you need more information.

Thanks!

+4
source share
2 answers

I added the following and it seems to work. I will warn about this with the recognition that I also struggle with ivy and a lot of material that works for me, it works to a large extent with a black box ... i.e. He does the job, so I stop messing around! My understanding is somewhat less developed, I'm afraid to say.

Anwyay, in settings.xml I added:

  <modules> <module organisation="my.organisation" name="*" resolveMode="dynamic"/> </modules> 

What I think, ivy says, to use his intelligence to work with these modules. This intelligence may include checking for updated versions of the module during resolution.

In addition, on resolvers, I added checkModified and changingPattern . Apparently, it's important to do this both on a real resolver and on a wrapping chain (if you have one):

 <chain name="foo" checkmodified="true" changingPattern=".*-SNAPSHOT"> <url name="bar" checkmodified="true" changingPattern=".*-SNAPSHOT"> <ivy pattern=... /> <artifact pattern=... /> </url> ... </chain> 

checkModified , hopefully does what it says on tin. And I understand that changingPattern tells ivy to check if artifacts containing this template have a new update in the repo. I personally use the maven repository in which the modifiable material always has -SNAPSHOT added to it, so I use this (quite often, I think). I think you could replace this changingPattern with ". *" Or something that suits you.

+4
source

I think you need to stop using the revConstraint attribute in your avap webapp file.

Ivy believes that "latest.revision" is the revision you want to get, instead of looking for the latest version :-)

I would recommend just setting the dependency as follows:

 <dependency name="library" rev="latest.integration"/> 

Explanation:

revConstraint is installed when the module is published. He is recording the latest version at the time of publication. Therefore, you do not need this during development. You also do not need to use the revision variable. When you publish an ivy module with reviews of "latest.revision" or "last.release", the requisition is allowed and recorded in the revConstraint attribute.

For more information, see the following link:

http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html#revision-constraint

+3
source

Source: https://habr.com/ru/post/1308518/


All Articles