这是indexloc提供的服务,不要输入任何密码
Skip to content

Maven 4: Error resolving artifacts in flatten-maven-plugin #495

@norrisjeremy

Description

@norrisjeremy

The following example pom.xml produces an an error in Maven 4 with the flatten-maven-plugin, but not in Maven 3:

<?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>
  <groupId>foo</groupId>
  <artifactId>bar</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.7.3</version>
        <configuration>
          <flattenDependencyMode>all</flattenDependencyMode>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.20.1</version>
    </dependency>
  </dependencies>
</project>

Maven 4.0.0-rc-5:

$ mvn flatten:flatten
[INFO] Scanning for projects...
[INFO] Loaded 21643 auto-discovered prefixes for remote repository central (prefixes-central.txt)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 36.9 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (21 kB at 53.2 kB/s)
[INFO] 
[INFO] -------------------------------------------------------< foo:bar >--------------------------------------------------------
[INFO] Building bar 1.0.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] ---------------------------------------------------------[ jar ]----------------------------------------------------------
[INFO] 
[INFO] --- flatten:1.7.3:flatten (default-cli) @ bar ---
[INFO] Generating flattened POM of project foo:bar:jar:1.0.0-SNAPSHOT...
[INFO] Artifact com.fasterxml.jackson:jackson-base:pom:2.20.1 is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from [central-snapshots (https://central.sonatype.com/repository/maven-snapshots, default, snapshots)]
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] Total time:  0.756 s
[INFO] Finished at: 2025-11-13T12:57:22-06:00
[INFO] --------------------------------------------------------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.7.3:flatten (default-cli) on project bar: failed to create a clean pom: unable to create flattened dependencies: caught exception when flattening dependencies: Failed to read artifact descriptor for com.fasterxml.jackson.core:jackson-databind::2.20.1: The following artifacts could not be resolved: com.fasterxml.jackson:jackson-base:pom:2.20.1 (present, but unavailable) (remote repositories: central-snapshots (https://central.sonatype.com/repository/maven-snapshots, default, snapshots)): One or more requests failed -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the '-e' switch
[ERROR] Re-run Maven using the '-X' switch to enable verbose output
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Maven 3.9.11:

$ mvn flatten:flatten 
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (file:/Users/ishmael/.sdkman/candidates/maven/current/lib/guice-5.1.0-classes.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner
WARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------< foo:bar >-------------------------------
[INFO] Building bar 1.0.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- flatten:1.7.3:flatten (default-cli) @ bar ---
[INFO] Generating flattened POM of project foo:bar:jar:1.0.0-SNAPSHOT...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.132 s
[INFO] Finished at: 2025-11-13T12:58:56-06:00
[INFO] ------------------------------------------------------------------------

As per discussions in apache/maven#11436, this appears to be due to an issue in flatten-maven-plugin (see apache/maven#11436 (comment)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions