Ivy - output decision results to ivy file

ivy.xml developed my ivy.xml file, I would like to create a new resolved-ivy.xml file consisting of all the transitive dependencies found in the solution. Is it possible to do this?

This is different from delivery, which (I believe) only writes immediate dependencies from your ivy.xml , not transitive dependencies. The deliver Ant task has a delivertarget attribute, which looks in the documentation how it should be done. In practice, it works only for modules in one organization (as a rule, not for all dependencies) and generates a file for each module.

It is also different from the ivy-report XML file, which is generated at the time of resolution, but not much different. If what I'm trying is not possible, I just hack this file directly, I suppose.

The context here is trying to include repeatable reproducible assemblies , including when there are changes (new libraries, versions) in the repository. There are messages around the firewalls that are trying to do this, and none of them that I found can do it right.

  • Additions to the Ivy repository can change the results of the solution, in particular, if any dependencies in the repository (and not just in your project) depend on the range. Example: A depends on B;[2.0,4.0] and B;3.1 later added to the repository.
  • The idea is to allow, as usual, to write the solution as an Ivy flattened file, except in your VCS project for that tag (or something else), and then allow this file with transitive="false" . Assuming that existing items in the repository are not modified, this allows for repeated assemblies.
  • If anyone has the best ideas for this, I'm all ears. ResolveEngine now, I expect you to have to hack some combination of ResolveEngine to make ResolveReport available, and then add a custom DeliverEngine to use it.
+6
source share
2 answers

artifactreport> may help.

Use the delivery task to create ivy.xml with dynamic version constraints replaced by the static version constraint (ie [2.0.3.0 [becomes 2.2.1):

 <ivy:deliver conf="*(public)" deliverpattern="${dist.dir}/ivy.xml"/> 

Then use the permission task for this file to prepare for artifactreport.

 <ivy:resolve file="${dist.dir}/ivy.xml" conf="*(public)" refresh="true" type="ivy" /> 

Finally, artifactreport will perform a temporary resolution of dependencies.

 <ivy:artifactreport tofile="${dist.dir}/artifactreport.xml" /> 

artifactreport.xml will look like

 <modules> <module organisation="com.googlecode.flyway" name="flyway" rev="1.7" status="release"/> <module organisation="org.postgresql" name="postgresql-jdbc" rev="9.0" status="release"/> <module organisation="org.hibernate" name="hibernate" rev="3.3.2" status="release"/> <module organisation="org.apache.commons" name="commons-daemon" rev="1.0.2" status="release"/> ... 

Use XSLT to create the ivy.xml form.

+3
source

Under normal conditions, I would say that it is too killed. The problem you are trying to get around is that your repository is unreliable ..... Perhaps you should consider using the repository manager to manage your repository?

(The artifacts published in Maven Central were not intentionally changed , this ensures that people using the repository do not encounter build instabilities.)

Having said all this, if you cannot completely trust the configuration of the repository module, then what you are trying to do is perhaps using artifactreport ivy. It generates an XML report that can be converted using XSLT to a new ivy file.

Example

 $ tree . |-- build.xml |-- ivy.xml `-- src `-- main `-- xsl `-- artifactreport.xsl 

build.xml

 <project name="demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant"> <target name="init"> <ivy:resolve/> </target> <target name="build" depends="init"> <ivy:artifactreport tofile="build/reports/artifacts.xml"/> <xslt style="src/main/xsl/artifactreport.xsl" in="build/reports/artifacts.xml" out="build/ivy.xml"/> </target> </project> 

artifactreport.xsl

 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <ivy-module version="2.0"> <info organisation="com.myspotontheweb" module="demo"/> <dependencies> <xsl:apply-templates select="modules/module"/> </dependencies> </ivy-module> </xsl:template> <xsl:template match="module"> <dependency org="{@organisation}" name="{@name}" rev="{@rev}"/> </xsl:template> </xsl:stylesheet> 
+1
source

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


All Articles