Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ivy doesn't find my artifact in filesystem

I've got an artifact in my local filesystem, but Ivy doesn't resolve it unless I put the <filesystem> resolver inside a <chain>. And it renames the artifact extension when it resolves it.

Here's 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's 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>

The artifact is a .zip file. It's in the right place and named correctly (in accordance with the <artifact>'s pattern attribute. But when I run ant, it fails to 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 it find my module?

Then: if I put the <filesystem> element inside a <chain> element, it resolves:

[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 that's strange. Why did the <chain> make a difference? And BTW, why is my module now a JAR??? The source is a ZIP file, I swear. It's the right one, too - I just rebuilt the ZIP, and the latest changes are in my JAR file. Why did Ivy rename it?

like image 756
Ladlestein Avatar asked Feb 21 '23 23:02

Ladlestein


1 Answers

The default type of an artifact in ivy is jar and the default extension is jar, too. This will lead to the renaming.

You have to 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 have to define the filesystem resolver properly:

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

The best approach would be to define a proper ivy.xml for your special dependency, which clearly defines what artifacts are available. And put this in your dist folder.

See:

  • https://ant.apache.org/ivy/history/latest-milestone/ivyfile/publications.html
  • https://ant.apache.org/ivy/history/latest-milestone/ivyfile/artifact.html

And it is often a good idea to run ant with ant -v when debugging ivy. This will give great additional infos.

like image 54
oers Avatar answered Mar 08 '23 23:03

oers