Search code examples
javamavenantmuleivyde

IvyDE unable to resolve Mule dependencies


I am working with Apache Ivy to manage transitive dependencies.

Working with Maven was quite a good experience because if there was any dependency that was not available at a remote directory or available with a different version, then Maven would manage those effectively.

However, Ivy gets stuck with this in my case as I am trying to manage Mule dependencies but it is being difficult for Ivy to manage while Maven manages it well without any problems.

One more important point is that I cannot even exclude any dependency because I don't want to exclude but I want Ivy to be capable enough so that it can manage it all or any other way if any.

Below is a screenshot of the error along with the necessary XML files.

enter image description here

ivy.xml

<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="MyOrganization"
    module="TestForIvySupport"
    status="integration">
</info>

<dependencies>
    <dependency org="org.mule" name="mule-core" rev="3.6.0"/>       
</dependencies>

ivysettings.xml

<settings defaultResolver="chained"/>
<resolvers>
    <chain name="chained">
            <url name="custom-repo">
            <ivy pattern="https://repository.mulesoft.org/nexus/content/groups/public/org/[organisation]/[module]/[revision]/ivy-[revision].xml"/>
            <artifact pattern="https://repository.mulesoft.org/nexus/content/groups/public/org/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
            </url>
        <ibiblio name="ibiblio" m2compatible="true" root="http://mirrors.ibiblio.org/maven2/"/>
        <ibiblio name="ibiblio1" m2compatible="true" root="http://repo1.maven.org/maven2/"/>
   </chain>
</resolvers>

build.xml

<project name="test ivy" default="test" xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="test" description="Test ivy installation">
<ivy:settings file="ivysettings.xml"/>
    <ivy:retrieve sync="false" pattern="myfolder/[artifact]-[revision].[ext]"/>
</target> 


Solution

  • Using your example I had a different error:

    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve]       ::          UNRESOLVED DEPENDENCIES         ::
    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve]       :: org.mule.mvel#mule-mvel2;2.1.9-MULE-005: not found
    [ivy:resolve]       :: org.mule.common#mule-common;3.6.0: not found
    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    

    I eventually got it working but discovered a broken POM.

    Working Example

    ivy.xml

    <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="MyOrganization"
        module="TestForIvySupport"
        status="integration">
      </info>
    
      <dependencies>
        <!-- Exclude the broken dependency -->
        <dependency org="org.mule" name="mule-core" rev="3.6.0" conf="default">       
          <exclude org="com.github.stephenc.eaio-grabbag" module="grabbag"/>
        </dependency>
    
        <!-- Just pull down the jar artifact associated with the module -->
        <dependency org="com.github.stephenc.eaio-grabbag" name="grabbag" rev="1.8.1" conf="default">       
          <artifact name="grabbag" type="jar"/>
        </dependency>
      </dependencies>
    
    </ivy-module>
    

    Notes:

    • The POM associated with the grabbag dependency is broken.
    • Work-around tells ivy to ignore the POM and then we explicitly pull down the jar file as a second dependency declaration.

    ivysettings.xml

    <ivysettings>
      <settings defaultResolver="chained"/>
      <resolvers>
        <chain name="chained" returnFirst="true">
          <ibiblio name="central" m2compatible="true"/>
          <ibiblio name="mulesoft" m2compatible="true" root="https://repository.mulesoft.org/nexus/content/groups/public"/>
        </chain>
      </resolvers>
    </ivysettings>
    

    Notes:

    • Simplified the settings file to use ibiblio resources to talk to just two Maven repositories: Maven Central and the Mulesoft repository

    Error analysis

    Analysis of first error

    I tracked this down to a problem with the parent pom of the "mule-core" module.

    There is an override dependency where the property refers to a version of "mule-mvel2" module that doesn't exist in Maven Central

    <properties>
      ..
      <muleMvelVersion>2.1.9-MULE-005</muleMvelVersion>
      ..
    </properties>
    
    <dependency>
      <groupId>org.mule.mvel</groupId>
      <artifactId>mule-mvel2</artifactId>
      <version>${muleMvelVersion}</version>
    </dependency>
    

    Managed to fix this by adding the following Mulesoft repository.

    Analysis of second error

    Trouble shooting this further I discovered a second cascaded error:

    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve]       ::              FAILED DOWNLOADS            ::
    [ivy:resolve]       :: ^ see resolution messages for details  ^ ::
    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    [ivy:resolve]       :: com.github.stephenc.eaio-grabbag#grabbag;1.8.1!grabbag.non-maven-jar
    [ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
    

    This problem is more serious as it's caused by a misconfigured POM file:

    Where the packaging has been changed from the "jar" default

    <packaging>non-maven-jar</packaging>
    

    The ivy work-around for is to exclude this broken transitive dependency and then explicitly pull down the jar artifact as a second dependency in the ivy file.

    I have raised a github issue with the the project.