[ https://issues.apache.org/jira/browse/MNG-8177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17872436#comment-17872436 ]
ASF GitHub Bot commented on MNG-8177: ------------------------------------- slawekjaranowski commented on code in PR #1633: URL: https://github.com/apache/maven/pull/1633#discussion_r1712041455 ########## maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RequestTraceHelper.java: ########## @@ -0,0 +1,70 @@ +/* + * 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.repository.internal; + +import java.util.stream.Collectors; + +import org.apache.maven.model.Plugin; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.collection.CollectStepData; +import org.eclipse.aether.resolution.ArtifactDescriptorRequest; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.DependencyRequest; + +/** + * Helper class to manage {@link RequestTrace} for better error logging. + * + * @since 3.9.9 + */ +public final class RequestTraceHelper { + + /** + * Method that creates some informational string based on passed in {@link RequestTrace}. The contents of request + * trace can literally be anything, but this class tries to cover "most common" cases that are happening in Maven. + */ + public static String interpretTrace(boolean explain, RequestTrace requestTrace) { + while (requestTrace != null) { + Object data = requestTrace.getData(); + if (data instanceof DependencyRequest) { + DependencyRequest request = (DependencyRequest) data; + return (explain ? "dependency request for " : "") + request; + } else if (data instanceof CollectRequest) { + CollectRequest request = (CollectRequest) data; + return (explain ? "collect request for " : "") + request; + } else if (data instanceof CollectStepData) { + CollectStepData stepData = (CollectStepData) data; + return (explain ? "collect path " : "") + + stepData.getPath().stream().map(Object::toString).collect(Collectors.joining(" -> ")); Review Comment: It can generate very long one line message ... maybe more readable will be separated by new line ########## maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RequestTraceHelper.java: ########## @@ -0,0 +1,70 @@ +/* + * 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.repository.internal; + +import java.util.stream.Collectors; + +import org.apache.maven.model.Plugin; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.collection.CollectStepData; +import org.eclipse.aether.resolution.ArtifactDescriptorRequest; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.DependencyRequest; + +/** + * Helper class to manage {@link RequestTrace} for better error logging. + * + * @since 3.9.9 + */ +public final class RequestTraceHelper { + + /** + * Method that creates some informational string based on passed in {@link RequestTrace}. The contents of request + * trace can literally be anything, but this class tries to cover "most common" cases that are happening in Maven. + */ + public static String interpretTrace(boolean explain, RequestTrace requestTrace) { Review Comment: `explain` is always `true` > Warning "'dependencyManagement.dependencies.dependency.systemPath' for > com.sun:tools:jar refers to a non-existing file > C:\Temp\jdk-11.0.23\..\lib\tools.jar" > ------------------------------------------------------------------------------------------------------------------------------------------------------------ > > Key: MNG-8177 > URL: https://issues.apache.org/jira/browse/MNG-8177 > Project: Maven > Issue Type: Bug > Components: Core > Affects Versions: 3.9.8 > Environment: Java 11 > Reporter: Wolfgang Knauf > Assignee: Tamas Cservenak > Priority: Minor > Fix For: 4.0.0, 3.9.9, 4.0.0-beta-4 > > > This warning pops up first with Maven 3.9.8, previous versions up to 3.9.7 > did not report it: > {{[WARNING] 1 problem was encountered while building the effective model for > org.jboss:jboss-dmr:jar:1.3.0.Final}} > When using the "-X" switch, I see this additional message: > {{[WARNING] 'dependencyManagement.dependencies.dependency.systemPath' for > com.sun:tools:jar refers to a non-existing file > C:\Temp\jdk-11.0.23\..\lib\tools.jar. Please verify that you run Maven using > a JDK and not just a JRE. @ org.jboss:jboss-dmr:1.3.0.Final}} > > I run it with JDK 11, but downloaded the zip file only. There is no > "tools.jar", which was removed as part of Java 9. > > To reproduce: create a project from this archetype: > {{mvn archetype:generate -DarchetypeCatalog=local -DgroupId=com.acme > -DartifactId=example-subsystem -Dversion=1.0-SNAPSHOT > -Dmodule=org.test.subsystem -Dpackage=com.acme.example > -DarchetypeGroupId=org.wildfly.archetype > -DarchetypeArtifactId=wildfly-subsystem -DarchetypeVersion=32.0.0.Final > -DinteractiveMode=false}} > > Then run this command to see the warning: > {{mvn dependency:tree -X}} > > Actually, I don't know why jboss-dmr:1.3.0 is tested, as the project should > reference jboss-dmr:1.7.0. -- This message was sent by Atlassian Jira (v8.20.10#820010)