This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch maven-atr-plugin
in repository https://gitbox.apache.org/repos/asf/maven-studies.git


The following commit(s) were added to refs/heads/maven-atr-plugin by this push:
     new d4bb75fb9 reuse ATR client when uploading multiple files
d4bb75fb9 is described below

commit d4bb75fb98d66e0901b4aff9afd41b388098fda6
Author: HervĂ© Boutemy <[email protected]>
AuthorDate: Tue Mar 24 22:14:13 2026 +0100

    reuse ATR client when uploading multiple files
---
 src/main/java/org/apache/maven/plugins/atr/AtrClient.java  |  2 +-
 src/main/java/org/apache/maven/plugins/atr/UploadMojo.java | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/atr/AtrClient.java 
b/src/main/java/org/apache/maven/plugins/atr/AtrClient.java
index 31d4bc745..619ea365c 100644
--- a/src/main/java/org/apache/maven/plugins/atr/AtrClient.java
+++ b/src/main/java/org/apache/maven/plugins/atr/AtrClient.java
@@ -66,7 +66,7 @@ public class AtrClient {
      *
      * @throws MojoExecutionException if JWT creation fails
      */
-    private void ensureJwt() throws MojoExecutionException {
+    void ensureJwt() throws MojoExecutionException {
         if (jwt != null) {
             return;
         }
diff --git a/src/main/java/org/apache/maven/plugins/atr/UploadMojo.java 
b/src/main/java/org/apache/maven/plugins/atr/UploadMojo.java
index 0b81f239b..3d29fa262 100644
--- a/src/main/java/org/apache/maven/plugins/atr/UploadMojo.java
+++ b/src/main/java/org/apache/maven/plugins/atr/UploadMojo.java
@@ -68,19 +68,26 @@ public class UploadMojo extends AbstractAtrMojo {
         getLog().info("Composing release " + url + "compose/" + project + "/" 
+ version);
         getLog().info("Files: " + files.length);
 
+        AtrClient client = null;
+        if (!dryRun) {
+            client = new AtrClient(url, getServer(), getLog());
+            client.ensureJwt();
+        }
+
         for (Path file : files) {
-            upload(file);
+            upload(client, file);
         }
     }
 
     /**
      * Upload a single file to ATR.
      *
+     * @param client the ATR client to use for upload
      * @param file the file to upload
      * @throws MojoExecutionException if an error occurs during upload
      * @throws MojoFailureException if the upload fails
      */
-    private void upload(Path file) throws MojoExecutionException, 
MojoFailureException {
+    private void upload(AtrClient client, Path file) throws 
MojoExecutionException, MojoFailureException {
         if (dryRun) {
             getLog().info("DRY RUN: Would upload: " + file.getFileName() + " 
to " + getAtrFileUrl(file));
             return;
@@ -93,7 +100,6 @@ public class UploadMojo extends AbstractAtrMojo {
                 (directory != null ? directory + "/" : "") + 
file.getFileName().toString();
 
         // Upload using ATR client
-        AtrClient client = new AtrClient(url, getServer(), getLog());
         String revisionNumber = client.uploadFile(project, version, target, 
file);
 
         getLog().info("Upload successful. Revision: " + revisionNumber);

Reply via email to