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 92534b6..56a0f4a 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ 17 - 4.0.0-beta-3 + 4.0.0-beta-5 2.0.13 @@ -84,7 +84,7 @@ 3.1.0 3.3.0 4.0.0-beta-1 - 4.0.0-beta-1 + 4.0.0-beta-2 3.3.0 3.2.1 3.2.2 diff --git a/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java b/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java index ab762ab..34af82c 100644 --- a/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; import org.apache.maven.api.Artifact; +import org.apache.maven.api.ProducedArtifact; import org.apache.maven.api.Session; import org.apache.maven.api.di.Inject; import org.apache.maven.api.model.Model; @@ -194,7 +195,7 @@ public void execute() { } 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))) { @@ -206,8 +207,9 @@ public void execute() { artifactManager.setPath(artifact, file); installableArtifacts.add(artifact); + ProducedArtifact pomArtifact = null; if (!isFilePom) { - Artifact pomArtifact = session.createArtifact(groupId, artifactId, version, null, "pom", null); + pomArtifact = session.createProducedArtifact(groupId, artifactId, version, null, "pom", null); if (deployedPom != null) { artifactManager.setPath(pomArtifact, deployedPom); installableArtifacts.add(pomArtifact); @@ -226,13 +228,15 @@ public void execute() { } 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); installableArtifacts.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); installableArtifacts.add(javadocArtifact); } @@ -249,6 +253,9 @@ public void execute() { } catch (IOException e) { // ignore } + if (pomArtifact != null) { + artifactManager.setPath(pomArtifact, null); + } } } } diff --git a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java index bd9699a..4dee57c 100644 --- a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java +++ b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java @@ -27,6 +27,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.Session; import org.apache.maven.api.di.Inject; @@ -179,8 +180,8 @@ private void installProject(ArtifactInstallerRequest request) { */ private ArtifactInstallerRequest processProject(Project project) { ProjectManager projectManager = getProjectManager(); - Collection installables = projectManager.getAllArtifacts(project); - Collection attachedArtifacts = projectManager.getAttachedArtifacts(project); + Collection installables = projectManager.getAllArtifacts(project); + Collection attachedArtifacts = projectManager.getAttachedArtifacts(project); getArtifactManager().setPath(project.getPomArtifact(), project.getPomPath()); @@ -211,7 +212,7 @@ private ArtifactInstallerRequest processProject(Project project) { } } - return ArtifactInstallerRequest.build(session, installables); + return ArtifactInstallerRequest.build(session, (Collection) installables); } private boolean isValidPath(Artifact a) { diff --git a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java index 0d00731..79232ef 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java @@ -170,8 +170,8 @@ public void testInstallFileWithClassifier(InstallFileMojo mojo) throws Exception Artifact pom = getArtifact(null, "pom"); Artifact sources = getArtifact("sources", "jar"); assertEquals(new HashSet<>(Arrays.asList(pom, sources)), artifacts); - // pom file does not exists, as it should have been deleted after the installation - assertFileNotExists(artifactManager.getPath(pom).get()); + // pom file does not exist, as it should have been deleted after the installation + assertTrue(artifactManager.getPath(pom).isEmpty()); assertFileExists(artifactManager.getPath(sources).get()); assertEquals( LOCAL_REPO, diff --git a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java index f4930d5..761d0b2 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java @@ -40,8 +40,8 @@ import org.apache.maven.api.plugin.MojoException; import org.apache.maven.api.plugin.testing.InjectMojo; 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.MojoExecutionStub; +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.ArtifactInstaller; @@ -120,7 +120,7 @@ public void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Excep 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(), @@ -182,8 +182,8 @@ private Project createProject(InternalSession session) { project.setArtifactId("maven-install-test"); project.setVersion("1.0-SNAPSHOT"); project.setPackaging("jar"); - ArtifactStub artifact = - new ArtifactStub("org.apache.maven.test", "maven-install-test", "", "1.0-SNAPSHOT", "jar"); + ProducedArtifactStub artifact = + new ProducedArtifactStub("org.apache.maven.test", "maven-install-test", "", "1.0-SNAPSHOT", "jar"); project.setMainArtifact(artifact); return project; }