elharo commented on code in PR #1677: URL: https://github.com/apache/maven-dependency-plugin/pull/1677#discussion_r3741750854
########## src/main/java/org/apache/maven/plugins/dependency/utils/RepositorySessionInjector.java: ########## @@ -0,0 +1,193 @@ +/* + * 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.plugins.dependency.utils; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.maven.RepositoryUtils; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.Authentication; +import org.apache.maven.artifact.repository.MavenArtifactRepository; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2; +import org.apache.maven.repository.Proxy; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.AuthenticationContext; +import org.eclipse.aether.repository.AuthenticationSelector; +import org.eclipse.aether.repository.MirrorSelector; +import org.eclipse.aether.repository.ProxySelector; +import org.eclipse.aether.repository.RemoteRepository; + +/** + * Applies the mirror, proxy and authentication configuration of a {@link RepositorySystemSession} to repositories + * that were built by hand rather than obtained from the project, so that they can be used for resolution. + * <p> + * This is the work {@code org.apache.maven.bridge.MavenRepositorySystem} does in its session-based + * {@code injectMirror}/{@code injectProxy}/{@code injectAuthentication} methods, reimplemented here because + * {@code org.apache.maven.bridge} is not one of the packages maven-core exports to plugin class realms — a plugin + * that references it compiles and unit-tests cleanly and then fails at runtime with + * {@code NoClassDefFoundError: org/apache/maven/bridge/MavenRepositorySystem}. Everything used below is in a package + * maven-core does export: {@code org.apache.maven} (for {@link RepositoryUtils}), {@code org.apache.maven.artifact}, + * {@code org.apache.maven.repository} and {@code org.eclipse.aether.repository}. + * <p> + * The session's selectors are populated by Maven from the mirrors, proxies and servers of + * <code>settings.xml</code>, with the servers and proxies already decrypted, and they are the same selectors + * Resolver consults when it performs the transfer. + */ +public class RepositorySessionInjector { Review Comment: There seems to be only one use of this class. Unless you intend this to be a general utility for external use, consider moving it into the package where it's used and making it non-public -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
