mavenjenkins

Apache Maven tries to download a dependency previously added


I have a project that will use dependencies from Maven Central and manually downloaded from a local Nexus (with curl). However, after mvn install:install-file, which installed a jar file downloaded from my Nexus, it's for some reason tries to download from a mirror defined in settings.xml. I would like to know what I miss. Commands used and their output:

mvn install:install-file '-Dfile=code-base-2.1.2.jar' '-DgroupId=com.rd' '-DartifactId=code-base' '-Dversion=2.1.2' '-Dpackaging=jar'

I can confirm that by ls -R output:

/home/jenkins/.m2/repository/com/rd/code-base/2.1.2:
_remote.repositories
code-base-2.1.2.jar
code-base-2.1.2.pom

Produces:

[INFO] Installing /home/jenkins/agent/workspace/code-base-2.1.2.jar to /home/jenkins/.m2/repository/com/rd/code-base/2.1.2/code-base-2.1.2.jar
[INFO] Installing /tmp/code-base-2.1.214636295790052122099.pom to /home/jenkins/.m2/repository/com/rd/code-base/2.1.2/code-base-2.1.2.pom

After that mvn clean install was executed and that produced this output:

[ERROR] Failed to execute goal on project ins-service: Could not resolve dependencies for project com.rd:ins-service:jar:0.0.1-SNAPSHOT
[ERROR] dependency: com.rd:code-base:jar:2.1.2 (compile)
[ERROR]     Could not find artifact com.rd:code-base:jar:2.1.2 in internal-repository (https://repo.maven.apache.org/maven2/) 

pom.xml of the project:

<?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 https://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>3.4.4</version>
        <relativePath/>
    </parent>
    <groupId>com.rd</groupId>
    <artifactId>ins-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ins-service</name>

    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.rd</groupId>
            <artifactId>code-base</artifactId>
            <version>2.1.2</version>
            <scope>compile</scope>
        </dependency>
</project>

Maven version is 3.9.9


Solution

  • Changed -DgroupId=com.rd to -DgroupId=com. That fixed the build as the dependency was installed at the incorrect path.