Skip to content

Commit

Permalink
Upgrade to beta-4
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Aug 29, 2024
1 parent 085900b commit d5e0e78
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ private InternalSession createSession() {
private Project createProject(InternalSession s) {
ProjectStub stub = new ProjectStub();
if (!"pom".equals(model.getPackaging())) {
ArtifactStub artifact = new ArtifactStub(
ProducedArtifactStub artifact = new ProducedArtifactStub(
model.getGroupId(), model.getArtifactId(), "", model.getVersion(), model.getPackaging());
stub.setMainArtifact(artifact);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Objects;

import org.apache.maven.api.Artifact;
import org.apache.maven.api.ArtifactCoordinate;
import org.apache.maven.api.ArtifactCoordinates;
import org.apache.maven.api.Version;
import org.apache.maven.api.VersionConstraint;
import org.apache.maven.api.annotations.Nonnull;
Expand Down Expand Up @@ -120,8 +120,8 @@ public boolean isSnapshot() {
}

@Override
public ArtifactCoordinate toCoordinate() {
return new ArtifactCoordinate() {
public ArtifactCoordinates toCoordinates() {
return new ArtifactCoordinates() {
@Override
public String getGroupId() {
return groupId;
Expand All @@ -138,7 +138,7 @@ public String getClassifier() {
}

@Override
public VersionConstraint getVersion() {
public VersionConstraint getVersionConstraint() {
return getParser().parseVersionConstraint(version);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.api.plugin.testing.stubs;

import org.apache.maven.api.ProducedArtifact;

/**
*
*/
public class ProducedArtifactStub extends ArtifactStub implements ProducedArtifact {
public ProducedArtifactStub() {}

public ProducedArtifactStub(
String groupId, String artifactId, String classifier, String version, String extension) {
super(groupId, artifactId, classifier, version, extension);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ProjectStub implements Project {
private boolean topProject;
private Path rootDirectory;
private Map<String, String> properties = new HashMap<>();
private Artifact mainArtifact;
private ProducedArtifact mainArtifact;

public void setModel(Model model) {
this.model = model;
Expand Down Expand Up @@ -119,8 +119,8 @@ public Map<String, PluginContainer> plugins() {
}

@Override
public List<Artifact> getArtifacts() {
Artifact pomArtifact = new ArtifactStub(getGroupId(), getArtifactId(), "", getVersion(), "pom");
public List<ProducedArtifact> getArtifacts() {
ProducedArtifact pomArtifact = new ProducedArtifactStub(getGroupId(), getArtifactId(), "", getVersion(), "pom");
return mainArtifact != null ? Arrays.asList(pomArtifact, mainArtifact) : Arrays.asList(pomArtifact);
}

Expand All @@ -138,13 +138,13 @@ public Path getPomPath() {

@Nonnull
@Override
public List<DependencyCoordinate> getDependencies() {
public List<DependencyCoordinates> getDependencies() {
return null;
}

@Nonnull
@Override
public List<DependencyCoordinate> getManagedDependencies() {
public List<DependencyCoordinates> getManagedDependencies() {
return null;
}

Expand Down Expand Up @@ -212,7 +212,7 @@ public ProjectStub setPackaging(String packaging) {
return this;
}

public ProjectStub setMainArtifact(Artifact mainArtifact) {
public ProjectStub setMainArtifact(ProducedArtifact mainArtifact) {
this.mainArtifact = mainArtifact;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.apache.maven.api.Artifact;
import org.apache.maven.api.LocalRepository;
import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.Project;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.Session;
Expand Down Expand Up @@ -223,7 +224,7 @@ public static InternalSession getMockSession(LocalRepository localRepository) {
Project project = iom.getArgument(1, Project.class);
String type = iom.getArgument(2, String.class);
Path path = iom.getArgument(3, Path.class);
Artifact artifact = session.createArtifact(
ProducedArtifact artifact = session.createProducedArtifact(
project.getGroupId(), project.getArtifactId(), project.getVersion(), null, null, type);
artifactManager.setPath(artifact, path);
attachedArtifacts
Expand All @@ -235,7 +236,7 @@ public static InternalSession getMockSession(LocalRepository localRepository) {
.attachArtifact(same(session), any(Project.class), any(), any());
doAnswer(iom -> {
Project project = iom.getArgument(0, Project.class);
Artifact artifact = iom.getArgument(1, Artifact.class);
ProducedArtifact artifact = iom.getArgument(1, ProducedArtifact.class);
Path path = iom.getArgument(2, Path.class);
artifactManager.setPath(artifact, path);
attachedArtifacts
Expand All @@ -244,7 +245,7 @@ public static InternalSession getMockSession(LocalRepository localRepository) {
return null;
})
.when(projectManager)
.attachArtifact(any(Project.class), any(Artifact.class), any(Path.class));
.attachArtifact(any(Project.class), any(ProducedArtifact.class), any(Path.class));
when(projectManager.getAttachedArtifacts(any()))
.then(iom ->
attachedArtifacts.computeIfAbsent(iom.getArgument(0, Project.class), p -> new ArrayList<>()));
Expand Down Expand Up @@ -319,7 +320,7 @@ public static InternalSession getMockSession(LocalRepository localRepository) {
Model model = new MavenStaxReader().read(request.getSource().get().openStream());
ProjectStub projectStub = new ProjectStub();
projectStub.setModel(model);
ArtifactStub artifactStub = new ArtifactStub(
ProducedArtifactStub artifactStub = new ProducedArtifactStub(
model.getGroupId(), model.getArtifactId(), "", model.getVersion(), model.getPackaging());
if (!"pom".equals(model.getPackaging())) {
projectStub.setMainArtifact(artifactStub);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@
import java.util.Optional;

import org.apache.maven.api.Artifact;
import org.apache.maven.api.ArtifactCoordinate;
import org.apache.maven.api.ArtifactCoordinates;
import org.apache.maven.api.Dependency;
import org.apache.maven.api.DependencyCoordinate;
import org.apache.maven.api.DependencyCoordinates;
import org.apache.maven.api.DependencyScope;
import org.apache.maven.api.DownloadedArtifact;
import org.apache.maven.api.Language;
import org.apache.maven.api.Listener;
import org.apache.maven.api.LocalRepository;
import org.apache.maven.api.Node;
import org.apache.maven.api.Packaging;
import org.apache.maven.api.PathScope;
import org.apache.maven.api.PathType;
import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.Project;
import org.apache.maven.api.ProjectScope;
import org.apache.maven.api.RemoteRepository;
Expand Down Expand Up @@ -219,58 +221,71 @@ public Artifact createArtifact(
}

@Override
public ArtifactCoordinate createArtifactCoordinate(String s, String s1, String s2, String s3) {
public ProducedArtifact createProducedArtifact(
String groupId, String artifactId, String version, String extension) {
return null;
}

@Override
public ArtifactCoordinate createArtifactCoordinate(String coordString) {
public ProducedArtifact createProducedArtifact(
String groupId, String artifactId, String version, String classifier, String extension, String type) {
return null;
}

@Override
public ArtifactCoordinates createArtifactCoordinates(
String groupId, String artifactId, String version, String extension) {
return null;
}

@Override
public ArtifactCoordinate createArtifactCoordinate(
String s, String s1, String s2, String s3, String s4, String s5) {
public ArtifactCoordinates createArtifactCoordinates(String coordString) {
return null;
}

@Override
public ArtifactCoordinates createArtifactCoordinates(
String groupId, String artifactId, String version, String classifier, String extension, String type) {
return null;
}

@Override
public ArtifactCoordinate createArtifactCoordinate(Artifact artifact) {
public ArtifactCoordinates createArtifactCoordinates(Artifact artifact) {
return null;
}

@Override
public DependencyCoordinate createDependencyCoordinate(ArtifactCoordinate artifactCoordinate) {
public DependencyCoordinates createDependencyCoordinates(ArtifactCoordinates artifactCoordinates) {
return null;
}

@Override
public DependencyCoordinate createDependencyCoordinate(Dependency dependency) {
public DependencyCoordinates createDependencyCoordinates(Dependency dependency) {
return null;
}

@Override
public Map.Entry<Artifact, Path> resolveArtifact(Artifact artifact) {
public DownloadedArtifact resolveArtifact(Artifact artifact) {
return null;
}

@Override
public Map.Entry<Artifact, Path> resolveArtifact(ArtifactCoordinate coordinate) {
public DownloadedArtifact resolveArtifact(ArtifactCoordinates coordinate) {
return null;
}

@Override
public Map<Artifact, Path> resolveArtifacts(ArtifactCoordinate... artifactCoordinates) {
public Collection<DownloadedArtifact> resolveArtifacts(ArtifactCoordinates... artifactCoordinates) {
return null;
}

@Override
public Map<Artifact, Path> resolveArtifacts(Collection<? extends ArtifactCoordinate> collection) {
public Collection<DownloadedArtifact> resolveArtifacts(Collection<? extends ArtifactCoordinates> collection) {
return null;
}

@Override
public Map<Artifact, Path> resolveArtifacts(Artifact... artifacts) {
public Collection<DownloadedArtifact> resolveArtifacts(Artifact... artifacts) {
return null;
}

Expand All @@ -280,12 +295,12 @@ public List<Node> flattenDependencies(Node node, PathScope scope) {
}

@Override
public List<Path> resolveDependencies(DependencyCoordinate dependencyCoordinate) {
public List<Path> resolveDependencies(DependencyCoordinates dependencyCoordinates) {
return null;
}

@Override
public List<Path> resolveDependencies(List<DependencyCoordinate> dependencyCoordinates) {
public List<Path> resolveDependencies(List<DependencyCoordinates> dependencyCoordinatess) {
return null;
}

Expand All @@ -295,12 +310,12 @@ public List<Path> resolveDependencies(Project project, PathScope scope) {
}

@Override
public Version resolveVersion(ArtifactCoordinate artifact) {
public Version resolveVersion(ArtifactCoordinates artifact) {
return null;
}

@Override
public List<Version> resolveVersionRange(ArtifactCoordinate artifact) {
public List<Version> resolveVersionRange(ArtifactCoordinates artifact) {
return null;
}

Expand All @@ -314,7 +329,7 @@ public void installArtifacts(Collection<Artifact> artifacts) {}
public void deployArtifact(RemoteRepository repository, Artifact... artifacts) {}

@Override
public void setArtifactPath(Artifact artifact, Path path) {}
public void setArtifactPath(ProducedArtifact artifact, Path path) {}

@Override
public Optional<Path> getArtifactPath(Artifact artifact) {
Expand All @@ -337,7 +352,7 @@ public Node collectDependencies(Project project) {
}

@Override
public Node collectDependencies(DependencyCoordinate dependencyCoordinate) {
public Node collectDependencies(DependencyCoordinates dependencyCoordinates) {
return null;
}

Expand Down Expand Up @@ -368,7 +383,7 @@ public VersionConstraint parseVersionConstraint(String s) {

@Override
public Map<PathType, List<Path>> resolveDependencies(
DependencyCoordinate dependencyCoordinate, PathScope scope, Collection<PathType> desiredTypes) {
DependencyCoordinates dependencyCoordinates, PathScope scope, Collection<PathType> desiredTypes) {
return Map.of();
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ under the License.

<properties>
<surefire.version>3.2.1</surefire.version>
<mavenVersion>4.0.0-beta-3</mavenVersion>
<mavenVersion>4.0.0-beta-4-SNAPSHOT</mavenVersion>
<maven.site.path>plugin-testing-archives/LATEST</maven.site.path>
<javaVersion>17</javaVersion>
<project.build.outputTimestamp>2024-06-26T07:42:15Z</project.build.outputTimestamp>
Expand Down

0 comments on commit d5e0e78

Please sign in to comment.