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

Maven issues after publishing pom files with the predefined variables #17

Open
sandeepanikapati opened this issue May 9, 2021 · 4 comments
Labels
feature request New feature or request

Comments

@sandeepanikapati
Copy link

Describe the bug
Maven install/deploy fails when we publish POM files with the predefined variables like {revision} instead of actual values to the Artifactory using the Artifactory Maven plugin.

To Reproduce

  1. Clone a sample multi module project and update the artifacts to predefined variables (like {revision} and {sha1}) instead of actual value in the pom.xml file as shown here.

  2. Added the extension(https://github.com/jcgay/unique-revision-maven-filtering) which replaces the ${revision} and {sha1} version in POM to actual value to the pom.xml file in target folder when installing / deploying the artifacts.

  3. Deploy the project to the Artifactory.
    Sample command used : mvn clean deploy -Drevision=2.0.0-SNAPSHOT -Dsha1=123 -Dbuildnumber=1

Parent pom.xml
<artifactId>multi</artifactId>
<version>${revision}-${sha1}</version>
<packaging>pom</packaging>

Child pom.xml:

<parent>
<groupId>org.jfrog.test</groupId>
<artifactId>multi</artifactId>
<version>${revision}-${sha1}</version>
</parent>
<artifactId>multi1</artifactId>
<packaging>jar</packaging>
<name>Multi 1</name>

  1. Now, clone a new maven project and add the “multi1” project (above project) as a dependency to it.

As shown below:
<dependency>
<groupId>org.jfrog.test</groupId>
<artifactId>multi1</artifactId>
<version>${revision}-${sha1}</version>
</dependency>

  1. run the maven clean install command and it results in the below error.
    Sample command used : mvn clean install -Drevision=2.0.0-SNAPSHOT -Dbuildnumber=1 -Dsha1=123

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.650 s
[INFO] Finished at: 2021-04-17T20:40:07+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project maven-example: Could not resolve dependencies for project org.jfrog.example:maven-example:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.jfrog.test:multi1:jar:2.0.0-SNAPSHOT-123: Failed to read artifact descriptor for org.jfrog.test:multi1:jar:2.0.0-SNAPSHOT-123: Could not find artifact org.jfrog.test:multi:pom:${revision}-${sha1} in central (http://localhost:8081/artifactory/san-libs-release) -> [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 full debug logging.
[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/DependencyResolutionException

Expected behavior
Maven should resolve the dependency artifacts successfully as the given version is existing in the repository.

Screenshots
Attached

Versions

  • Artifactory Maven plugin version: 3.2.1
  • Artifactory version: 7.15.2
  • Maven version: apache-maven-3.6.3

Additional context

Pom files in the target folders are created with actual values (i.e, 2.0.0-SNAPSHOT-123). Please find the below pom file snippet of the version which got created in the target folder for the multi1 project.

<parent>
<groupId>org.jfrog.test</groupId>
<artifactId>multi</artifactId>
<version>2.0.0-SNAPSHOT-123</version>
</parent>

However, the pom file from the source folder with predefined value got deployed to the Artifactory (Please refer to the attached screenshot) instead of the pom file from the target folder.
pomfile_sample

@sandeepanikapati sandeepanikapati added the bug Something isn't working label May 9, 2021
@yahavi
Copy link
Member

yahavi commented May 13, 2021

@sandeepani2206
Thanks for reporting this issue.
Supporting the unique-revision-maven-filtering extension is not a bug, but a feature request.

In the Maven Artifactory plugin we override the deploy goal. Ultimately, all artifacts are uploaded to Artifactory using our ModuleParallelDeploy. We use this method for many reasons. Some of them are:

  • Collecting the build-info
  • Avoiding writing temp files in the file system
  • Checksum deployment
  • Parallel deployment
  • Producer-consumer design pattern
  • Exclude artifacts from uploading
  • More...

I looked at the unique-revision-maven-filtering and it looks like it overrides the MetadataGeneratorFactory which we don't use in the Artifactory Maven plugin.
However, it does generate the required pom under /target directory. Therefore I believe we can support this feature in the future.

@yahavi yahavi added feature request New feature or request and removed bug Something isn't working labels May 13, 2021
@colferai
Copy link

colferai commented Feb 7, 2022

We're having the same problem. Any expectations for the fix?

Thanks!

@TobiX
Copy link

TobiX commented Aug 18, 2022

The same seems to happen when using the flatten-maven-plugin as described in https://maven.apache.org/maven-ci-friendly.html

@TobiX
Copy link

TobiX commented Jan 31, 2023

This might have been fixed in release 3.5.1 - I'm not seeing the issue anymore (with flatten-maven-plugin).

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

No branches or pull requests

4 participants