[ https://issues.apache.org/jira/browse/MNG-6869?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17686926#comment-17686926 ]
ASF GitHub Bot commented on MNG-6869: ------------------------------------- michael-o commented on code in PR #995: URL: https://github.com/apache/maven/pull/995#discussion_r1102407885 ########## maven-embedder/src/main/java/org/apache/maven/cli/RemoteRepositoryConnectionVerifier.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.cli; + +import java.net.URI; +import java.util.Optional; + +import org.apache.commons.lang3.StringUtils; +import org.apache.maven.RepositoryUtils; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.spi.connector.transport.GetTask; +import org.eclipse.aether.spi.connector.transport.Transporter; +import org.eclipse.aether.spi.connector.transport.TransporterProvider; +import org.eclipse.aether.transfer.NoTransporterException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Helper class to verify connection to a remote repository. + */ +public class RemoteRepositoryConnectionVerifier { + private static final Artifact APACHE_MAVEN_ARTIFACT = MavenStatusCommand.APACHE_MAVEN_ARTIFACT; + private final Logger logger; + private final TransporterProvider transporterProvider; + + public RemoteRepositoryConnectionVerifier(final PlexusContainer container) throws ComponentLookupException { + this.logger = LoggerFactory.getILoggerFactory().getLogger(RemoteRepositoryConnectionVerifier.class.getName()); + this.transporterProvider = container.lookup(TransporterProvider.class); + } + + private boolean isCentralOrMirrorOfCentral(final RemoteRepository remoteRepository) { + return "central".equals(remoteRepository.getId()) + || remoteRepository.getMirroredRepositories().stream() + .map(RemoteRepository::getId) + .anyMatch("central"::equals); + } Review Comment: Please see: * https://github.com/apache/maven/pull/419 * https://issues.apache.org/jira/browse/MNG-4645 > New flag to verify the status > ----------------------------- > > Key: MNG-6869 > URL: https://issues.apache.org/jira/browse/MNG-6869 > Project: Maven > Issue Type: New Feature > Reporter: Robert Scholte > Assignee: Maarten Mulders > Priority: Major > > While working on INFRA-19861 we had issues with invalid changes in the > settings.xml. > This was detected too late. After installation {{mvn --version}} is called, > but it will only show the version of Maven. > It would be better to have a flag that verifies it a bit more: > - can Maven read/write to the local repository > - can Maven access all predefined repositories? (does the proxy work?) > This gives a much better feedback if Maven can do its job. > Current workaround: call something like {{mvn help:evaluate > -Dexpression=settings.localRepository -q -DforceStdout}} -- This message was sent by Atlassian Jira (v8.20.10#820010)