gnodet-bot commented on code in PR #13166:
URL: https://github.com/apache/maven/pull/13166#discussion_r4041406542


##########
.github/workflows/update-lifecycle-plugins.yml:
##########
@@ -0,0 +1,93 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Update lifecycle plugin versions
+
+on:
+  schedule:
+    # Every Monday at 08:00 UTC
+    - cron: '0 8 * * 1'
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+jobs:
+  update-lifecycle-plugins:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pull-requests: write
+    strategy:
+      fail-fast: false
+      matrix:
+        branch: [master, maven-4.0.x]
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 
v7.0.1
+        with:
+          ref: ${{ matrix.branch }}
+          persist-credentials: false
+
+      - uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # 
v6.0.1
+        with:
+          java-version: '21'
+          distribution: 'temurin'
+          cache: maven
+
+      - name: Update lifecycle plugin versions
+        run: |
+          mvn -B eu.maveniverse.maven.plugins:toolbox:0.16.0:plugin-versions \
+            -Pversions-update \
+            -DartifactVersionMatcherSpec="not(any(snapshotOrPreview()))" \
+            -Dapply
+
+      - name: Create Pull Request
+        env:
+          GH_TOKEN: ${{ secrets.GH_TOKEN }}
+          BRANCH: update/lifecycle-plugins-${{ matrix.branch }}
+          BASE_BRANCH: ${{ matrix.branch }}
+        run: |
+          if git diff --quiet impl/maven-core/pom.xml; then
+            echo "No lifecycle plugin version changes detected."
+            exit 0
+          fi
+
+          echo "--- Updated properties ---"
+          git diff impl/maven-core/pom.xml | grep '^[+-].*version\.maven' | 
grep -v '^---\|^+++'
+
+          git config user.name "github-actions[bot]"
+          git config user.email 
"41898282+github-actions[bot]@users.noreply.github.com"
+          git switch --create "${BRANCH}"
+          git add impl/maven-core/pom.xml
+          git commit -m "chore: update Maven lifecycle plugin versions"
+          git remote set-url origin 
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git";
+          git push --force-with-lease --set-upstream origin "${BRANCH}"

Review Comment:
   ⚠️ **[NOT ADDRESSED] `--force-with-lease` without a remote tracking ref 
behaves like `--force` here.** `actions/checkout` checks out `${{ matrix.branch 
}}` only — it does not fetch `update/lifecycle-plugins-*`. `git switch 
--create` creates a local branch with no upstream tracking ref. Without a 
remote-tracking ref to lease against, Git falls back to an unconditional force 
push. The safety guarantee of `--force-with-lease` (abort if someone else 
pushed in the meantime) is lost.
   
   For a bot-owned throwaway branch, either:
   1. Use `--force` explicitly (documents the intent):
      ```suggestion
             git push --force --set-upstream origin "${BRANCH}"
      ```
   2. Or fetch first so the lease has something to verify against:
      ```
      git fetch origin "${BRANCH}" 2>/dev/null || true
      git push --force-with-lease --set-upstream origin "${BRANCH}"
      ```



