Skip to content

Commit

Permalink
Merge pull request #19672 from aloubyansky/mute-registry-client-mojo-…
Browse files Browse the repository at this point in the history
…transfer-listener

Mute artifact transfer listener for the registry client used from a Mojo unless debug is enabled
  • Loading branch information
aloubyansky authored Aug 26, 2021
2 parents 4cecb53 + abec422 commit 739f902
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.quarkus.devtools.project.BuildTool;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.devtools.project.QuarkusProjectHelper;
import io.quarkus.maven.utilities.MojoUtils;
import io.quarkus.platform.descriptor.loader.json.ResourceLoader;
import io.quarkus.platform.tools.maven.MojoMessageWriter;
import io.quarkus.registry.RegistryResolutionException;
Expand Down Expand Up @@ -89,7 +90,7 @@ public void execute() throws MojoExecutionException {
try {
mvn = MavenArtifactResolver.builder()
.setRepositorySystem(repoSystem)
.setRepositorySystemSession(repoSession)
.setRepositorySystemSession(MojoUtils.muteTransferListener(repoSession))
.setRemoteRepositories(repos)
.setRemoteRepositoryManager(remoteRepoManager)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void execute() throws MojoExecutionException {
try {
mvn = MavenArtifactResolver.builder()
.setRepositorySystem(repoSystem)
.setRepositorySystemSession(repoSession)
.setRepositorySystemSession(MojoUtils.muteTransferListener(repoSession))
.setRemoteRepositories(repos)
.setRemoteRepositoryManager(remoteRepoManager)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.devtools.project.QuarkusProjectHelper;
import io.quarkus.devtools.project.buildfile.MavenProjectBuildFile;
import io.quarkus.maven.utilities.MojoUtils;
import io.quarkus.platform.descriptor.loader.json.ResourceLoader;
import io.quarkus.platform.tools.ToolsConstants;
import io.quarkus.platform.tools.ToolsUtils;
Expand Down Expand Up @@ -170,7 +171,7 @@ private MavenArtifactResolver artifactResolver() throws MojoExecutionException {
try {
artifactResolver = MavenArtifactResolver.builder()
.setRepositorySystem(repoSystem)
.setRepositorySystemSession(repoSession)
.setRepositorySystemSession(MojoUtils.muteTransferListener(repoSession))
.setRemoteRepositories(repos)
.setRemoteRepositoryManager(remoteRepositoryManager)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import org.apache.maven.cli.transfer.QuietMavenTransferListener;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystemSession;

/**
* @author kameshs
Expand Down Expand Up @@ -60,6 +63,15 @@ private MojoUtils() {
// Avoid direct instantiation
}

public static RepositorySystemSession muteTransferListener(RepositorySystemSession session) {
if (session.getTransferListener() == null) {
return session;
}
final DefaultRepositorySystemSession newSession = new DefaultRepositorySystemSession(session);
newSession.setTransferListener(new QuietMavenTransferListener());
return newSession;
}

/**
* Checks whether the project has the dependency
*
Expand Down

0 comments on commit 739f902

Please sign in to comment.