Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Upgrade to beta 5 #81

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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" ]'
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -277,7 +278,7 @@ public void execute() throws MojoException {
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))) {
Expand All @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -405,6 +409,9 @@ public void execute() throws MojoException {
} catch (IOException e) {
// ignore
}
if (pomArtifact != null) {
artifactManager.setPath(pomArtifact, null);
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -254,8 +255,8 @@ private void deploy(ArtifactDeployerRequest request) {

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()) {
Expand Down Expand Up @@ -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();

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