jfrog / artifactory-maven-plugin

A Maven plugin to resolve artifacts from Artifactory, deploy artifacts to Artifactory, capture and publish build info.
https://www.jfrog.com/confluence/display/JFROG/Maven+Artifactory+Plugin
Apache License 2.0
24 stars 26 forks source link

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

Open sandeepanikapati opened 3 years ago

sandeepanikapati commented 3 years ago

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>

4) 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>

5) 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

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
yahavi commented 3 years ago

@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:

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.

colferai commented 2 years ago

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

Thanks!

TobiX commented 2 years ago

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

TobiX commented 1 year ago

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