You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/08/31 11:57:13 UTC
(maven-deploy-plugin) 07/07: fix: adapt deployAtEnd re-deploy test for cache optimization compatibility
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch security/audit-medium-fixes
in repository https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git
commit 6812306ef6b08deff6d3a236eee5a40f00913523
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Aug 31 13:56:49 2026 +0200
fix: adapt deployAtEnd re-deploy test for cache optimization compatibility
The deployAtEndBatchIsNotRedeployedOnReentry test needs a properly mocked
MojoExecution with plugin model, because the upstream cache optimization
(PROJECTS_WITH_DEPLOY_KEY) calls mojoExecution.getPlugin().getModel().getKey()
in hasDeployExecution().
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../org/apache/maven/plugins/deploy/DeployMojoTest.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
index 4709b08..8f3aeae 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -433,10 +433,26 @@ class DeployMojoTest {
@Test
@InjectMojo(goal = "deploy")
void deployAtEndBatchIsNotRedeployedOnReentry(DeployMojo mojo) throws Exception {
+ // Set up mojoExecution with a proper plugin model so hasDeployExecution() can look up
+ // the deploy plugin key. This is needed because the cache optimization (PROJECTS_WITH_DEPLOY_KEY)
+ // calls mojoExecution.getPlugin().getModel().getKey() to find the current plugin in each project's
+ // build plugins map.
+ org.apache.maven.api.model.Plugin pluginModel = org.apache.maven.api.model.Plugin.newBuilder()
+ .groupId("org.apache.maven.plugins")
+ .artifactId("maven-deploy-plugin")
+ .build();
+ org.apache.maven.api.Plugin mojoPlugin = org.mockito.Mockito.mock(org.apache.maven.api.Plugin.class);
+ org.apache.maven.api.MojoExecution mojoExec =
+ org.mockito.Mockito.mock(org.apache.maven.api.MojoExecution.class);
+ org.mockito.Mockito.doReturn(mojoPlugin).when(mojoExec).getPlugin();
+ org.mockito.Mockito.doReturn(pluginModel).when(mojoPlugin).getModel();
+ setVariableValueToObject(mojo, "mojoExecution", mojoExec);
+
Project project = (Project) getVariableValueFromObject(mojo, "project");
artifactManager.setPath(
project.getMainArtifact().get(),
Paths.get(getBasedir(), "target/test-classes/unit/maven-deploy-test-1.0-SNAPSHOT.jar"));
+
// give the session a persistent plugin context and a real reactor project list
Map<Project, Map<String, Object>> contexts = new HashMap<>();
when(session.getPluginContext(any(Project.class)))