[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17643427#comment-17643427 ] Hudson commented on MNG-7619: - Build succeeded in Jenkins: Maven » Maven TLP » maven » master #148 See https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven/job/master/148/ > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Assignee: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17643423#comment-17643423 ] Hudson commented on MNG-7619: - Build succeeded in Jenkins: Maven » Maven TLP » maven » maven-3.9.x #96 See https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven/job/maven-3.9.x/96/ > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Assignee: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17643402#comment-17643402 ] ASF GitHub Bot commented on MNG-7619: - cstamas merged PR #900: URL: https://github.com/apache/maven/pull/900 > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17643403#comment-17643403 ] ASF GitHub Bot commented on MNG-7619: - cstamas merged PR #902: URL: https://github.com/apache/maven/pull/902 > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17643049#comment-17643049 ] ASF GitHub Bot commented on MNG-7619: - cstamas opened a new pull request, #902: URL: https://github.com/apache/maven/pull/902 Adds Maven feature that is able to explain why an artifact is present in local repository. Usable for diagnosing resolution issues. In local repository, for each artifact it records `.tracking` folder, containing farthest artifact that got to this artifact, and the list of graph nodes that lead to it. Note: this is based on by @grgrzybek proposal and reuses some code he provided. See https://github.com/apache/maven-resolver/pull/182 Forward-port of: https://github.com/apache/maven/pull/900 --- https://issues.apache.org/jira/browse/MNG-7619 Following this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[MNG-XXX] SUMMARY`, where you replace `MNG-XXX` and `SUMMARY` with the appropriate JIRA issue. Best practice is to use the JIRA issue title in the pull request title and in the first line of the commit message. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] You have run the [Core IT][core-its] successfully. If your pull request is about ~20 lines of code you don't need to sign an [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure please ask on the developers list. To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) you have to acknowledge this by using the following check-box. - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). [core-its]: https://maven.apache.org/core-its/core-it-suite/ > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642995#comment-17642995 ] ASF GitHub Bot commented on MNG-7619: - pzygielo commented on code in PR #900: URL: https://github.com/apache/maven/pull/900#discussion_r1038965386 ## maven-core/src/main/java/org/apache/maven/internal/aether/ReverseTreeRepositoryListener.java: ## @@ -0,0 +1,114 @@ +/* + * 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.internal.aether; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.ListIterator; +import java.util.Objects; +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.CollectStepData; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; + +/** + * A class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent} + * events fired during collection. + * + * @since 3.9.0 + */ +class ReverseTreeRepositoryListener extends AbstractRepositoryListener { +@Override +public void artifactResolved(RepositoryEvent event) { +requireNonNull(event, "event cannot be null"); + +if (!event.getArtifact() +.getFile() +.getPath() + .startsWith(event.getSession().getLocalRepository().getBasedir().getPath())) { +return; // reactor artifact +} +RequestTrace trace = event.getTrace(); +CollectStepData collectStepTrace = null; Review Comment: Class method (static) would need no instance for test. Like it doesn't to do its job. > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642993#comment-17642993 ] ASF GitHub Bot commented on MNG-7619: - cstamas commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-1336402839 Um, unsure why GH says "removed request" from @pzygielo , I actually asked both @michael-o and @pzygielo for repeated review... > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642977#comment-17642977 ] ASF GitHub Bot commented on MNG-7619: - pzygielo commented on code in PR #900: URL: https://github.com/apache/maven/pull/900#discussion_r1038946944 ## maven-core/src/main/java/org/apache/maven/internal/aether/ReverseTreeRepositoryListener.java: ## @@ -0,0 +1,114 @@ +/* + * 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.internal.aether; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.ListIterator; +import java.util.Objects; +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.CollectStepData; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; + +/** + * A class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent} + * events fired during collection. + * + * @since 3.9.0 + */ +class ReverseTreeRepositoryListener extends AbstractRepositoryListener { +@Override +public void artifactResolved(RepositoryEvent event) { +requireNonNull(event, "event cannot be null"); + +if (!event.getArtifact() +.getFile() +.getPath() + .startsWith(event.getSession().getLocalRepository().getBasedir().getPath())) { +return; // reactor artifact +} +RequestTrace trace = event.getTrace(); +CollectStepData collectStepTrace = null; Review Comment: Could this variable be moved one line up, and the loop then extracted to (tested) class method? > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642975#comment-17642975 ] ASF GitHub Bot commented on MNG-7619: - pzygielo commented on code in PR #900: URL: https://github.com/apache/maven/pull/900#discussion_r1038946491 ## maven-core/src/main/java/org/apache/maven/internal/aether/ReverseTreeRepositoryListener.java: ## @@ -0,0 +1,114 @@ +/* + * 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.internal.aether; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.ListIterator; +import java.util.Objects; +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.CollectStepData; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; + +/** + * A class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent} + * events fired during collection. + * + * @since 3.9.0 + */ +class ReverseTreeRepositoryListener extends AbstractRepositoryListener { +@Override +public void artifactResolved(RepositoryEvent event) { +requireNonNull(event, "event cannot be null"); + +if (!event.getArtifact() +.getFile() +.getPath() + .startsWith(event.getSession().getLocalRepository().getBasedir().getPath())) { +return; // reactor artifact Review Comment: Could this condition be extracted to method IDK, `isReactorArtifact(event)`? The comment then removed? The method tested? > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642964#comment-17642964 ] ASF GitHub Bot commented on MNG-7619: - cstamas commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-1336366201 @laeubi while I agree with ideas you wrote, I am still for this PR to go in, here is why: This PR is (nearly) trivial, but gives you powerful tool (for investigation, answering several questions), is registered early (earliest possible), and does not prevent anything of those you wrote (a plugin). Moreover, by being earliest present, and present during whole session of a real build, it covers _everything_ (even some plugin that may dynamically resolve). Not easily done with something like build extension or even plugin (they are all too late to cover everything). Also, none of these prevents anything of those things you wrote, this is totally orthogonal. I personally see this like `-X`, a handy switch seldom used by users, but when one needs it, is very very handy. > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642946#comment-17642946 ] ASF GitHub Bot commented on MNG-7619: - laeubi commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-1336328111 Not sure if this was already mentioned, but instead of "bake this in" would it not be better to have a way for (core-)plugins to hook in a `RepositoryListener` or even on the project level as we already to for `AbstractMavenLifeCycleListeners` / `WorkspaceReaders`? The this can become part of m-dependency-p for example. I also wonder if it is even required to record the data at all, should it not be sufficient to first load the pom(s), then generate a list of used plugins and then resolve their dependencies and then do something similar to `dependency:tree` (maybe plugin-dependency-tree)? To make it more convenient then one might pass a `-DdependencyReverse=` to have a reverse output rooted at the given GAV when build finished. > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642924#comment-17642924 ] ASF GitHub Bot commented on MNG-7619: - michael-o commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-1336266571 > Thats org.eclipse.aether.graph.Dependency#toString, we could fix it, but given this is "advanced" feature, I don't think is something would block this? Agree, we need to spin off the issue there. Here, no change is required. > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642923#comment-17642923 ] ASF GitHub Bot commented on MNG-7619: - cstamas commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-1336266075 Thats org.eclipse.aether.graph.Dependency#toString, we could fix it, but given this is "advanced" feature, I don't think is something would block this? > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642922#comment-17642922 ] ASF GitHub Bot commented on MNG-7619: - michael-o commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-1336265250 Can we leave out these empty parens: `org.apache.maven.plugins:maven-dependency-plugin:jar:3.3.0 () (plugin)`? From a user PoV it looks like a bug. > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642919#comment-17642919 ] ASF GitHub Bot commented on MNG-7619: - cstamas commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-133626 Note: this is based on by @grgrzybek proposal and reuses some code he provided. See https://github.com/apache/maven-resolver/pull/182 > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > > Ability to make Maven record: > * why given artifact is present in local repository > * record reverse dep tree how this artifact got resolved > This is mostly for detecting dependency resolution anomalies, ideally best > combined with {{-Dmaven.repo.local}} when you use new/empty local repo to > build a project. After the build, you will end up with reverse dep trees in > {{.tracking}} directories for each artifact. > To enable, pass {{-Dmaven.repo.local.recordReverseTree}} on CLI. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642917#comment-17642917 ] ASF GitHub Bot commented on MNG-7619: - michael-o commented on code in PR #900: URL: https://github.com/apache/maven/pull/900#discussion_r1038874052 ## maven-core/src/main/java/org/apache/maven/internal/aether/ReverseTreeRepositoryListener.java: ## @@ -0,0 +1,114 @@ +/* + * 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.internal.aether; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ListIterator; +import java.util.Objects; +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.CollectStepData; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; + +/** + * A class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent} + * events fired during collection. + * + * @since 3.9.0 + */ +class ReverseTreeRepositoryListener extends AbstractRepositoryListener { +private static final String EOL = System.lineSeparator(); Review Comment: LS, not EOL ## maven-core/src/main/java/org/apache/maven/internal/aether/ReverseTreeRepositoryListener.java: ## @@ -0,0 +1,114 @@ +/* + * 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.internal.aether; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ListIterator; +import java.util.Objects; +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.CollectStepData; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; + +/** + * A class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent} + * events fired during collection. + * + * @since 3.9.0 + */ +class ReverseTreeRepositoryListener extends AbstractRepositoryListener { +private static final String EOL = System.lineSeparator(); + +@Override +public void artifactResolved(RepositoryEvent event) { +requireNonNull(event, "event cannot be null"); + +if (!event.getArtifact() +.getFile() +.getPath() + .startsWith(event.getSession().getLocalRepository().getBasedir().getPath())) { +return; // reactor artifact +} +RequestTrace trace = event.getTrace(); +CollectStepData collectStepTrace = null; +while (trace != null) { +if (trace.getData() instanceof CollectStepData) { +collectStepTrace = (CollectStepData) trace.getData(); +break; +} +trace = trace.getParent(); +} + +if
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642914#comment-17642914 ] ASF GitHub Bot commented on MNG-7619: - cstamas commented on PR #900: URL: https://github.com/apache/maven/pull/900#issuecomment-1336258963 Excercise: build this PR (will produce Maven 3.9.0-SNAPSHOT distro), then use same distro to build itself (or just maven.3.9.x, does not matter) using these: ``` mvn clean install -Dmaven.repo.local=local -Dmaven.repo.local.recordReverseTree -Drat.skip ``` (rat is dumb to inspect "local" where local repository is and fail, so we skip it). Q1: why is maven-core 2.2.1 in local repo? ``` [cstamas@infinity maven (maven-3.9.x +%)]$ tree -L 1 local/org/apache/maven/maven-core/2.2.1/.tracking/ local/org/apache/maven/maven-core/2.2.1/.tracking/ ├── org.apache.maven.plugins_maven-remote-resources-plugin_jar_1.7.0 ├── org.codehaus.mojo_build-helper-maven-plugin_jar_1.12 └── org.codehaus.mojo_buildnumber-maven-plugin_jar_1.4 0 directories, 3 files [cstamas@infinity maven (maven-3.9.x +%)]$ cat local/org/apache/maven/maven-core/2.2.1/.tracking/org.codehaus.mojo_build-helper-maven-plugin_jar_1.12 org.apache.maven:maven-core:jar:2.2.1 (compile) (plugin) org.codehaus.mojo:build-helper-maven-plugin:jar:1.12 () (plugin) [cstamas@infinity maven (maven-3.9.x +%)]$ ``` > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7619) Maven should explain why an artifact is present in local repository
[ https://issues.apache.org/jira/browse/MNG-7619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17642913#comment-17642913 ] ASF GitHub Bot commented on MNG-7619: - cstamas opened a new pull request, #900: URL: https://github.com/apache/maven/pull/900 Adds Maven feature that is able to explain why an artifact is present in local repository. Usable for diagnosing resolution issues. --- https://issues.apache.org/jira/browse/MNG-7619 > Maven should explain why an artifact is present in local repository > --- > > Key: MNG-7619 > URL: https://issues.apache.org/jira/browse/MNG-7619 > Project: Maven > Issue Type: Improvement > Components: Dependencies >Reporter: Tamas Cservenak >Priority: Major > Fix For: 3.9.0, 4.0.x-candidate, 4.0.0-alpha-3 > > -- This message was sent by Atlassian Jira (v8.20.10#820010)