diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/services/packages/maven/find_or_create_package_service.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/services/packages/maven/find_or_create_package_service.rb')
-rw-r--r-- | app/services/packages/maven/find_or_create_package_service.rb | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/app/services/packages/maven/find_or_create_package_service.rb b/app/services/packages/maven/find_or_create_package_service.rb index 50a008843ad..505f45a7b21 100644 --- a/app/services/packages/maven/find_or_create_package_service.rb +++ b/app/services/packages/maven/find_or_create_package_service.rb @@ -3,21 +3,33 @@ module Packages module Maven class FindOrCreatePackageService < BaseService MAVEN_METADATA_FILE = 'maven-metadata.xml'.freeze + SNAPSHOT_TERM = '-SNAPSHOT'.freeze def execute - package = ::Packages::Maven::PackageFinder - .new(params[:path], current_user, project: project).execute + package = + ::Packages::Maven::PackageFinder.new(params[:path], current_user, project: project) + .execute unless package - if params[:file_name] == MAVEN_METADATA_FILE - # Maven uploads several files during `mvn deploy` in next order: - # - my-company/my-app/1.0-SNAPSHOT/my-app.jar - # - my-company/my-app/1.0-SNAPSHOT/my-app.pom - # - my-company/my-app/1.0-SNAPSHOT/maven-metadata.xml - # - my-company/my-app/maven-metadata.xml - # - # The last xml file does not have VERSION in URL because it contains - # information about all versions. + # Maven uploads several files during `mvn deploy` in next order: + # - my-company/my-app/1.0-SNAPSHOT/my-app.jar + # - my-company/my-app/1.0-SNAPSHOT/my-app.pom + # - my-company/my-app/1.0-SNAPSHOT/maven-metadata.xml + # - my-company/my-app/maven-metadata.xml + # + # The last xml file does not have VERSION in URL because it contains + # information about all versions. When uploading such file, we create + # a package with a version set to `nil`. The xml file with a version + # is only created and uploaded for snapshot versions. + # + # Gradle has a different upload order: + # - my-company/my-app/1.0-SNAPSHOT/maven-metadata.xml + # - my-company/my-app/1.0-SNAPSHOT/my-app.jar + # - my-company/my-app/1.0-SNAPSHOT/my-app.pom + # - my-company/my-app/maven-metadata.xml + # + # The first upload has to create the proper package (the one with the version set). + if params[:file_name] == MAVEN_METADATA_FILE && !params[:path]&.ends_with?(SNAPSHOT_TERM) package_name, version = params[:path], nil else package_name, _, version = params[:path].rpartition('/') @@ -30,8 +42,9 @@ module Packages build: params[:build] } - package = ::Packages::Maven::CreatePackageService - .new(project, current_user, package_params).execute + package = + ::Packages::Maven::CreatePackageService.new(project, current_user, package_params) + .execute end package |