Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Upgrade to beta-5 #89

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]'
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

<properties>
<javaVersion>17</javaVersion>
<mavenVersion>4.0.0-beta-3</mavenVersion>
<mavenVersion>4.0.0-beta-5</mavenVersion>
<!-- Maven bound -->
<slf4jVersion>2.0.13</slf4jVersion>

Expand All @@ -84,7 +84,7 @@
<mavenEnforcerPluginVersion>3.1.0</mavenEnforcerPluginVersion>
<mavenJarPluginVersion>3.3.0</mavenJarPluginVersion>
<mavenPluginPluginVersion>4.0.0-beta-1</mavenPluginPluginVersion>
<mavenPluginTestingVersion>4.0.0-beta-1</mavenPluginTestingVersion>
<mavenPluginTestingVersion>4.0.0-beta-2-SNAPSHOT</mavenPluginTestingVersion>
<mavenResourcesPluginVersion>3.3.0</mavenResourcesPluginVersion>
<mavenSourcePluginVersion>3.2.1</mavenSourcePluginVersion>
<mavenSurefirePluginVersion>3.2.2</mavenSurefirePluginVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))) {
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -249,6 +253,9 @@ public void execute() {
} catch (IOException e) {
// ignore
}
if (pomArtifact != null) {
artifactManager.setPath(pomArtifact, null);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -179,8 +180,8 @@ private void installProject(ArtifactInstallerRequest request) {
*/
private ArtifactInstallerRequest processProject(Project project) {
ProjectManager projectManager = getProjectManager();
Collection<Artifact> installables = projectManager.getAllArtifacts(project);
Collection<Artifact> attachedArtifacts = projectManager.getAttachedArtifacts(project);
Collection<ProducedArtifact> installables = projectManager.getAllArtifacts(project);
Collection<ProducedArtifact> attachedArtifacts = projectManager.getAttachedArtifacts(project);

getArtifactManager().setPath(project.getPomArtifact(), project.getPomPath());

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
}
Expand Down