Fix an issue with some jar files
π΄ Context
In !11 (merged), we implemented and merge support for maven packages.
To publish packages, we used the deploy-file
command.
We hit an issue where the command can complain about missing information on the package to be published:
$ mvn deploy:deploy-file -Durl=https://gitlab.com/api/v4/projects/45821687/packages/maven -DrepositoryId=pkgs_importer_destination -Dfile=$(ls *.jar | head -n 1) -s settings.xml
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- deploy:3.0.0:deploy-file (default-cli) @ standalone-pom ---
[INFO] pom.xml not found in spring-web-6.0.9.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.096 s
[INFO] Finished at: 2023-05-22T16:36:54+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0:deploy-file (default-cli) on project standalone-pom: The artifact information is incomplete: 'groupId', 'artifactId', 'version' and 'packaging' are required. -> [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/MojoExecutionException
To fix, this we can add an additional parameter to the command, the pomFile
location. This file is the metadata file about the package and will provide the information that the command needs.
Related issue: #26 (closed)
π€ What does this MR do?
- Update the publish script for Maven packages to support the
pomFile
option - Update the related test.
β How to test this locally
With the following config.yml
file:
config.yml
from_maven_central:
type: maven
source:
url: https://repo1.maven.org/maven2
destination: &maven_destination
url: https://gitlab.com/api/v4/projects/<project_id>/packages/maven
credentials:
token: $GITLAB_TOKEN
header_name: Private-Token
packages:
"org.springframework:spring-web": 6.0.9
- Generate the pipeline config file:
$ go run main.go generate -c <config file path>
- Take the
child_pipeline.yml
file contents and paste into the<project_id>
repository in a.gitlab-ci.yml
file. - Check the pipeline.
main
Using The pomFile
option is not used and the upload operation fails
Using this MR branch
The pomFile
option is used for the upload and it succeeds
Edited by David Fernandez