kordamp / pomchecker

🦉 Maven POM syntax checker
Apache License 2.0
65 stars 11 forks source link

Pomchecker CLI does not resolve artifacts from Maven Central #22

Closed gastaldi closed 2 months ago

gastaldi commented 2 months ago

Having a pom.xml like the following:

<?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>io.quarkiverse</groupId>
        <artifactId>quarkiverse-parent</artifactId>
        <version>17</version>
    </parent>
    <groupId>io.quarkiverse.slack</groupId>
    <artifactId>quarkus-slack-parent</artifactId>
    <version>0.0.2</version>
    <packaging>pom</packaging>
</project>

First run rm -rf ~/.m2/repository/io/quarkiverse to make sure your local repository does not have the parent artifact.

When I run pomchecker check-maven-central --file pom.xml the following error is shown:

[INFO] Maven Central checks: /private/tmp/jreleaser/repository/pom.xml
org.apache.maven.project.ProjectBuildingException: 1 problem was encountered while building the effective model for io.quarkiverse.slack:quarkus-slack-parent:0.0.2
[FATAL] Non-resolvable parent POM for io.quarkiverse.slack:quarkus-slack-parent:0.0.2: The following artifacts could not be resolved: io.quarkiverse:quarkiverse-parent:pom:17 (absent): Could not find artifact io.quarkiverse:quarkiverse-parent:pom:17 and 'parent.relativePath' points at wrong local POM @ line 5, column 13
 for project io.quarkiverse.slack:quarkus-slack-parent:0.0.2 at /private/tmp/jreleaser/repository/pom.xml
java.lang.IllegalStateException: org.apache.maven.project.ProjectBuildingException: 1 problem was encountered while building the effective model for io.quarkiverse.slack:quarkus-slack-parent:0.0.2
[FATAL] Non-resolvable parent POM for io.quarkiverse.slack:quarkus-slack-parent:0.0.2: The following artifacts could not be resolved: io.quarkiverse:quarkiverse-parent:pom:17 (absent): Could not find artifact io.quarkiverse:quarkiverse-parent:pom:17 and 'parent.relativePath' points at wrong local POM @ line 5, column 13
 for project io.quarkiverse.slack:quarkus-slack-parent:0.0.2 at /private/tmp/jreleaser/repository/pom.xml
    at org.kordamp.maven.checker.cli.internal.PomParser.createMavenProject(PomParser.java:102)
    at org.kordamp.maven.checker.cli.internal.PomParser.createMavenProject(PomParser.java:66)
    at org.kordamp.maven.checker.cli.CheckMavenCentral.execute(CheckMavenCentral.java:61)
    at org.kordamp.maven.checker.cli.AbstractCommand.call(AbstractCommand.java:102)
    at org.kordamp.maven.checker.cli.CheckMavenCentral.call(CheckMavenCentral.java:30)
    at org.kordamp.maven.checker.cli.AbstractCommand.call(AbstractCommand.java:34)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
    at picocli.CommandLine.execute(CommandLine.java:2170)
    at org.kordamp.maven.checker.cli.Main.execute(Main.java:86)
    at org.kordamp.maven.checker.cli.Main.run(Main.java:72)
    at org.kordamp.maven.checker.cli.Main.main(Main.java:64)
Caused by: org.apache.maven.project.ProjectBuildingException: 1 problem was encountered while building the effective model for io.quarkiverse.slack:quarkus-slack-parent:0.0.2
[FATAL] Non-resolvable parent POM for io.quarkiverse.slack:quarkus-slack-parent:0.0.2: The following artifacts could not be resolved: io.quarkiverse:quarkiverse-parent:pom:17 (absent): Could not find artifact io.quarkiverse:quarkiverse-parent:pom:17 and 'parent.relativePath' points at wrong local POM @ line 5, column 13
 for project io.quarkiverse.slack:quarkus-slack-parent:0.0.2 at /private/tmp/jreleaser/repository/pom.xml
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:180)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:123)
    at org.kordamp.maven.checker.cli.internal.PomParser.createMavenProject(PomParser.java:99)
    ... 16 more
Caused by: org.apache.maven.model.building.ModelBuildingException: 1 problem was encountered while building the effective model for io.quarkiverse.slack:quarkus-slack-parent:0.0.2
[FATAL] Non-resolvable parent POM for io.quarkiverse.slack:quarkus-slack-parent:0.0.2: The following artifacts could not be resolved: io.quarkiverse:quarkiverse-parent:pom:17 (absent): Could not find artifact io.quarkiverse:quarkiverse-parent:pom:17 and 'parent.relativePath' points at wrong local POM @ line 5, column 13

    at org.apache.maven.model.building.DefaultModelProblemCollector.newModelBuildingException(DefaultModelProblemCollector.java:176)
    at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:1033)
    at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:801)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:327)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:243)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:176)
    ... 18 more
gastaldi commented 2 months ago

Apparently a call is missing to projectBuildingRequest.setRemoteRepositories(...) here: https://github.com/kordamp/pomchecker/blob/96676f91490184b87ff7625e452ae89a01e4f02c/pomchecker-cli/src/main/java/org/kordamp/maven/checker/cli/internal/PomParser.java#L85

aalmiray commented 2 months ago

🎉 This issue has been resolved in v1.12.0 (Release Notes)