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 2024/11/14 08:03:28 UTC
(maven-deploy-plugin) branch master updated: Upgrade to beta 5 (#81)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 1bd60a0 Upgrade to beta 5 (#81)
1bd60a0 is described below
commit 1bd60a0c007f6d32da76b30215ced8e29e434792
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Nov 14 09:03:24 2024 +0100
Upgrade to beta 5 (#81)
---
.github/workflows/maven-verify.yml | 4 +-
pom.xml | 6 +-
.../maven/plugins/deploy/DeployFileMojo.java | 17 +++--
.../apache/maven/plugins/deploy/DeployMojo.java | 7 +-
.../maven/plugins/deploy/DeployFileMojoTest.java | 77 +++++++++++-----------
.../maven/plugins/deploy/DeployMojoTest.java | 7 +-
6 files changed, 64 insertions(+), 54 deletions(-)
diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml
index 56062b5..ff3f00c 100644
--- a/.github/workflows/maven-verify.yml
+++ b/.github/workflows/maven-verify.yml
@@ -26,6 +26,6 @@ jobs:
name: Verify
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
with:
- ff-maven: "4.0.0-beta-3" # Maven version for fail-fast-build
- maven-matrix: '[ "4.0.0-beta-3" ]'
+ ff-maven: "4.0.0-beta-5" # Maven version for fail-fast-build
+ maven-matrix: '[ "4.0.0-beta-5" ]'
jdk-matrix: '[ "17", "21" ]'
diff --git a/pom.xml b/pom.xml
index 9fc6e9a..e287447 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,7 +69,7 @@ under the License.
<properties>
<javaVersion>17</javaVersion>
- <mavenVersion>4.0.0-beta-3</mavenVersion>
+ <mavenVersion>4.0.0-beta-5</mavenVersion>
<guiceVersion>6.0.0</guiceVersion>
<mavenAntrunPluginVersion>${version.maven-antrun-plugin}</mavenAntrunPluginVersion>
@@ -83,8 +83,8 @@ under the License.
<mavenSourcePluginVersion>${version.maven-source-plugin}</mavenSourcePluginVersion>
<mavenSurefirePluginVersion>${version.maven-surefire}</mavenSurefirePluginVersion>
<mavenWarPluginVersion>${version.maven-war-plugin}</mavenWarPluginVersion>
- <mavenPluginTestingVersion>4.0.0-beta-1</mavenPluginTestingVersion>
- <mavenResolverVersion>2.0.0-alpha-11</mavenResolverVersion>
+ <mavenPluginTestingVersion>4.0.0-beta-2</mavenPluginTestingVersion>
+ <mavenResolverVersion>2.0.2</mavenResolverVersion>
<mockitoVersion>5.12.0</mockitoVersion>
<slf4jVersion>2.0.13</slf4jVersion>
<version.plexus-xml>4.0.3</version.plexus-xml>
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
index 400a496..029128c 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
@@ -34,6 +34,7 @@ import java.util.jar.JarFile;
import java.util.regex.Pattern;
import org.apache.maven.api.Artifact;
+import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.model.Model;
import org.apache.maven.api.model.Parent;
@@ -277,7 +278,7 @@ public class DeployFileMojo extends AbstractDeployMojo {
List<Artifact> deployables = new ArrayList<>();
boolean isFilePom = classifier == null && "pom".equals(packaging);
- Artifact artifact = session.createArtifact(
+ ProducedArtifact artifact = session.createProducedArtifact(
groupId, artifactId, version, classifier, isFilePom ? "pom" : getExtension(file), packaging);
if (file.equals(getLocalRepositoryFile(artifact))) {
@@ -288,8 +289,9 @@ public class DeployFileMojo extends AbstractDeployMojo {
artifactManager.setPath(artifact, file);
deployables.add(artifact);
+ ProducedArtifact pomArtifact = null;
if (!isFilePom) {
- Artifact pomArtifact = session.createArtifact(groupId, artifactId, version, "", "pom", null);
+ pomArtifact = session.createProducedArtifact(groupId, artifactId, version, "", "pom", null);
if (deployedPom != null) {
artifactManager.setPath(pomArtifact, deployedPom);
deployables.add(pomArtifact);
@@ -306,13 +308,15 @@ public class DeployFileMojo extends AbstractDeployMojo {
}
if (sources != null) {
- Artifact sourcesArtifact = session.createArtifact(groupId, artifactId, version, "sources", "jar", null);
+ ProducedArtifact sourcesArtifact =
+ session.createProducedArtifact(groupId, artifactId, version, "sources", "jar", null);
artifactManager.setPath(sourcesArtifact, sources);
deployables.add(sourcesArtifact);
}
if (javadoc != null) {
- Artifact javadocArtifact = session.createArtifact(groupId, artifactId, version, "javadoc", "jar", null);
+ ProducedArtifact javadocArtifact =
+ session.createProducedArtifact(groupId, artifactId, version, "javadoc", "jar", null);
artifactManager.setPath(javadocArtifact, javadoc);
deployables.add(javadocArtifact);
}
@@ -360,7 +364,7 @@ public class DeployFileMojo extends AbstractDeployMojo {
String extension = getExtension(file);
String type = types.substring(ti, nti).trim();
- Artifact deployable = session.createArtifact(
+ ProducedArtifact deployable = session.createProducedArtifact(
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion().asString(),
@@ -405,6 +409,9 @@ public class DeployFileMojo extends AbstractDeployMojo {
} catch (IOException e) {
// ignore
}
+ if (pomArtifact != null) {
+ artifactManager.setPath(pomArtifact, null);
+ }
}
}
}
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
index 3b75d63..61c0b26 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.MojoExecution;
+import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.Project;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.di.Inject;
@@ -254,8 +255,8 @@ public class DeployMojo extends AbstractDeployMojo {
private ArtifactDeployerRequest createDeployerRequest() {
ProjectManager projectManager = getProjectManager();
- Collection<Artifact> deployables = projectManager.getAllArtifacts(project);
- Collection<Artifact> attachedArtifacts = projectManager.getAttachedArtifacts(project);
+ Collection<ProducedArtifact> deployables = projectManager.getAllArtifacts(project);
+ Collection<ProducedArtifact> attachedArtifacts = projectManager.getAttachedArtifacts(project);
ArtifactManager artifactManager = getArtifactManager();
if (artifactManager.getPath(project.getPomArtifact()).isEmpty()) {
@@ -292,7 +293,7 @@ public class DeployMojo extends AbstractDeployMojo {
ArtifactDeployerRequest request = ArtifactDeployerRequest.builder()
.session(session)
.repository(getDeploymentRepository(session.isVersionSnapshot(project.getVersion())))
- .artifacts(deployables)
+ .artifacts((Collection) deployables)
.retryFailedDeploymentCount(Math.max(1, Math.min(10, getRetryFailedDeploymentCount())))
.build();
diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
index 25ba936..471c5bd 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
@@ -165,26 +165,27 @@ public class DeployFileMojoTest {
String version = (String) getVariableValueFromObject(mojo, "version");
String url = (String) getVariableValueFromObject(mojo, "url");
- ArtifactDeployerRequest request = execute(mojo);
-
- assertNotNull(request);
- List<Artifact> artifacts = new ArrayList<>(request.getArtifacts());
- assertEquals(2, artifacts.size());
- // first artifact
- Artifact a1 = artifacts.get(0);
- assertEquals(new ArtifactStub(groupId, artifactId, "bin", version, "jar"), a1);
- Path p1 = artifactManager.getPath(a1).orElse(null);
- assertNotNull(p1);
- assertTrue(p1.toString().endsWith("maven-deploy-test-1.0-SNAPSHOT.jar"));
- // second artifact
- Artifact a2 = artifacts.get(1);
- assertEquals(new ArtifactStub(groupId, artifactId, "", version, "pom"), a2);
- Path p2 = artifactManager.getPath(a2).orElse(null);
- assertNotNull(p2);
- assertTrue(p2.toString().endsWith(".pom"));
- // remote repository
- assertNotNull(request.getRepository());
- assertEquals(url.replace(File.separator, "/"), request.getRepository().getUrl());
+ execute(mojo, request -> {
+ assertNotNull(request);
+ List<Artifact> artifacts = new ArrayList<>(request.getArtifacts());
+ assertEquals(2, artifacts.size());
+ // first artifact
+ Artifact a1 = artifacts.get(0);
+ assertEquals(new ArtifactStub(groupId, artifactId, "bin", version, "jar"), a1);
+ Path p1 = artifactManager.getPath(a1).orElse(null);
+ assertNotNull(p1);
+ assertTrue(p1.toString().endsWith("maven-deploy-test-1.0-SNAPSHOT.jar"));
+ // second artifact
+ Artifact a2 = artifacts.get(1);
+ assertEquals(new ArtifactStub(groupId, artifactId, "", version, "pom"), a2);
+ Path p2 = artifactManager.getPath(a2).orElse(null);
+ assertNotNull(p2);
+ assertTrue(p2.toString().endsWith(".pom"));
+ // remote repository
+ assertNotNull(request.getRepository());
+ assertEquals(
+ url.replace(File.separator, "/"), request.getRepository().getUrl());
+ });
}
@Test
@@ -206,24 +207,24 @@ public class DeployFileMojoTest {
assertEquals("maven-deploy-file-test", artifactId);
assertEquals("1.0", version);
- ArtifactDeployerRequest request = execute(mojo);
-
- assertNotNull(request);
- List<Artifact> artifacts = new ArrayList<>(request.getArtifacts());
- assertEquals(2, artifacts.size());
- Artifact a1 = artifacts.get(0);
- Artifact a2 = artifacts.get(1);
- Path p1 = artifactManager.getPath(a1).orElse(null);
- Path p2 = artifactManager.getPath(a2).orElse(null);
- assertNotNull(p1);
- assertTrue(p1.toString().endsWith("maven-deploy-test.zip"));
- assertNotNull(p2);
- assertTrue(p2.toString().endsWith(".pom"));
-
- assertNotNull(request.getRepository());
- assertEquals(
- "file://" + getBasedir().replace(File.separator, "/") + "/target/remote-repo/deploy-file",
- request.getRepository().getUrl());
+ execute(mojo, request -> {
+ assertNotNull(request);
+ List<Artifact> artifacts = new ArrayList<>(request.getArtifacts());
+ assertEquals(2, artifacts.size());
+ Artifact a1 = artifacts.get(0);
+ Artifact a2 = artifacts.get(1);
+ Path p1 = artifactManager.getPath(a1).orElse(null);
+ Path p2 = artifactManager.getPath(a2).orElse(null);
+ assertNotNull(p1);
+ assertTrue(p1.toString().endsWith("maven-deploy-test.zip"));
+ assertNotNull(p2);
+ assertTrue(p2.toString().endsWith(".pom"));
+
+ assertNotNull(request.getRepository());
+ assertEquals(
+ "file://" + getBasedir().replace(File.separator, "/") + "/target/remote-repo/deploy-file",
+ request.getRepository().getUrl());
+ });
}
private ArtifactDeployerRequest execute(DeployFileMojo mojo) {
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 a1e3e1e..79e9913 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -37,7 +37,7 @@ import org.apache.maven.api.plugin.MojoException;
import org.apache.maven.api.plugin.testing.InjectMojo;
import org.apache.maven.api.plugin.testing.MojoParameter;
import org.apache.maven.api.plugin.testing.MojoTest;
-import org.apache.maven.api.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.api.plugin.testing.stubs.ProducedArtifactStub;
import org.apache.maven.api.plugin.testing.stubs.ProjectStub;
import org.apache.maven.api.plugin.testing.stubs.SessionMock;
import org.apache.maven.api.services.ArtifactDeployer;
@@ -158,7 +158,7 @@ public class DeployMojoTest {
Project project = (Project) getVariableValueFromObject(mojo, "project");
projectManager.attachArtifact(
project,
- new ArtifactStub("org.apache.maven.test", "attached-artifact-test", "", "1.0-SNAPSHOT", "jar"),
+ new ProducedArtifactStub("org.apache.maven.test", "attached-artifact-test", "", "1.0-SNAPSHOT", "jar"),
Paths.get(getBasedir(), "target/test-classes/unit/attached-artifact-test-1.0-SNAPSHOT.jar"));
artifactManager.setPath(
project.getMainArtifact().get(),
@@ -310,7 +310,8 @@ public class DeployMojoTest {
.url(Paths.get(getBasedir()).toUri().toString())
.build())
.build()));
- ArtifactStub jar = new ArtifactStub("org.apache.maven.test", "maven-deploy-test", "", "1.0-SNAPSHOT", "jar");
+ ProducedArtifactStub jar =
+ new ProducedArtifactStub("org.apache.maven.test", "maven-deploy-test", "", "1.0-SNAPSHOT", "jar");
project.setMainArtifact(jar);
return project;
}