[MNG-8329] ArtifactInstallerRequest and ArtifactDeployerRequest should use Collection<ProducedArtifact> (#1836)

This commit is contained in:
Guillaume Nodet 2024-10-25 18:43:07 +02:00 committed by GitHub
parent 227b13a900
commit 2a6fc5ab67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 40 additions and 36 deletions

View File

@ -521,7 +521,7 @@ public interface Session {
*
* @see org.apache.maven.api.services.ArtifactInstaller#install(Session, Collection)
*/
void installArtifacts(@Nonnull Artifact... artifacts);
void installArtifacts(@Nonnull ProducedArtifact... artifacts);
/**
* Shortcut for {@code getService(ArtifactInstaller.class).install(...)}.
@ -531,7 +531,7 @@ public interface Session {
*
* @see org.apache.maven.api.services.ArtifactInstaller#install(Session, Collection)
*/
void installArtifacts(@Nonnull Collection<Artifact> artifacts);
void installArtifacts(@Nonnull Collection<ProducedArtifact> artifacts);
/**
* Shortcut for {@code getService(ArtifactDeployer.class).deploy(...)}.
@ -542,7 +542,7 @@ public interface Session {
*
* @see org.apache.maven.api.services.ArtifactDeployer#deploy(Session, RemoteRepository, Collection)
*/
void deployArtifact(@Nonnull RemoteRepository repository, @Nonnull Artifact... artifacts);
void deployArtifact(@Nonnull RemoteRepository repository, @Nonnull ProducedArtifact... artifacts);
/**
* Shortcut for {@code getService(ArtifactManager.class).setPath(...)}.

View File

@ -20,7 +20,7 @@ package org.apache.maven.api.services;
import java.util.Collection;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.Service;
import org.apache.maven.api.Session;
@ -28,10 +28,10 @@ import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
/**
* Deploys {@link Artifact}s to a {@link RemoteRepository}.
* Deploys {@link ProducedArtifact}s to a {@link RemoteRepository}.
*
* @since 4.0.0
* @see Session#deployArtifact(RemoteRepository, Artifact...)
* @see Session#deployArtifact(RemoteRepository, ProducedArtifact...)
*/
@Experimental
public interface ArtifactDeployer extends Service {
@ -50,7 +50,9 @@ public interface ArtifactDeployer extends Service {
* @throws IllegalArgumentException if an argument is {@code null} or invalid
*/
default void deploy(
@Nonnull Session session, @Nonnull RemoteRepository repository, @Nonnull Collection<Artifact> artifacts) {
@Nonnull Session session,
@Nonnull RemoteRepository repository,
@Nonnull Collection<ProducedArtifact> artifacts) {
deploy(ArtifactDeployerRequest.build(session, repository, artifacts));
}
}

View File

@ -20,7 +20,7 @@ package org.apache.maven.api.services;
import java.util.Collection;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.Session;
import org.apache.maven.api.annotations.Experimental;
@ -45,7 +45,7 @@ public interface ArtifactDeployerRequest {
RemoteRepository getRepository();
@Nonnull
Collection<Artifact> getArtifacts();
Collection<ProducedArtifact> getArtifacts();
int getRetryFailedDeploymentCount();
@ -56,7 +56,9 @@ public interface ArtifactDeployerRequest {
@Nonnull
static ArtifactDeployerRequest build(
@Nonnull Session session, @Nonnull RemoteRepository repository, @Nonnull Collection<Artifact> artifacts) {
@Nonnull Session session,
@Nonnull RemoteRepository repository,
@Nonnull Collection<ProducedArtifact> artifacts) {
return builder()
.session(nonNull(session, "session cannot be null"))
.repository(nonNull(repository, "repository cannot be null"))
@ -67,7 +69,7 @@ public interface ArtifactDeployerRequest {
class ArtifactDeployerRequestBuilder {
Session session;
RemoteRepository repository;
Collection<Artifact> artifacts;
Collection<ProducedArtifact> artifacts;
int retryFailedDeploymentCount;
ArtifactDeployerRequestBuilder() {}
@ -84,7 +86,7 @@ public interface ArtifactDeployerRequest {
return this;
}
public ArtifactDeployerRequestBuilder artifacts(Collection<Artifact> artifacts) {
public ArtifactDeployerRequestBuilder artifacts(Collection<ProducedArtifact> artifacts) {
this.artifacts = artifacts;
return this;
}
@ -102,13 +104,13 @@ public interface ArtifactDeployerRequest {
private static class DefaultArtifactDeployerRequest extends BaseRequest implements ArtifactDeployerRequest {
private final RemoteRepository repository;
private final Collection<Artifact> artifacts;
private final Collection<ProducedArtifact> artifacts;
private final int retryFailedDeploymentCount;
DefaultArtifactDeployerRequest(
@Nonnull Session session,
@Nonnull RemoteRepository repository,
@Nonnull Collection<Artifact> artifacts,
@Nonnull Collection<ProducedArtifact> artifacts,
int retryFailedDeploymentCount) {
super(session);
this.repository = nonNull(repository, "repository cannot be null");
@ -124,7 +126,7 @@ public interface ArtifactDeployerRequest {
@Nonnull
@Override
public Collection<Artifact> getArtifacts() {
public Collection<ProducedArtifact> getArtifacts() {
return artifacts;
}

View File

@ -21,14 +21,14 @@ package org.apache.maven.api.services;
import java.util.Collection;
import java.util.Collections;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.Service;
import org.apache.maven.api.Session;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
/**
* Installs {@link Artifact}s to the local repository.
* Installs {@link ProducedArtifact}s to the local repository.
*
* @since 4.0.0
* @see Session#withLocalRepository(org.apache.maven.api.LocalRepository)
@ -44,19 +44,19 @@ public interface ArtifactInstaller extends Service {
/**
* @param session the repository session
* @param artifact the {@link Artifact} to install
* @param artifact the {@link ProducedArtifact} to install
* @throws ArtifactInstallerException In case of an error which can be the a given artifact cannot be found or the
* installation has failed.
* @throws IllegalArgumentException in case of parameter {@code session} is {@code null} or
* {@code artifact} is {@code null}.
*/
default void install(Session session, Artifact artifact) {
default void install(Session session, ProducedArtifact artifact) {
install(session, Collections.singletonList(artifact));
}
/**
* @param session the repository session
* @param artifacts Collection of {@link Artifact MavenArtifacts}
* @param artifacts Collection of {@link ProducedArtifact MavenArtifacts}
* @throws ArtifactInstallerException In case of an error which can be the a given artifact cannot be found or the
* installation has failed.
* @throws IllegalArgumentException in case of parameter {@code request} is {@code null} or parameter
@ -64,7 +64,7 @@ public interface ArtifactInstaller extends Service {
* or parameter {@code mavenArtifacts} is {@code null} or
* {@code mavenArtifacts.isEmpty()} is {@code true}.
*/
default void install(Session session, Collection<Artifact> artifacts) {
default void install(Session session, Collection<ProducedArtifact> artifacts) {
install(ArtifactInstallerRequest.build(session, artifacts));
}
}

View File

@ -21,7 +21,7 @@ package org.apache.maven.api.services;
import java.util.Collection;
import java.util.Collections;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.Session;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Immutable;
@ -44,7 +44,7 @@ public interface ArtifactInstallerRequest {
Session getSession();
@Nonnull
Collection<Artifact> getArtifacts();
Collection<ProducedArtifact> getArtifacts();
@Nonnull
static ArtifactInstallerRequestBuilder builder() {
@ -52,7 +52,7 @@ public interface ArtifactInstallerRequest {
}
@Nonnull
static ArtifactInstallerRequest build(Session session, Collection<Artifact> artifacts) {
static ArtifactInstallerRequest build(Session session, Collection<ProducedArtifact> artifacts) {
return builder()
.session(nonNull(session, "session cannot be null"))
.artifacts(nonNull(artifacts, "artifacts cannot be null"))
@ -62,7 +62,7 @@ public interface ArtifactInstallerRequest {
@NotThreadSafe
class ArtifactInstallerRequestBuilder {
Session session;
Collection<Artifact> artifacts = Collections.emptyList();
Collection<ProducedArtifact> artifacts = Collections.emptyList();
ArtifactInstallerRequestBuilder() {}
@ -73,7 +73,7 @@ public interface ArtifactInstallerRequest {
}
@Nonnull
public ArtifactInstallerRequestBuilder artifacts(@Nullable Collection<Artifact> artifacts) {
public ArtifactInstallerRequestBuilder artifacts(@Nullable Collection<ProducedArtifact> artifacts) {
this.artifacts = artifacts != null ? artifacts : Collections.emptyList();
return this;
}
@ -85,16 +85,16 @@ public interface ArtifactInstallerRequest {
static class DefaultArtifactInstallerRequest extends BaseRequest implements ArtifactInstallerRequest {
private final Collection<Artifact> artifacts;
private final Collection<ProducedArtifact> artifacts;
DefaultArtifactInstallerRequest(@Nonnull Session session, @Nonnull Collection<Artifact> artifacts) {
DefaultArtifactInstallerRequest(@Nonnull Session session, @Nonnull Collection<ProducedArtifact> artifacts) {
super(session);
this.artifacts = unmodifiable(nonNull(artifacts, "artifacts cannot be null"));
}
@Nonnull
@Override
public Collection<Artifact> getArtifacts() {
public Collection<ProducedArtifact> getArtifacts() {
return artifacts;
}
}

View File

@ -344,7 +344,7 @@ public abstract class AbstractSession implements InternalSession {
}
@Override
public List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifact> artifacts) {
public List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<? extends Artifact> artifacts) {
return artifacts == null ? null : map(artifacts, this::toArtifact);
}
@ -637,7 +637,7 @@ public abstract class AbstractSession implements InternalSession {
* @see ArtifactInstaller#install(Session, Collection)
*/
@Override
public void installArtifacts(Artifact... artifacts) {
public void installArtifacts(ProducedArtifact... artifacts) {
installArtifacts(Arrays.asList(artifacts));
}
@ -648,7 +648,7 @@ public abstract class AbstractSession implements InternalSession {
* @see ArtifactInstaller#install(Session, Collection)
*/
@Override
public void installArtifacts(Collection<Artifact> artifacts) {
public void installArtifacts(Collection<ProducedArtifact> artifacts) {
getService(ArtifactInstaller.class).install(this, artifacts);
}
@ -659,7 +659,7 @@ public abstract class AbstractSession implements InternalSession {
* @see ArtifactDeployer#deploy(Session, RemoteRepository, Collection)
*/
@Override
public void deployArtifact(RemoteRepository repository, Artifact... artifacts) {
public void deployArtifact(RemoteRepository repository, ProducedArtifact... artifacts) {
getService(ArtifactDeployer.class).deploy(this, repository, Arrays.asList(artifacts));
}

View File

@ -20,7 +20,7 @@ package org.apache.maven.internal.impl;
import java.util.Collection;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.ProducedArtifact;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.di.Named;
@ -44,7 +44,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer {
public void deploy(@Nonnull ArtifactDeployerRequest request) {
nonNull(request, "request");
InternalSession session = InternalSession.from(request.getSession());
Collection<Artifact> artifacts = nonNull(request.getArtifacts(), "request.artifacts");
Collection<ProducedArtifact> artifacts = nonNull(request.getArtifacts(), "request.artifacts");
RemoteRepository repository = nonNull(request.getRepository(), "request.repository");
try {
DeployRequest deployRequest = new DeployRequest()

View File

@ -77,7 +77,7 @@ public interface InternalSession extends Session {
org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinates dependency, boolean managed);
List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifact> artifacts);
List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<? extends Artifact> artifacts);
org.eclipse.aether.artifact.Artifact toArtifact(Artifact artifact);