1
votes

Am running mvn clean install on my gitlab ci/cd docker image and it throws the following error below.

[ERROR] Failed to execute goal on project bootstrap.service: Could not resolve dependencies for project com.sheeft:bootstrap.service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.google.firebase:firebase-admin:jar:6.10.0 -> com.google.cloud:google-cloud-firestore:jar:1.9.0 -> com.google.cloud:google-cloud-core-grpc:jar:1.79.0 -> io.grpc:grpc-netty-shaded:jar:1.21.0 -> io.grpc:grpc-core:jar:[1.21.0]: No versions available for io.grpc:grpc-core:jar:[1.21.0] within specified range -> [Help 1]

So I tried the following in my pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.sheeft</groupId>
    <artifactId>bootstrap.service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Sheeft Bootstrap Service</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-core</artifactId>
                <version>1.23.0</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-api</artifactId>
                <version>[1.23.0]</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.vaadin.external.google</groupId>
                    <artifactId>android-json</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- 2fa -->
        <dependency>
            <groupId>org.jboss.aerogear</groupId>
            <artifactId>aerogear-otp-java</artifactId>
            <version>1.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.inlaks</groupId>
            <artifactId>inlaks-util-lib</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.derby/derby -->
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20160212</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.firebase</groupId>
            <artifactId>firebase-admin</artifactId>
            <version>6.10.0</version>
            <exclusions>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-netty-shaded</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-core</artifactId>
            <version>1.23.0</version>
            <exclusions>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
            <version>1.23.0</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-api</artifactId>
            <version>[1.23.0]</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

so the error is a bit different now but it is weird

[ERROR] Failed to execute goal on project bootstrap.service: Could not resolve dependencies for project com.sheeft:bootstrap.service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at io.grpc:grpc-core:jar:1.23.0 -> io.grpc:grpc-api:jar:[1.23.0]: No versions available for io.grpc:grpc-api:jar:[1.23.0] within specified range -> [Help 1]

what is weird about the above error is that it actually downloaded the dependency as seen below

Downloading from central: https://repo.maven.apache.org/maven2/io/grpc/grpc-api/1.23.0/grpc-api-1.23.0.pom Downloaded from central: https://repo.maven.apache.org/maven2/io/grpc/grpc-api/1.23.0/grpc-api-1.23.0.pom (0 B at 0 B/s)

1
make sure you have these dependencies in your maven repositoryDevDio
@DevDio they are there I run mvn CLI options compile and it builds successfully.DaviesTobi alex
Possible duplication of No versions available for grpc:grpc-corejar1.13.1. Could also just be that when you run it on your docker image you not reaching your maven repo.Ambro-r
@Ambro-r I have updated the question, I looked at the link you shared and it helped a lot. please take a look.DaviesTobi alex

1 Answers

0
votes

You explicitly refere to grpc-api versio 1.21.1 which prefent transient dependecny load from grpc-core 1.23 with related version. Why do you want them different? If you wanna keep them like this you have to exclude grpc-api from grpc-core.

But easier way to handle it is keep one version for api and core.

Maven range syntax: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html

For Core module it's only strict version compatibility defined as:

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>[1.23.0]</version>
<scope>compile</scope>
</dependency>