amorfis
amorfis

Reputation: 15770

Gradle cannot resolve dependency

In my build.gradle file I have a line in dependencies:

compile group: 'org.jboss.seam.validation', name: 'seam-validation-api', version:'3.1.0.Final'

When I try to run the project, e.g. 'test' task, I get an error:

> Could not resolve org.jboss.seam.validation:seam-validation-api:3.1.0.Final.
Required by:
    com.smspl.mc5:mc5-web-ui:1.0.0-SNAPSHOT
    com.smspl.mc5:mc5-web-ui:1.0.0-SNAPSHOT > com.smspl.mc5:mc5-common-rest:1.0.0-SNAPSHOT
> Could not parse POM /Users/amorfis/.m2/repository/org/jboss/seam/validation/seam-validation-api/3.1.0.Final/seam-validation-api-3.1.0.Final.pom
  > Unable to resolve version for dependency 'javax.enterprise:cdi-api:jar'
> Could not parse POM https://nexus.softwaremill.com/content/groups/smlcommon-repos/org/jboss/seam/validation/seam-validation-api/3.1.0.Final/seam-validation-api-3.1.0.Final.pom
  > Unable to resolve version for dependency 'javax.enterprise:cdi-api:jar'

I'm aware that the problem is that version of 'javax.enterprise:cdi-api:jar' is not specified in the seam-validation-api pom. It is specified in it's parent, and gradle probably has some problems figuring it out. The parent part of seam-validation-api pom looks like this:

<parent>
    <groupId>org.jboss.seam.validation</groupId>
    <artifactId>seam-validation-parent</artifactId>
    <version>3.1.0.Final</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<dependencies>
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

My gut feeling tells me the problem is in part. I also tried to add this parent dependency explicitely, by adding new line to build.gradle 'dependencies', but without any luck.

Anyone knows solution to this?

UPDATE: In the parent pom:

<groupId>org.jboss.seam.validation</groupId>
<artifactId>seam-validation-parent</artifactId>
<packaging>pom</packaging>
<version>3.1.0.Final</version>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.seam</groupId>
            <artifactId>seam-bom</artifactId>
            <version>${seam.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Upvotes: 2

Views: 4236

Answers (1)

akhikhl
akhikhl

Reputation: 2578

Here is a little research of the problem (only research, NOT a solution):

  1. seam-validation-api-3.1.0.Final.pom has parent seam-validation-parent-3.1.0.Final.pom

  2. seam-validation-parent-3.1.0.Final.pom has parent seam-parent-19.pom

  3. The file seam-parent-4.pom contained version definition for cdi-api, but seam-parent-19.pom does not.

  4. The file seam-validation-parent-3.0.0.Final.pom did contain dependencyManagement for cdi-api, but newer version seam-validation-parent-3.1.0.Final.pom does not.

I also looked into the code of GradlePomModuleDescriptorBuilder (the class that throws the abovementioned "Could not resolve..." exception). It seems that the class looks for DependencyManagement sections up the parent-pom chain, but it does not respect resolutionStrategy (or any other definitions from gradle script). So currently it is not possible to augment/override dependencyManagement of POM.

My advice: contact the developer(s) of seam framework and ask them to fix the dependencies.

Upvotes: 2

Related Questions