Search code examples
mavenmaven-deploy-pluginaws-codeartifact

Maven Failed to deploy artifacts: Could not find artifact - CodeArtifact


I'm trying to deploy an artifact on AWS CodeArtifact using CodeBuild. I was able to do the same with other artifacts in the same repository, but on this one I have the following error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy)
  on project common-api: Failed to deploy artifacts:
  Could not find artifact it.friendshome.api:common-api:jar:0.0.16 in friendshome-private-maven-repo
  (https://friendshome-243132787362.d.codeartifact.eu-south-1.amazonaws.com/maven/private-maven-repo/)

This is the pom.xml file:

<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>2.5.2</version>
    
    <relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>it.friendshome.api</groupId>
<artifactId>common-api</artifactId>
<version>0.0.16</version>
<name>common-api</name>
<description>FriendsHome User Common API</description>
<properties>
    <java.version>11</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.zalando</groupId>
        <artifactId>logbook-spring-boot-starter</artifactId>
        <version>2.9.0</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
    <dependency>
        <groupId>com.auth0</groupId>
        <artifactId>java-jwt</artifactId>
        <version>3.16.0</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
    </dependency>

    <dependency>
        <groupId>net.logstash.logback</groupId>
        <artifactId>logstash-logback-encoder</artifactId>
        <version>6.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${java.version}</source> <!-- depending on your project -->
                <target>${java.version}</target> <!-- depending on your project -->
            </configuration>
        </plugin>
    </plugins>
</build>

<distributionManagement>
    <repository>
        <id>friendshome-private-maven-repo</id>
        <name>friendshome-private-maven-repo</name>
        <url>https://friendshome-243132787362.d.codeartifact.eu-south-1.amazonaws.com/maven/private-maven-repo/</url>
    </repository>
</distributionManagement>

This is the custom settings.xml used:

<settings>
  <servers>
    <server>
      <id>friendshome-private-maven-repo</id>
      <username>aws</username>
      <password>${env.CODEARTIFACT_TOKEN}</password>
    </server>
  </servers>
</settings>

I cannot understand why, in the deploy phase, Maven is not able to find the package I was deploying in that moment in the repo (and why it is looking for it).


Solution

  • I managed this problem creating a new repo on CodeArtifact. I suppose that something was wrong in the repo I was managing, but I didn't changed any configuration.