##########
.github/workflows/update-lifecycle-plugins.yml:
##########
@@ -0,0 +1,93 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Update lifecycle plugin versions
+
+on:
+  schedule:
+    # Every Monday at 08:00 UTC
+    - cron: '0 8 * * 1'
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+jobs:
+  update-lifecycle-plugins:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pull-requests: write
+    strategy:
+      fail-fast: false
+      matrix:
+        branch: [master, maven-4.0.x]
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 
v7.0.1
+        with:
+          ref: ${{ matrix.branch }}
+          persist-credentials: false
+
+      - uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # 
v6.0.1
+        with:
+          java-version: '21'
+          distribution: 'temurin'
+          cache: maven
+
+      - name: Update lifecycle plugin versions
+        run: |
+          mvn -B eu.maveniverse.maven.plugins:toolbox:0.16.0:plugin-versions \
+            -Pversions-update \
+            -DartifactVersionMatcherSpec="not(any(snapshotOrPreview()))" \
+            -Dapply
+
+      - name: Create Pull Request
+        env:
+          GH_TOKEN: ${{ secrets.GH_TOKEN }}
+          BRANCH: update/lifecycle-plugins-${{ matrix.branch }}
+          BASE_BRANCH: ${{ matrix.branch }}
+        run: |
+          if git diff --quiet impl/maven-core/pom.xml; then
+            echo "No lifecycle plugin version changes detected."
+            exit 0
+          fi
+
+          echo "--- Updated properties ---"
+          git diff impl/maven-core/pom.xml | grep '^[+-].*version\.maven' | 
grep -v '^---\|^+++'
+
+          git config user.name "github-actions[bot]"
+          git config user.email 
"41898282+github-actions[bot]@users.noreply.github.com"
+          git switch --create "${BRANCH}"
+          git add impl/maven-core/pom.xml
+          git commit -m "chore: update Maven lifecycle plugin versions"
+          git remote set-url origin 
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git";
+          git push --force-with-lease --set-upstream origin "${BRANCH}"
+
+          if gh pr list \
+              --repo "${GITHUB_REPOSITORY}" \
+              --state open \
+              --head "${BRANCH}" \
+              --json number \
+              --jq 'length' | grep -q '^0$'; then
+            gh pr create \
+              --repo "${GITHUB_REPOSITORY}" \
+              --base "${BASE_BRANCH}" \
+              --head "${BRANCH}" \
+              --title "chore: update Maven lifecycle plugin versions 
(${BASE_BRANCH})" \
+              --body "Automated update of Maven lifecycle plugin versions via 
\`toolbox:plugin-versions\`. These versions are declared in 
\`impl/maven-core/pom.xml\` and are used by the Maven default lifecycle 
binding. They are filtered at build time into \`plugin-versions.properties\` 
and loaded at runtime by \`PluginVersions\\`. This PR was created automatically 
by the \`update-lifecycle-plugins\` workflow." \

Review Comment:
   🔧 **[NOT ADDRESSED] Spurious backslash before closing backtick renders as 
`PluginVersions\.` in the PR body.** The shell sequence `\\\`` inside 
double-quotes expands to `\`` — a literal backslash followed by a backtick. 
GitHub renders this as `PluginVersions\.` (backslash before the period). The 
trailing `\.` is unintended.
   
   ```suggestion
                 --body "Automated update of Maven lifecycle plugin versions 
via \`toolbox:plugin-versions\`. These versions are declared in 
\`impl/maven-core/pom.xml\` and are used by the Maven default lifecycle 
binding. They are filtered at build time into \`plugin-versions.properties\` 
and loaded at runtime by \`PluginVersions\`. This PR was created automatically 
by the \`update-lifecycle-plugins\` workflow." \
   ```



##########
pom.xml:
##########
@@ -1302,5 +1302,154 @@ under the License.
         </plugins>
       </build>
     </profile>
+    <profile>
+      <!--
+        This profile is NEVER activated during a normal build.
+        It configures versions-maven-plugin to map the version.maven-*-plugin
+        properties (in impl/maven-core/pom.xml) to their corresponding Maven
+        plugin artifacts, enabling:
+
+          mvn versions:update-properties -Pversions-update \
+            -DincludeProperties="version.maven-clean-plugin,..." \
+            -pl impl/maven-core
+
+        The GitHub Actions workflow 
.github/workflows/update-lifecycle-plugins.yml
+        runs this command weekly and opens a PR when updates are found.
+      -->
+      <id>versions-update</id>
+      <build>
+        <plugins>

Review Comment:
   🔧 **Stale comment — describes the old `versions:update-properties` approach, 
not the current `toolbox:plugin-versions` workflow.** The comment still shows:
   ```
   mvn versions:update-properties -Pversions-update \
     -DincludeProperties="version.maven-clean-plugin,..." \
     -pl impl/maven-core
   ```
   but the actual workflow now runs `toolbox:plugin-versions`. The 
`versions-maven-plugin` configuration in this profile is also dead code for the 
automation — toolbox ignores it. The comment should either be updated to 
reflect the actual workflow command, or the `versions-maven-plugin` config 
should be removed if it's no longer used manually either.
   
   For reference, the actual workflow command is:
   ```
   mvn -B eu.maveniverse.maven.plugins:toolbox:0.16.0:plugin-versions \
     -Pversions-update \
     -DartifactVersionMatcherSpec="not(any(snapshotOrPreview()))" \
     -Dapply
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to