Ivy doesn't find my artifact on file system

I have an artifact in my local file system, but Ivy will not allow it unless I put the <file system> resolver inside the <chain>. And he renames the extension of the artifact when he resolves it.

Here is my ivy.xml:

<ivy-module version="2.0"> <info organisation="apache" module="hello-ivy"/> <dependencies> <dependency org="myorg" name="mymodule" rev="1.1-SNAPSHOT"/> </dependencies> </ivy-module> 

And here is my ivysettings.xml:

 <ivysettings> <settings /> <resolvers> <filesystem name="local"> <artifact pattern="/path/to/my/artifact/[module]/dist/[module]-[revision].zip" /> </filesystem> </resolvers> </ivysettings> 

My build.xml:

 <project xmlns:ivy="antlib:org.apache.ivy.ant" name="hello-ivy" default="deps"> <target name="deps" description="--> retrieve dependencies with ivy"> <ivy:settings file="ivysettings.xml"/> <ivy:resolve /> <ivy:retrieve /> </target> </project> 

An artifact is a .zip file. It is in the right place and correctly named (according to the <artifact> attribute. But when I run ant, it cannot resolve the artifact:

 [ivy:resolve] :::: WARNINGS [ivy:resolve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:resolve] :: UNRESOLVED DEPENDENCIES :: [ivy:resolve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:resolve] :: myorg#mymodule;1.1-SNAPSHOT: no resolver found for myorg#mymodule: check your configuration [ivy:resolve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:resolve] :::: ERRORS [ivy:resolve] unknown resolver null [ivy:resolve] no resolver found for myorg#mymodule: check your configuration 

Why doesn't he find my module?

Then: if I put the <file system> element inside the <chain> element, it solves:

 [ivy:resolve] found myorg#mymodule;1.1-SNAPSHOT in local [ivy:resolve] downloading /path/to/my/artifact/mymodule/dist/mymodule-1.1-SNAPSHOT.zip [ivy:resolve] ..................(lots of dots here).....(37899kB) [ivy:resolve] [SUCCESSFUL ] myorg#mymodule;1.1-SNAPSHOT!mymodule.jar (430ms) 

So strange. Why does <chain> make a difference? And BTW, why is my module now JAR ??? The source is a ZIP file, I swear. This is also correct, I just rebuilt the ZIP, and the latest changes are in my JAR file. Why did Ivy rename it?

+4
source share
1 answer

By default, the artifact type in the plus is jar, and the default extension is jar. This will result in renaming.

You should define your dependency like this (explicitly define the artifact):

 <dependency org="myorg" name="mymodule" rev="1.1-SNAPSHOT"> <artifact name="mymodule" type="zip" conf="A,B"/> </dependency> 

But you must correctly identify the file system resolver:

  <filesystem name="local"> <artifact pattern="/path/to/my/artifact/[module]/dist/[module]-[revision].[ext]" /> </filesystem> 

The best approach would be to determine the correct ivy.xml for your special dependency, which clearly defines which artifacts are available. And put it in your dist folder.

Cm:

And it is often good to run ant with ant -v when debugging ivy. This will provide additional additional information.

+8
source

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


All Articles