nexus-public icon indicating copy to clipboard operation
nexus-public copied to clipboard

Maven 2 related properties not possible to set via API when creating Maven group repository

Open haxorof opened this issue 8 months ago • 2 comments

Problem

If you create a Maven group repository via the GUI you must select "Maven 2" related properties related to "Version policy", "Layout policy" and "Content Disposition". All works well to set these here in the GUI and then when looking into tasks like "Maven - Delete SNAPSHOT" only repositories with version policy "Mixed" or "Snapshot" is listed in the "Repositories" list when creating that task.

However, when trying to do the same via API and create Maven group repository with these Maven 2 properties it is not possible. The API model for that POST request does not support such options. It seems then to be stored with kind of default values and then having version policy "Release" but also at the same time the database does not seem to be updated correctly. This because it updates something more when you update and save it via GUI, can be seen when looking at what is listed in repositories in task "Maven - Delete SNAPSHOT" before and after update.

Steps To Reproduce

  1. Start Nexus instance using official container
  2. Login as admin with admin123 and go to http://localhost:8081/#admin/system/api
  3. Go to POST for /v1/repositories/maven/group
  4. Click "Try it out" and past the following JSON below and click "Execute"
    {
    
      "name": "maven-public-test",
      "online": true,
      "storage": {
        "blobStoreName": "default",
        "strictContentTypeValidation": false
      },
      "group": {
        "memberNames": [
          "maven-releases",
          "maven-snapshots",
          "maven-central"
        ]
      }
    }
    
  5. Repository is successfully created and go to http://localhost:8081/#admin/repository/repositories:maven-public-test
  6. You will see it is having "Version policy" set to "Release".
  7. Go to http://localhost:8081/#admin/system/tasks and click "Create task" and select "Maven - Delete SNAPSHOT".
  8. In the "Repository" list you will now see "maven-public-test" even if it is showing to be having version policy "Release".
  9. Go back to http://localhost:8081/#admin/repository/repositories:maven-public-test and remove "maven-central" from members and click "Save".
  10. Now if you repeat step 7 you will no longer see "maven-public-test" under "Repositories".

haxorof avatar Aug 18 '25 11:08 haxorof

Group repositories don't store content aside from merged metadata and internally route requests to members. If you do not wish a group to support snapshots don't add snapshot repositories to the group.

mpiggott avatar Aug 21 '25 16:08 mpiggott

My point is more that you cannot create a Maven group repo with mixed or snapshot version policy via API as you can do via GUI. The consequence of this is that in the task (as mentioned earlier) it is not possible to select that group repo only. Instead you are then forced to create tasks for each member of that group repo.

I mentioned maven-public here just because it was easier to show the difference between API and GUI and the consequence of that.

When you automate and do not want to do things manually then it is a problem.

Cheers!

haxorof avatar Aug 21 '25 20:08 haxorof