-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
304 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
shared/src/main/java/eu/maveniverse/maven/toolbox/shared/DeployingSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2023-2024 Maveniverse Org. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
package eu.maveniverse.maven.toolbox.shared; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Collection; | ||
import org.eclipse.aether.RepositorySystem; | ||
import org.eclipse.aether.RepositorySystemSession; | ||
import org.eclipse.aether.RequestTrace; | ||
import org.eclipse.aether.artifact.Artifact; | ||
import org.eclipse.aether.deployment.DeployRequest; | ||
import org.eclipse.aether.deployment.DeploymentException; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
|
||
/** | ||
* Construction to accept collection of artifacts and deploy them into given remote repository. | ||
*/ | ||
public final class DeployingSink implements ArtifactSink { | ||
/** | ||
* Creates installing sink that installs into passed in session local repository. | ||
*/ | ||
public static DeployingSink deploying( | ||
Output output, RepositorySystem system, RepositorySystemSession session, RemoteRepository repository) { | ||
return new DeployingSink(output, system, session, repository); | ||
} | ||
|
||
private final Output output; | ||
private final RepositorySystem system; | ||
private final RepositorySystemSession session; | ||
private final DeployRequest deployRequest; | ||
|
||
private DeployingSink( | ||
Output output, RepositorySystem system, RepositorySystemSession session, RemoteRepository repository) { | ||
this.output = requireNonNull(output, "output"); | ||
this.system = requireNonNull(system, "system"); | ||
this.session = requireNonNull(session, "session"); | ||
this.deployRequest = new DeployRequest(); | ||
this.deployRequest.setRepository(repository); | ||
this.deployRequest.setTrace(RequestTrace.newChild(null, this)); | ||
} | ||
|
||
@Override | ||
public void accept(Collection<Artifact> artifacts) { | ||
requireNonNull(artifacts, "artifacts"); | ||
deployRequest.setArtifacts(artifacts); | ||
} | ||
|
||
@Override | ||
public void accept(Artifact artifact) { | ||
requireNonNull(artifact, "artifact"); | ||
deployRequest.addArtifact(artifact); | ||
} | ||
|
||
@Override | ||
public void close() throws DeploymentException { | ||
output.normal( | ||
"Deploying {} artifacts to {}...", deployRequest.getArtifacts().size(), deployRequest.getRepository()); | ||
system.deploy(session, deployRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
shared/src/main/java/eu/maveniverse/maven/toolbox/shared/InstallingSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2023-2024 Maveniverse Org. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
package eu.maveniverse.maven.toolbox.shared; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Collection; | ||
import org.eclipse.aether.RepositorySystem; | ||
import org.eclipse.aether.RepositorySystemSession; | ||
import org.eclipse.aether.RequestTrace; | ||
import org.eclipse.aether.artifact.Artifact; | ||
import org.eclipse.aether.installation.InstallRequest; | ||
import org.eclipse.aether.installation.InstallationException; | ||
|
||
/** | ||
* Construction to accept collection of artifacts and install them into local repository. | ||
*/ | ||
public final class InstallingSink implements ArtifactSink { | ||
/** | ||
* Creates installing sink that installs into passed in session local repository. | ||
*/ | ||
public static InstallingSink installing(Output output, RepositorySystem system, RepositorySystemSession session) { | ||
return new InstallingSink(output, system, session); | ||
} | ||
|
||
private final Output output; | ||
private final RepositorySystem system; | ||
private final RepositorySystemSession session; | ||
private final InstallRequest installRequest; | ||
|
||
private InstallingSink(Output output, RepositorySystem system, RepositorySystemSession session) { | ||
this.output = requireNonNull(output, "output"); | ||
this.system = requireNonNull(system, "system"); | ||
this.session = requireNonNull(session, "session"); | ||
this.installRequest = new InstallRequest(); | ||
this.installRequest.setTrace(RequestTrace.newChild(null, this)); | ||
} | ||
|
||
@Override | ||
public void accept(Collection<Artifact> artifacts) { | ||
requireNonNull(artifacts, "artifacts"); | ||
installRequest.setArtifacts(artifacts); | ||
} | ||
|
||
@Override | ||
public void accept(Artifact artifact) { | ||
requireNonNull(artifact, "artifact"); | ||
installRequest.addArtifact(artifact); | ||
} | ||
|
||
@Override | ||
public void close() throws InstallationException { | ||
output.normal( | ||
"Installing {} artifacts...", installRequest.getArtifacts().size()); | ||
system.install(session, installRequest); | ||
} | ||
} |
Oops, something went wrong.