Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.4.0 chokes on BOM import #348

Closed
famod opened this issue Mar 20, 2023 · 14 comments · Fixed by #350
Closed

1.4.0 chokes on BOM import #348

famod opened this issue Mar 20, 2023 · 14 comments · Fixed by #350
Labels

Comments

@famod
Copy link
Contributor

famod commented Mar 20, 2023

When trying to update from 1.3.0 to 1.4.0, I'm seeing the following errors (obfuscated, project is closed source):
Jenkins (mirror in settings):

[ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.4.0:flatten (flatten) on project register-parent: 1 problem was encountered while building the effective model for someproject:register-parent:4.2.0.latest
[ERROR] [ERROR] Non-resolvable import POM: Could not find artifact someproject:ext-api-bom:pom:0.5.0.95 in mirror (https://artifacts.somecompany.de/artifactory/common-dev-release/) @ 
[ERROR] 
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.4.0:flatten (flatten) on project register-parent: 1 problem was encountered while building the effective model for someproject:register-parent:4.2.0.latest
[ERROR] Non-resolvable import POM: Could not find artifact someproject:ext-api-bom:pom:0.5.0.95 in mirror (https://artifacts.somecompany.de/artifactory/common-dev-release/) 
[...]
    at org.apache.maven.model.building.DefaultModelProblemCollector.newModelBuildingException (DefaultModelProblemCollector.java:197)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:568)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:454)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:267)
    at org.codehaus.mojo.flatten.ModelBuilderThreadSafetyWorkaround.build (ModelBuilderThreadSafetyWorkaround.java:132)
    at org.codehaus.mojo.flatten.FlattenMojo.createEffectivePom (FlattenMojo.java:880)
    at org.codehaus.mojo.flatten.FlattenMojo.createFlattenedPom (FlattenMojo.java:541)
    at org.codehaus.mojo.flatten.FlattenMojo.execute (FlattenMojo.java:406)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
[...]

Local (no mirror in settings):

[ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.4.0:flatten (flatten) on project register-parent: 1 problem was encountered while building the effective model for someproject:register-parent:4.2.0.local-dev3
[ERROR] [ERROR] Non-resolvable import POM: Could not find artifact someproject:ext-api-bom:pom:0.5.0.95 in central (https://repo.maven.apache.org/maven2) @ 
[ERROR] 
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.4.0:flatten (flatten) on project register-parent: 1 problem was encountered while building the effective model for someproject:register-parent:4.2.0.local-dev3
[ERROR] Non-resolvable import POM: Could not find artifact someproject:ext-api-bom:pom:0.5.0.95 in central (https://repo.maven.apache.org/maven2) @ 
<same stacktrace>

So something is wrong with the repo selection while resolving a BOM artifact.

  • repositories and pluginRepositories defined in pom.xml, pointing to corporate artifactory (credentials in settings.xml)
  • Maven 3.8.7
  • resolveCiFriendliesOnly
@pzygielo
Copy link
Contributor

pzygielo commented Mar 20, 2023

I'm seeing similar.

@slawekjaranowski
Copy link
Member

Can you provide a simple project which reproduce it?

@slawekjaranowski
Copy link
Member

I'm seeing similar.

This change was really needed - yes it can introduce some of bugs which was not covered by IT.
So now we can improve it.

@famod
Copy link
Contributor Author

famod commented Mar 20, 2023

Can you provide a simple project which reproduce it?

I suppose you need a repo manager (e.g. nexus) and an artifact that only exists in that repo.
Unfortunatly I don't have time for that currently, sorry.

@cstamas
Copy link
Contributor

cstamas commented Mar 23, 2023

I believe this is the problem right here: https://github.com/mojohaus/flatten-maven-plugin/pull/336/files#diff-9f8ec1d13bc75e576b6c21b96d277373eb856d5465ef87ef675a983b3ade36beR1154

@slawekjaranowski
Copy link
Member

Looks as is simple to fix, but reproduce project will be appreciated to have regression.

@famod
Copy link
Contributor Author

famod commented Mar 23, 2023

I won't be able to provide a reproducer anytime soon, sorry.
I'd gladly test a snapshot though (or build the plugin myself from a fix branch).

@zuisong
Copy link

zuisong commented Mar 24, 2023

Same problem to me

@zuisong
Copy link

zuisong commented Mar 24, 2023

Looks as is simple to fix, but reproduce project will be appreciated to have regression.

@slawekjaranowski
You can create a empty maven project, and pom.xml content. then run mvn compile

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.github.zuisong</groupId>
  <artifactId>flatten-maven-plugin-issue348</artifactId>
  <version>0.0.1</version>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.github.vert-x3.vertx-stack</groupId>
        <artifactId>vertx-stack-depchain</artifactId>
        <version>4.4.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <repositories>
    <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </repository>
  </repositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <!-- it works on version 1.3.0  -->
        <version>1.4.0</version>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
          <execution>
            <id>flatten.clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

@zuisong
Copy link

zuisong commented Mar 24, 2023

@slawekjaranowski
Copy link
Member

slawekjaranowski commented Mar 25, 2023

@zuisong - thanks for example

I have created a fix - you can build locally plugin from branch fix-348 for your testing purpose

I don't know how artifacts in jitpack are managed - so I don't add example as IT.
I don't want to have failed test if something change in jitpack in the future.

@zuisong
Copy link

zuisong commented Mar 27, 2023

It works now. ❤️

Could we use Spring Milestone Repository to add IT?

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.github.zuisong</groupId>
  <artifactId>flatten-maven-plugin-issue348</artifactId>
  <version>0.0.1</version>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>3.0.0-M5</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <repositories>
    <repository>
      <id>repository.spring.milestone</id>
      <name>Spring Milestone Repository</name>
      <url>http://repo.spring.io/milestone</url>
    </repository>
  </repositories>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <!-- <version>1.4.1-SNAPSHOT</version> -->
        <version>1.4.0</version>
        <!-- <version>1.3.0</version> -->
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
          <execution>
            <id>flatten.clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

@slawekjaranowski
Copy link
Member

Ok, test added, build pass.
I will merge fix and release next version.

@famod
Copy link
Contributor Author

famod commented Mar 27, 2023

Thanks all!
It didn't occur to me that the BOM in question doesn't need to be internal, so thanks @zuisong for pointing that out by providing a very simple reproducer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants