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 #269

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ under the License.

<properties>
<javaVersion>17</javaVersion>
<mavenVersion>4.0.0-beta-3</mavenVersion>
<mavenVersion>4.0.0-beta-5</mavenVersion>

<asmVersion>9.7</asmVersion>
<groovyVersion>2.4.21</groovyVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import org.apache.maven.api.plugin.MojoException;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.api.services.ArtifactManager;
import org.apache.maven.api.services.DependencyCoordinateFactory;
import org.apache.maven.api.services.DependencyCoordinateFactoryRequest;
import org.apache.maven.api.services.DependencyCoordinatesFactory;
import org.apache.maven.api.services.DependencyCoordinatesFactoryRequest;
import org.apache.maven.api.services.DependencyResolver;
import org.apache.maven.api.services.DependencyResolverRequest;
import org.apache.maven.api.services.MessageBuilder;
Expand Down Expand Up @@ -344,7 +344,7 @@ public abstract class AbstractCompilerMojo implements Mojo {
*
*/
@Parameter
protected List<DependencyCoordinate> annotationProcessorPaths;
protected List<DependencyCoordinates> annotationProcessorPaths;

/**
* <p>
Expand Down Expand Up @@ -1556,8 +1556,8 @@ private List<String> resolveProcessorPathEntries() throws MojoException {

try {
Session session = this.session.withRemoteRepositories(projectManager.getRemoteProjectRepositories(project));
List<org.apache.maven.api.DependencyCoordinate> coords =
annotationProcessorPaths.stream().map(this::toCoordinate).collect(Collectors.toList());
List<org.apache.maven.api.DependencyCoordinates> coords =
annotationProcessorPaths.stream().map(this::toCoordinates).collect(Collectors.toList());
return session
.getService(DependencyResolver.class)
.resolve(DependencyResolverRequest.builder()
Expand All @@ -1575,9 +1575,9 @@ private List<String> resolveProcessorPathEntries() throws MojoException {
}
}

private org.apache.maven.api.DependencyCoordinate toCoordinate(DependencyCoordinate coord) {
return session.getService(DependencyCoordinateFactory.class)
.create(DependencyCoordinateFactoryRequest.builder()
private org.apache.maven.api.DependencyCoordinates toCoordinates(DependencyCoordinates coord) {
return session.getService(DependencyCoordinatesFactory.class)
.create(DependencyCoordinatesFactoryRequest.builder()
.session(session)
.groupId(coord.getGroupId())
.artifactId(coord.getArtifactId())
Expand Down Expand Up @@ -1607,13 +1607,13 @@ public String getArtifactId() {
.toList();
}

private String getAnnotationProcessorPathVersion(DependencyCoordinate annotationProcessorPath)
private String getAnnotationProcessorPathVersion(DependencyCoordinates annotationProcessorPath)
throws MojoException {
String configuredVersion = annotationProcessorPath.getVersion();
if (configuredVersion != null) {
return configuredVersion;
} else {
List<org.apache.maven.api.DependencyCoordinate> managedDependencies = project.getManagedDependencies();
List<org.apache.maven.api.DependencyCoordinates> managedDependencies = project.getManagedDependencies();
return findManagedVersion(annotationProcessorPath, managedDependencies)
.orElseThrow(() -> new MojoException(String.format(
"Cannot find version for annotation processor path '%s'. The version needs to be either"
Expand All @@ -1623,15 +1623,15 @@ private String getAnnotationProcessorPathVersion(DependencyCoordinate annotation
}

private Optional<String> findManagedVersion(
DependencyCoordinate dependencyCoordinate,
List<org.apache.maven.api.DependencyCoordinate> managedDependencies) {
DependencyCoordinates dependencyCoordinate,
List<org.apache.maven.api.DependencyCoordinates> managedDependencies) {
return managedDependencies.stream()
.filter(dep -> Objects.equals(dep.getGroupId(), dependencyCoordinate.getGroupId())
&& Objects.equals(dep.getArtifactId(), dependencyCoordinate.getArtifactId())
&& Objects.equals(dep.getClassifier(), dependencyCoordinate.getClassifier())
&& Objects.equals(dep.getType().id(), dependencyCoordinate.getType()))
.findAny()
.map(d -> d.getVersion().asString());
.map(d -> d.getVersionConstraint().asString());
}

private void writePlugin(MessageBuilder mb) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class CompilerMojo extends AbstractCompilerMojo {
* Projects main artifact.
*/
@Parameter(defaultValue = "${project.mainArtifact}", readonly = true, required = true)
protected Artifact projectArtifact;
protected ProducedArtifact projectArtifact;

/**
* The directory for compiled classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @author Andreas Gudian
* @since 3.4
*/
public class DependencyCoordinate {
public class DependencyCoordinates {
private String groupId;

private String artifactId;
Expand Down Expand Up @@ -104,7 +104,7 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass()) {
return false;
}
DependencyCoordinate other = (DependencyCoordinate) obj;
DependencyCoordinates other = (DependencyCoordinates) obj;
return Objects.equals(groupId, other.groupId)
&& Objects.equals(artifactId, other.artifactId)
&& Objects.equals(version, other.version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.apache.maven.api.plugin.testing.MojoExtension;
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.ArtifactManager;
Expand Down Expand Up @@ -456,7 +456,7 @@ private static InternalSession createSession() {
.when(session)
.getStartTime();

Artifact junit = new ArtifactStub("junit", "junit", null, "3.8.1", "jar");
ProducedArtifactStub junit = new ProducedArtifactStub("junit", "junit", null, "3.8.1", "jar");

MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
doReturn(messageBuilderFactory).when(session).getService(MessageBuilderFactory.class);
Expand Down Expand Up @@ -513,7 +513,8 @@ private static InternalSession createSession() {
@SuppressWarnings("unused")
private static Project createProject() {
ProjectStub stub = new ProjectStub();
ArtifactStub artifact = new ArtifactStub("myGroupId", "myArtifactId", null, "1.0-SNAPSHOT", "jar");
ProducedArtifactStub artifact =
new ProducedArtifactStub("myGroupId", "myArtifactId", null, "1.0-SNAPSHOT", "jar");
stub.setMainArtifact(artifact);
stub.setModel(Model.newBuilder()
.groupId(artifact.getGroupId())
Expand Down
Loading