Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven dependency exclusions: Same artifact-id issue

I have an Apache Cocoon Project and I wanted to update Apache FOP from 1.0 to 1.1, in order to fix foreign (non-latin) script issues, such as Greek.

I found FOP 1.1 has a Maven dependency:

<dependency>
  <groupId>org.apache.xmlgraphics</groupId>
  <artifactId>fop</artifactId>
  <version>1.1</version>
</dependency>

ERROR: Failed to execute goal on project X: Could not resolve dependencies for project com.X:jar:1.0-SNAPSHOT: Failure to find org.apache.avalon.framework:avalon-framework-api:jar:4.2.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

I search for a solution in this issue and I found that this dependency has broken links to some other dependencies, which FOP 1.1 needs to call. These are connected with Avalon framework API 4.2. I read in a mailing list that maybe trying to use exclusions and call extra dependencies is working fine. The solution was this code:

<dependency>
  <groupId>org.apache.xmlgraphics</groupId>
  <artifactId>fop</artifactId>
  <version>1.1</version>
  <exclusions>
    <exclusion>
     <artifactId>avalon-framework-api</artifactId>
     <groupId>org.apache.avalon.framework</groupId>
    </exclusion>
    <exclusion>
     <artifactId>avalon-framework-impl</artifactId>
     <groupId>org.apache.avalon.framework</groupId>
    </exclusion>
  </exclusions>
  </dependency>
  <!-- these two are to correct issues in fop dependency --> 
  <dependency>
   <groupId>avalon-framework</groupId>
   <artifactId>avalon-framework-api</artifactId>
   <version>4.2.0</version>
  </dependency>
  <dependency>
   <groupId>avalon-framework</groupId>
   <artifactId>avalon-framework-impl</artifactId>
   <version>4.2.0</version>
</dependency>

Now compilation returns the following ERROR2: "Failed to execute goal org.apache.cocoon:cocoon-maven-plugin:1.0.0-M2:prepare (prepare) on project X: There are at least two artifacts with the ID 'avalon-framework-api': avalon-framework:avalon-framework-api:jar:4.2.0:compile".

Of course there are. Two dependencies are excluded, the broken ones, and two of them are called, the correct ones. How can I fix this issue?

like image 509
kiddo Avatar asked Jan 12 '23 09:01

kiddo


1 Answers

Haven't tested this yet, but perhaps excluding org.apache.avalon.framework v4.2.0 and include the latest v4.3.1 instead. Such as:

    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>fop</artifactId>
        <version>1.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.avalon.framework</groupId>
                <artifactId>avalon-framework-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.avalon.framework</groupId>
                <artifactId>avalon-framework-impl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.avalon.framework</groupId>
        <artifactId>avalon-framework-api</artifactId>
        <version>4.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.avalon.framework</groupId>
        <artifactId>avalon-framework-impl</artifactId>
        <version>4.3.1</version>
    </dependency>
like image 56
Tristan Everitt Avatar answered Jan 22 '23 00:01

Tristan Everitt