diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 56062b54..ff3f00c3 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 9fc6e9ad..40e504fd 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ under the License. 17 - 4.0.0-beta-3 + 4.0.0-beta-5 6.0.0 ${version.maven-antrun-plugin} @@ -83,8 +83,8 @@ under the License. ${version.maven-source-plugin} ${version.maven-surefire} ${version.maven-war-plugin} - 4.0.0-beta-1 - 2.0.0-alpha-11 + 4.0.0-beta-2-SNAPSHOT + 2.0.2 5.12.0 2.0.13 4.0.3 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 400a496b..029128c5 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.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 void execute() throws MojoException { List 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 void execute() throws MojoException { 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 void execute() throws MojoException { } 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 void execute() throws MojoException { 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 void execute() throws MojoException { } 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 3b75d63d..61c0b262 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 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 @@ private void deploy(ArtifactDeployerRequest request) { private ArtifactDeployerRequest createDeployerRequest() { ProjectManager projectManager = getProjectManager(); - Collection deployables = projectManager.getAllArtifacts(project); - Collection attachedArtifacts = projectManager.getAttachedArtifacts(project); + Collection deployables = projectManager.getAllArtifacts(project); + Collection attachedArtifacts = projectManager.getAttachedArtifacts(project); ArtifactManager artifactManager = getArtifactManager(); if (artifactManager.getPath(project.getPomArtifact()).isEmpty()) { @@ -292,7 +293,7 @@ private ArtifactDeployerRequest createDeployerRequest() { 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 25ba9369..471c5bde 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 void testDeployIfClassifierIsSet(DeployFileMojo mojo) throws Exception { String version = (String) getVariableValueFromObject(mojo, "version"); String url = (String) getVariableValueFromObject(mojo, "url"); - ArtifactDeployerRequest request = execute(mojo); - - assertNotNull(request); - List 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 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 void testDeployIfArtifactIsNotJar(DeployFileMojo mojo) throws Exception { assertEquals("maven-deploy-file-test", artifactId); assertEquals("1.0", version); - ArtifactDeployerRequest request = execute(mojo); - - assertNotNull(request); - List 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 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 a1e3e1e4..79e9913a 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.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 void testDeployWithAttachedArtifacts(DeployMojo mojo) throws Exception { 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 @@ private Project createProject() { .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; }