You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/05/24 13:50:10 UTC

[GitHub] [maven-resolver] cstamas opened a new pull request, #182: Idea2: collector using RequestTrace

cstamas opened a new pull request, #182:
URL: https://github.com/apache/maven-resolver/pull/182

   To pass over contextual information to listeners.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151172953

   > Will it use maven resolver 1.8.0 or 1.8.1? Any chance this PR will make it into maven-resolver used in Maven 3.9.0?
   
   Yes and yes: this is last bit we waited for to release resolver 1.8.1, and hopefully will go into Maven 3.9.0.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1150864268

   Dependencies can be tracked as expected. It works different for child→parent relationship, because the path is not passed down with `RequestTrace`.
   
   Most of the projects being built on fresh repo starts with:
   ```
   Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
   Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (3.9 kB at 8.9 kB/s)
   Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom
   Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom (13 kB at 157 kB/s)
   Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/21/maven-parent-21.pom
   Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/21/maven-parent-21.pom (26 kB at 277 kB/s)
   Downloading from central: https://repo.maven.apache.org/maven2/org/apache/apache/10/apache-10.pom
   Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/apache/10/apache-10.pom (15 kB at 197 kB/s)
   Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar
   Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar (25 kB at 254 kB/s)
   ```
   
   However for org.apache:apache:pom:10, I could track this information (in fresh M2 repo in `org/apache/apache/10/.tracking/org.apache.maven.plugins_maven-clean-plugin_2.5.plugin` file):
   ```
   org.apache:apache:pom:10
     org.apache.maven.plugins:maven-clean-plugin:2.5
       org.apache.maven:maven-core:3.8.6.1:default-lifecycle-bindings (implicit)
   
   Repository: central (https://repo.maven.apache.org/maven2, default, releases)
   ```
   
   It'd be great to insert these:
   * org/apache/maven/plugins/maven-plugins/22
   * org/apache/maven/maven-parent/21
   
   but for now let's leave as is - parent-child relationship is much less relevant than normal dependencies.
   
   What's most important is `log4j/log4j/1.2.12/.tracking/org.apache.maven.plugins_maven-compiler-plugin_jar_3.1.dep` file with:
   ```
   log4j:log4j:jar:1.2.12 (compile) (plugin)
     org.apache.xbean:xbean-reflect:jar:3.4 (compile) (plugin)
       org.codehaus.plexus:plexus-container-default:jar:1.5.5 (compile) (plugin)
         org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 () (plugin)
   
   Repository: central (https://repo.maven.apache.org/maven2, default, releases)
   ```


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] michael-o commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1140490337

   > > How does this change the message usage when this type of information is collected by default?
   > 
   > I don't quite get the question here...
   
   Stupid typo: memory usage


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151057136

   Another plugin doing its own resolution: `com.vaadin.integration.maven.UpdateWidgetsetMojo` - my listener is called, but there's only one RequestTrace available:
   ```
   result = {org.eclipse.aether.RepositoryEvent@41639} "ARTIFACT_RESOLVED ant:ant:pom:1.6.5 (/data/tmp/.m2-ext2-df/ant/ant/1.6.5/ant-1.6.5.pom) @ central (https://repo.maven.apache.org/maven2, default, releases)"
    artifact: org.eclipse.aether.artifact.Artifact  = {org.eclipse.aether.artifact.DefaultArtifact@41691} "ant:ant:pom:1.6.5"
    exceptions: java.util.List  = {java.util.Collections$EmptyList@41694}  size = 0
    file: java.io.File  = {java.io.File@41693} "/data/tmp/.m2-ext2-df/ant/ant/1.6.5/ant-1.6.5.pom"
    metadata: org.eclipse.aether.metadata.Metadata  = null
    repository: org.eclipse.aether.repository.ArtifactRepository  = {org.eclipse.aether.repository.RemoteRepository@41692} "central (https://repo.maven.apache.org/maven2, default, releases)"
    session: org.eclipse.aether.RepositorySystemSession  = {org.eclipse.aether.DefaultRepositorySystemSession@41690} 
    trace: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@41695} "ant:ant:pom:1.6.5 < [apache-snapshots (https://repository.apache.org/content/groups/snapshots-group, default, snapshots), sonatype-ops4j-snapshots (https://oss.sonatype.org/content/repositories/ops4j-snapshots, default, snapshots), prime-repo (https://repository.primefaces.org, default, releases+snapshots), sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, default, snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]"
     data: java.lang.Object  = {org.eclipse.aether.resolution.ArtifactRequest@41641} "ant:ant:pom:1.6.5 < [apache-snapshots (https://repository.apache.org/content/groups/snapshots-group, default, snapshots), sonatype-ops4j-snapshots (https://oss.sonatype.org/content/repositories/ops4j-snapshots, default, snapshots), prime-repo (https://repository.primefaces.org, default, releases+snapshots), sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, default, snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]"
      artifact: org.eclipse.aether.artifact.Artifact  = {org.eclipse.aether.artifact.DefaultArtifact@41705} "ant:ant:pom:1.6.5"
      context: java.lang.String  = {@41707} ""
      node: org.eclipse.aether.graph.DependencyNode  = null
      repositories: java.util.List  = {java.util.ArrayList@41706}  size = 5
      trace: org.eclipse.aether.RequestTrace  = null
     parent: org.eclipse.aether.RequestTrace  = null
    type: org.eclipse.aether.RepositoryEvent$EventType  = {@41689} "ARTIFACT_RESOLVED"
   ```


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151039187

   > try out new transport
   darn, I always lag behind... What kind of transport? ;)


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] michael-o commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151228693

   I will do the release 


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1147681955

   I'll check tomorrow - thanks!


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1149914516

   So far, so good/great!
   I have Maven 3.8.6 using maven-resolver 1.8.1-SNAPSHOT with this PR merged and I'm running my tests.
   For example, for log4j 1.2.12, I have:
   ```
   log4j:log4j:jar:1.2.12 (compile) (plugin)
     org.apache.xbean:xbean-reflect:jar:3.4 (compile) (plugin)
       org.codehaus.plexus:plexus-container-default:jar:1.5.5 (compile) (plugin)
         org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 () (plugin)
   ```
   
   And I could narrow down the extension to just one class - that extends `org.eclipse.aether.AbstractRepositoryListener` - so no more hacks of the resolver itself. And I can see everything I need in the data objects attached to available `org.eclipse.aether.RequestTrace`.
   
   Tomorrow I'll check how it affects the _embedded resolution process_ - because I have cases where separate resolution is performed within:
   * org.apache.camel.springboot:camel-spring-boot-generator-maven-plugin:prepare-spring-boot-starter mojo
   * org.apache.karaf.tooling:karaf-maven-plugin:assembly mojo
   
   I'll also provide some performance data.
   
   But for now I can say that this is a great addition to the resolver and exactly what I wanted ;).


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on a diff in pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#discussion_r884300349


##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";
+            String indent = "";
+            ListIterator<DependencyNode> iter = collectStepTrace.getPath()
+                    .listIterator( collectStepTrace.getPath().size() );
+            while ( iter.hasPrevious() )
+            {
+                DependencyNode curr = iter.previous();
+                indent += "  ";
+                trackingData += indent + curr + " (" + collectStepTrace.getContext() + ")\n";
+            }
+            try
+            {
+                Path trackingDir = resolvedArtifact.getFile().getParentFile().toPath().resolve( ".tracking" );
+                Files.createDirectories( trackingDir );
+                Path trackingFile = trackingDir.resolve( collectStepTrace.getPath().get( 0 )
+                        .getArtifact().toString().replace( ":", "_" ) );
+                Files.write( trackingFile, trackingData.getBytes( StandardCharsets.UTF_8 ) );
+                System.out.println( trackingData );
+            }
+            catch ( IOException e )
+            {
+                throw new UncheckedIOException( e );
+            }
+        }
+    }
+
+    /**
+     * The event "artifact resolved" if fired WHENEVER an artifact is resolved, BUT, it happens also when an artifact
+     * descriptor (model, the POM) is being built, and parent (and parent of parent...) is being asked for. Hence, this
+     * method "filters" out in WHICH artifact are we interested in, but it intentionally neglects extension, as
+     * ArtifactDescriptorReader modifies extension to "pom" during collect. So all we have to rely on is GAV only.
+     */
+    private boolean isInScope( Artifact artifact, Artifact nodeArtifact )
+    {
+        return Objects.equals( artifact.getGroupId(), nodeArtifact.getGroupId() )
+                && Objects.equals( artifact.getArtifactId(), nodeArtifact.getArtifactId() )
+                && Objects.equals( artifact.getVersion(), nodeArtifact.getVersion() );
+    }

Review Comment:
   No, it does not, as one "collect" events may produce several events, as parent POMs are being collected, and per definition parent POM GAV must be different (otherwise you have a cycle). Also, this is "demo snippet", and example here only want's to be clear that the event fired does not correspond 1:1 to "collect step" (again, several events are fired per one collect step).
   
   The trace request is added ONLY when collecting, and these events are fired as side effects of artifact descriptor read requests, and those are going to model builder, that in turn resolve (so use cached or fetches from remote) the POM and all POMs (like parents) needed to build artifact descriptor.... Hence, unrelated to actual dependency, artifact descriptor reader effectively goes for their POMs. Also, if you think about it, any classified artifact and main one too uses same one POM.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151058454

   The trace shows DefaultLegacyArtifactCollector, so this may be the reason:
   ```
   "main@1" prio=5 tid=0x1 nid=NA runnable
     java.lang.Thread.State: RUNNABLE
   	  at org.ops4j.tools.maven.tracker.TrackingRepositoryListener.write(TrackingRepositoryListener.java:123)
   	  at org.ops4j.tools.maven.tracker.TrackingRepositoryListener.artifactResolved(TrackingRepositoryListener.java:52)
   	  at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.dispatch(DefaultRepositoryEventDispatcher.java:136)
   	  at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.dispatch(DefaultRepositoryEventDispatcher.java:93)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.artifactResolved(DefaultArtifactResolver.java:673)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:339)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:235)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:212)
   	  at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:272)
   	  at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:318)
   	  at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:299)
   	  at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:593)
   	  at org.apache.maven.project.artifact.MavenMetadataSource.retrieve(MavenMetadataSource.java:212)
   	  at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:551)
   	  at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:605)
   	  at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:148)
   	  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:504)
   	  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveWithExceptions(DefaultArtifactResolver.java:358)
   	  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:352)
   	  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:324)
   	  at org.codehaus.mojo.gwt.AbstractGwtMojo.getJarAndDependencies(AbstractGwtMojo.java:377)
   	  at org.codehaus.mojo.gwt.AbstractGwtMojo.getGwtDevJar(AbstractGwtMojo.java:269)
   	  at com.vaadin.integration.maven.UpdateWidgetsetMojo.updateWidgetset(UpdateWidgetsetMojo.java:276)
   	  at com.vaadin.integration.maven.UpdateWidgetsetMojo.updateLocalWidgetset(UpdateWidgetsetMojo.java:123)
   	  at com.vaadin.integration.maven.UpdateWidgetsetMojo.doExecute(UpdateWidgetsetMojo.java:92)
   	  at org.codehaus.mojo.gwt.shell.AbstractGwtShellMojo.execute(AbstractGwtShellMojo.java:182)
   	  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
   	  at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
   	  at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
   	  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
   	  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
   	  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
   	  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
   	  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
   	  at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
   	  at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
   	  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
   	  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
   	  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
   	  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
   	  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
   	  at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
   	  at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
   	  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	  at java.lang.reflect.Method.invoke(Method.java:498)
   	  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
   	  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
   	  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
   	  at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
   ```


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151164419

   > darn, I always lag behind... What kind of transport? ;)
   
   Sorry, spoke too early: I just spotted you play with 3.8.6 while this is in 3.9.0 and above only https://issues.apache.org/jira/browse/MNG-7454
   
   (you can use it with 3.8.6 as well, but is a bit more complicated, just follow steps as here https://github.com/apache/maven/pull/635)
   
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas merged pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas merged PR #182:
URL: https://github.com/apache/maven-resolver/pull/182


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151034135

   New version of tracking extension: https://github.com/grgrzybek/tracking-maven-extension/commits/resolver-1.8.x
   
   I've performed these tests building https://github.com/ops4j/org.ops4j.pax.web project:
   * Maven 3.8.6 with maven-resolver 1.8.1-SNAPSHOT with this #182 merged and `-Dmaven.ext.class.path` pointing to my extension
   * Maven 3.8.6 with maven-resolver 1.8.1-SNAPSHOT with this #182 merged without my extension
   * Maven 3.8.6 with maven-resolver 1.8.1-SNAPSHOT with this #182 merged and `-Dmaven.ext.class.path` pointing to my extension and with `-Daether.collector.impl=bf`
   * Maven 3.8.6 with maven-resolver 1.8.1-SNAPSHOT with this #182 merged without my extension and with `-Daether.collector.impl=bf`
   * Maven 3.8.5 with normal maven-resolver 1.6.3
   
   and then 2nd time each of the above again on previously populated repo. Here are the results (tme = [tracking maven extension](https://github.com/grgrzybek/tracking-maven-extension/commits/resolver-1.8.x
   )):
   
   | | fresh repository | existing repository |
   |---|---|---|
   |mvn 3.8.6 + resolver 1.8.1 + #182 + tme + DF|5:25 min|1:08 min|
   |mvn 3.8.6 + resolver 1.8.1 + #182 + DF|5:09 min|1:07 min|
   |mvn 3.8.6 + resolver 1.8.1 + #182 + tme + BF|5:15 min|1:07 min|
   |mvn 3.8.6 + resolver 1.8.1 + #182 + BF|5:04 min|1:07 min|
   |mvn 3.8.5 + resolver 1.6.3|5:19 min|1:07 min|
   
   It's too small sample to treat it as proper performance test, but it can be a rough estimate.
   When nothing is downloaded (already populated repo) the times are almost the same.
   
   * When downloading is involved the extension's listener (where all the `.tracking` content is created) adds 10-15 seconds to the processing (~4-5%).
   * BF is slightly faster than DF.
   
   There are small difference between BF and DF when checking the reversed dependency trees - these are fully expected and actually show the difference in graph navigation. For example for aopalliance:aopalliance:1.0 I had:
   
   DF:
   ```
   aopalliance:aopalliance:pom:1.0
     aopalliance:aopalliance:jar:1.0 (compile) (plugin)
       org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0 (compile) (plugin)
         org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.0.0.M5 (compile) (plugin)
           org.apache.maven:maven-plugin-api:jar:3.1.1 (compile) (plugin)
             org.apache.maven.enforcer:enforcer-api:jar:3.0.0 (compile) (plugin)
               org.commonjava.maven.enforcer:enforce-managed-deps-rule:jar:1.3 (runtime) (plugin)
                 org.apache.maven.plugins:maven-enforcer-plugin:jar:3.0.0 () (plugin)
   
   Repository: central (https://repo.maven.apache.org/maven2, default, releases)
   ```
   
   BF:
   ```
   aopalliance:aopalliance:pom:1.0
     aopalliance:aopalliance:jar:1.0 (compile) (plugin)
       org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0 (compile) (plugin)
         org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.0.0.M5 (compile) (plugin)
           org.apache.maven:maven-plugin-api:jar:3.1.1 (compile) (plugin)
             org.apache.maven.plugins:maven-enforcer-plugin:jar:3.0.0 () (plugin)
   
   Repository: central (https://repo.maven.apache.org/maven2, default, releases)
   ```
   
   I'm going to have a look now at the plugins I've mentioned earlier (org.apache.camel.springboot:camel-spring-boot-generator-maven-plugin and org.apache.karaf.tooling:karaf-maven-plugin).
   
   Summarizing - the resolver changes are great! thanks @cstamas ! (cc: @gnodet )


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151932081

   @michael-o sorry for holding the release - I added my approval earlier ;)


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151167650

   Btw, Maven 3.9.0 (branch maven-3.9.x) is almost done, should be safe to use as well as you locally build instance for yourself (that's what I use as well when testing stuff).


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1147667658

   @grgrzybek Please take a peek a compare the "demo snippet" output with what you need


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151165431

   Similar situation with `camel-spring-boot-generator-maven-plugin:3.14.2-SNAPSHOT:prepare-spring-boot-starter`:
   ```
   "main@1" prio=5 tid=0x1 nid=NA runnable
     java.lang.Thread.State: RUNNABLE
   	  at org.ops4j.tools.maven.tracker.TrackingRepositoryListener.write(TrackingRepositoryListener.java:130)
   	  at org.ops4j.tools.maven.tracker.TrackingRepositoryListener.artifactResolved(TrackingRepositoryListener.java:53)
   	  at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.dispatch(DefaultRepositoryEventDispatcher.java:136)
   	  at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.dispatch(DefaultRepositoryEventDispatcher.java:93)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.artifactResolved(DefaultArtifactResolver.java:673)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:339)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:235)
   	  at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:212)
   	  at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:272)
   	  at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:318)
   	  at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:299)
   	  at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:593)
   	  at org.apache.maven.project.artifact.MavenMetadataSource.retrieve(MavenMetadataSource.java:212)
   	  at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:551)
   	  at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:605)
   	  at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:148)
   	  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:504)
   	  at org.apache.maven.repository.legacy.LegacyRepositorySystem.resolve(LegacyRepositorySystem.java:367)
   	  at org.apache.maven.DefaultProjectDependenciesResolver.resolveImpl(DefaultProjectDependenciesResolver.java:165)
   	  at org.apache.maven.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:81)
   	  at org.apache.maven.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:65)
   	  at org.apache.camel.springboot.maven.SpringBootStarterMojo.filterIncludedArtifacts(SpringBootStarterMojo.java:306)
   	  at org.apache.camel.springboot.maven.SpringBootStarterMojo.fixExcludedDependencies(SpringBootStarterMojo.java:265)
   	  at org.apache.camel.springboot.maven.SpringBootStarterMojo.executeAll(SpringBootStarterMojo.java:114)
   	  at org.apache.camel.springboot.maven.AbstractSpringBootGenerator.execute(AbstractSpringBootGenerator.java:69)
   	  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
   ...
   ```
   
   There's `org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector` involved and my listener, while called, doesn't have access to anything useful:
   ```
   result = {org.eclipse.aether.RepositoryEvent@9738} "ARTIFACT_RESOLVED com.fasterxml.jackson.datatype:jackson-datatype-jsr310:pom:2.12.1 (/home/ggrzybek/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.1/jackson-datatype-jsr310-2.12.1.pom) @ central (https://repo.maven.apache.org/maven2, default, releases)"
    artifact: org.eclipse.aether.artifact.Artifact  = {org.eclipse.aether.artifact.DefaultArtifact@9782} "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:pom:2.12.1"
    exceptions: java.util.List  = {java.util.Collections$EmptyList@9785}  size = 0
    file: java.io.File  = {java.io.File@9784} "/home/ggrzybek/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.1/jackson-datatype-jsr310-2.12.1.pom"
    metadata: org.eclipse.aether.metadata.Metadata  = null
    repository: org.eclipse.aether.repository.ArtifactRepository  = {org.eclipse.aether.repository.RemoteRepository@9783} "central (https://repo.maven.apache.org/maven2, default, releases)"
    session: org.eclipse.aether.RepositorySystemSession  = {org.eclipse.aether.DefaultRepositorySystemSession@9781} 
    trace: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@9786} "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:pom:2.12.1 < [central (https://repo.maven.apache.org/maven2, default, releases)]"
     data: java.lang.Object  = {org.eclipse.aether.resolution.ArtifactRequest@9740} "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:pom:2.12.1 < [central (https://repo.maven.apache.org/maven2, default, releases)]"
      artifact: org.eclipse.aether.artifact.Artifact  = {org.eclipse.aether.artifact.DefaultArtifact@9797} "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:pom:2.12.1"
      context: java.lang.String  = {@9799} ""
      node: org.eclipse.aether.graph.DependencyNode  = null
      repositories: java.util.List  = {java.util.ArrayList@9798}  size = 4
      trace: org.eclipse.aether.RequestTrace  = null
     parent: org.eclipse.aether.RequestTrace  = null
    type: org.eclipse.aether.RepositoryEvent$EventType  = {@9780} "ARTIFACT_RESOLVED"
   ```


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151179681

   > From my PoV just fine, waiting for @grgrzybek
   
   In a moment you nod, am merging this and soon is followed by 1.8.1 release...


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] michael-o commented on a diff in pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#discussion_r884301025


##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -44,6 +44,8 @@
 public class ReverseTreeRepositoryListener
         extends AbstractRepositoryListener
 {
+    private static final String LINE_SEP = System.lineSeparator();

Review Comment:
   In most cases we even use `LS` or `EOL`.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] michael-o commented on a diff in pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#discussion_r884173911


##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";

Review Comment:
   `toString()` is redudant



##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";
+            String indent = "";
+            ListIterator<DependencyNode> iter = collectStepTrace.getPath()
+                    .listIterator( collectStepTrace.getPath().size() );
+            while ( iter.hasPrevious() )
+            {
+                DependencyNode curr = iter.previous();
+                indent += "  ";
+                trackingData += indent + curr + " (" + collectStepTrace.getContext() + ")\n";

Review Comment:
   `System.lineSeparator()`



##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";

Review Comment:
   `System.lineSeparator()`



##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";
+            String indent = "";
+            ListIterator<DependencyNode> iter = collectStepTrace.getPath()
+                    .listIterator( collectStepTrace.getPath().size() );
+            while ( iter.hasPrevious() )
+            {
+                DependencyNode curr = iter.previous();
+                indent += "  ";
+                trackingData += indent + curr + " (" + collectStepTrace.getContext() + ")\n";
+            }
+            try
+            {
+                Path trackingDir = resolvedArtifact.getFile().getParentFile().toPath().resolve( ".tracking" );
+                Files.createDirectories( trackingDir );
+                Path trackingFile = trackingDir.resolve( collectStepTrace.getPath().get( 0 )
+                        .getArtifact().toString().replace( ":", "_" ) );
+                Files.write( trackingFile, trackingData.getBytes( StandardCharsets.UTF_8 ) );
+                System.out.println( trackingData );
+            }
+            catch ( IOException e )
+            {
+                throw new UncheckedIOException( e );
+            }
+        }
+    }
+
+    /**
+     * The event "artifact resolved" if fired WHENEVER an artifact is resolved, BUT, it happens also when an artifact
+     * descriptor (model, the POM) is being built, and parent (and parent of parent...) is being asked for. Hence, this
+     * method "filters" out in WHICH artifact are we interested in, but it intentionally neglects extension, as
+     * ArtifactDescriptorReader modifies extension to "pom" during collect. So all we have to rely on is GAV only.
+     */
+    private boolean isInScope( Artifact artifact, Artifact nodeArtifact )
+    {
+        return Objects.equals( artifact.getGroupId(), nodeArtifact.getGroupId() )
+                && Objects.equals( artifact.getArtifactId(), nodeArtifact.getArtifactId() )
+                && Objects.equals( artifact.getVersion(), nodeArtifact.getVersion() );
+    }

Review Comment:
   Classifier and type don't matter?



##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";
+            String indent = "";
+            ListIterator<DependencyNode> iter = collectStepTrace.getPath()
+                    .listIterator( collectStepTrace.getPath().size() );
+            while ( iter.hasPrevious() )
+            {
+                DependencyNode curr = iter.previous();
+                indent += "  ";
+                trackingData += indent + curr + " (" + collectStepTrace.getContext() + ")\n";
+            }
+            try
+            {
+                Path trackingDir = resolvedArtifact.getFile().getParentFile().toPath().resolve( ".tracking" );
+                Files.createDirectories( trackingDir );
+                Path trackingFile = trackingDir.resolve( collectStepTrace.getPath().get( 0 )
+                        .getArtifact().toString().replace( ":", "_" ) );
+                Files.write( trackingFile, trackingData.getBytes( StandardCharsets.UTF_8 ) );
+                System.out.println( trackingData );
+            }
+            catch ( IOException e )
+            {
+                throw new UncheckedIOException( e );
+            }
+        }
+    }
+
+    /**
+     * The event "artifact resolved" if fired WHENEVER an artifact is resolved, BUT, it happens also when an artifact
+     * descriptor (model, the POM) is being built, and parent (and parent of parent...) is being asked for. Hence, this
+     * method "filters" out in WHICH artifact are we interested in, but it intentionally neglects extension, as

Review Comment:
   extension as



##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";
+            String indent = "";
+            ListIterator<DependencyNode> iter = collectStepTrace.getPath()
+                    .listIterator( collectStepTrace.getPath().size() );
+            while ( iter.hasPrevious() )
+            {
+                DependencyNode curr = iter.previous();
+                indent += "  ";
+                trackingData += indent + curr + " (" + collectStepTrace.getContext() + ")\n";
+            }
+            try
+            {
+                Path trackingDir = resolvedArtifact.getFile().getParentFile().toPath().resolve( ".tracking" );
+                Files.createDirectories( trackingDir );
+                Path trackingFile = trackingDir.resolve( collectStepTrace.getPath().get( 0 )
+                        .getArtifact().toString().replace( ":", "_" ) );
+                Files.write( trackingFile, trackingData.getBytes( StandardCharsets.UTF_8 ) );
+                System.out.println( trackingData );
+            }
+            catch ( IOException e )
+            {
+                throw new UncheckedIOException( e );
+            }
+        }
+    }
+
+    /**
+     * The event "artifact resolved" if fired WHENEVER an artifact is resolved, BUT, it happens also when an artifact

Review Comment:
   BUT it...



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on a diff in pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#discussion_r884301868


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DependencyCollectorDelegate.java:
##########
@@ -290,6 +290,33 @@ public final CollectResult collectDependencies( RepositorySystemSession session,
         return result;
     }
 
+    /**
+     * Creates child {@link RequestTrace} instance from passed in {@link RequestTrace} and parameters by creating
+     * {@link CollectStepDataImpl} instance out of passed in data. Caller must ensure that passed in parameters are
+     * NOT affected by threading (or that there is no multi threading involved). In other words, the passed in values
+     * should be immutable.
+     *
+     * @param trace   The current trace instance.
+     * @param context The context from {@link CollectRequest#getRequestContext()}, never {@code null}.
+     * @param path    List representing the path of dependency nodes, never {@code null}. Caller must ensure, that this
+     *                list does not change during the lifetime of the requested {@link RequestTrace} instance. If it may
+     *                change, simplest is to pass here a copy of used list.
+     * @param node    Currently collected node, that collector came by following the passed in path.
+     * @return A child request trance instance, never {@code null}.
+     */
+    protected RequestTrace collectStepTrace( RequestTrace trace, String context, List<DependencyNode> path,

Review Comment:
   Am least certain about this method: it does "too little" IMHO. For example, it could just take a copy the passed in "path" parameter list, but OTOH, am unsure how big penalty (heap, GC wise) would this introduce. Hence, am leaving this decision (to copy or not copy the list) to subclass, as subclass should know does it requires a copy or not, or in other words, is it multi threaded or not.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1140492617

   > > > How does this change the message usage when this type of information is collected by default?
   > > 
   > > 
   > > I don't quite get the question here...
   > 
   > Stupid typo: memory usage
   
   I foresee minimal change, as this does not duplicates any collection, is really just new "step" instance per collect step. Still, AFAIR @khmarbaise  had some benchmark framework, so would be good to compare on insanely huge projects I guess....


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1140489240

   > How does this change the message usage when this type of information is collected by default?
   
   I don't quite get the question here...


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151171821

   > Btw, Maven 3.9.0 (branch maven-3.9.x) is almost done, should be safe to use as well as you locally build instance for yourself (that's what I use as well when testing stuff).
   
   Will it use maven resolver 1.8.0 or 1.8.1?
   Any chance this PR will make it into maven-resolver used in Maven 3.9.0?


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] michael-o commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151506806

   @grgrzybek can we merge this?


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] michael-o commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1141433187

   On my list for end of week. Waiting for @khmarbaise also...


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151036420

   @grgrzybek one more thing... IF you are testing already, try out new transport? :wink: 
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151148657

   An update about karaf-maven-plugin - while it's downloading additional artifacts (after analyzing the Karaf features), there's no real resolution performed, so it's not really possible to intercept karaf's downloads with some particular "path to the dependency".


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1151176988

   > Yes and yes: this very PR is last bit we waited for to release resolver 1.8.1, and hopefully will go into Maven 3.9.0.
   
   Great to hear - thank you very much for your outstanding help!


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] grgrzybek commented on pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
grgrzybek commented on PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#issuecomment-1149629847

   When running on simplest project, with modified [tracking maven extension](https://github.com/grgrzybek/tracking-maven-extension), I have all I need in `org.eclipse.aether.internal.impl.collect.CollectStepDataImpl`:
   ```
   event = {org.eclipse.aether.RepositoryEvent@5325} "ARTIFACT_DOWNLOADED log4j:log4j:pom:1.2.12 (/home/ggrzybek/sources/_testing/grgr-test-simplest/.m2/log4j/log4j/1.2.12/log4j-1.2.12.pom) @ central (https://repo.maven.apache.org/maven2, default, releases)"
    artifact: org.eclipse.aether.artifact.Artifact  = {org.eclipse.aether.artifact.DefaultArtifact@5346} "log4j:log4j:pom:1.2.12"
    exceptions: java.util.List  = {java.util.Collections$EmptyList@5348}  size = 0
    file: java.io.File  = {java.io.File@5347} "/home/ggrzybek/sources/_testing/grgr-test-simplest/.m2/log4j/log4j/1.2.12/log4j-1.2.12.pom"
    metadata: org.eclipse.aether.metadata.Metadata  = null
    repository: org.eclipse.aether.repository.ArtifactRepository  = {org.eclipse.aether.repository.RemoteRepository@2709} "central (https://repo.maven.apache.org/maven2, default, releases)"
    session: org.eclipse.aether.RepositorySystemSession  = {org.eclipse.aether.DefaultRepositorySystemSession@5330} 
    trace: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@5349} "log4j:log4j:pom:1.2.12 < [central (https://repo.maven.apache.org/maven2, default, releases), maven-default-http-blocker (http://0.0.0.0/, default, snapshots, blocked)]"
     data: java.lang.Object  = {org.eclipse.aether.resolution.ArtifactRequest@5356} "log4j:log4j:pom:1.2.12 < [central (https://repo.maven.apache.org/maven2, default, releases), maven-default-http-blocker (http://0.0.0.0/, default, snapshots, blocked)]"
     parent: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@5355} "log4j:log4j:jar:1.2.12 < [central (https://repo.maven.apache.org/maven2, default, releases), maven-default-http-blocker (http://0.0.0.0/, default, snapshots, blocked)]"
      data: java.lang.Object  = {org.eclipse.aether.resolution.ArtifactDescriptorRequest@5329} "log4j:log4j:jar:1.2.12 < [central (https://repo.maven.apache.org/maven2, default, releases), maven-default-http-blocker (http://0.0.0.0/, default, snapshots, blocked)]"
      parent: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@5359} "org.eclipse.aether.internal.impl.collect.CollectStepDataImpl@7551da2a"
       data: java.lang.Object  = {org.eclipse.aether.internal.impl.collect.CollectStepDataImpl@5363} 
        context: java.lang.String  = {@5375} "plugin"
        node: org.eclipse.aether.graph.Dependency  = {org.eclipse.aether.graph.Dependency@5331} "log4j:log4j:jar:1.2.12 (compile)"
        path: java.util.List  = {java.util.ArrayList@5336}  size = 3
         0 = {org.eclipse.aether.graph.DefaultDependencyNode@5378} "org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 ()"
         1 = {org.eclipse.aether.graph.DefaultDependencyNode@5379} "org.codehaus.plexus:plexus-container-default:jar:1.5.5 (compile)"
         2 = {org.eclipse.aether.graph.DefaultDependencyNode@5380} "org.apache.xbean:xbean-reflect:jar:3.4 (compile)"
       parent: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@5362} "org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 () -> [] < [central (https://repo.maven.apache.org/maven2, default, releases)]"
        data: java.lang.Object  = {org.eclipse.aether.collection.CollectRequest@5366} "org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 () -> [] < [central (https://repo.maven.apache.org/maven2, default, releases)]"
        parent: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@5365} "org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 () -> [] < [central (https://repo.maven.apache.org/maven2, default, releases)]"
         data: java.lang.Object  = {org.eclipse.aether.resolution.DependencyRequest@5370} "org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 () -> [] < [central (https://repo.maven.apache.org/maven2, default, releases)]"
         parent: org.eclipse.aether.RequestTrace  = {org.eclipse.aether.RequestTrace@5369} "Plugin [org.apache.maven.plugins:maven-compiler-plugin]"
          data: java.lang.Object  = {org.apache.maven.model.Plugin@5373} "Plugin [org.apache.maven.plugins:maven-compiler-plugin]"
          parent: org.eclipse.aether.RequestTrace  = null
   ```
   
   Checking few of my corner cases...


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on a diff in pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#discussion_r884300349


##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";
+            String indent = "";
+            ListIterator<DependencyNode> iter = collectStepTrace.getPath()
+                    .listIterator( collectStepTrace.getPath().size() );
+            while ( iter.hasPrevious() )
+            {
+                DependencyNode curr = iter.previous();
+                indent += "  ";
+                trackingData += indent + curr + " (" + collectStepTrace.getContext() + ")\n";
+            }
+            try
+            {
+                Path trackingDir = resolvedArtifact.getFile().getParentFile().toPath().resolve( ".tracking" );
+                Files.createDirectories( trackingDir );
+                Path trackingFile = trackingDir.resolve( collectStepTrace.getPath().get( 0 )
+                        .getArtifact().toString().replace( ":", "_" ) );
+                Files.write( trackingFile, trackingData.getBytes( StandardCharsets.UTF_8 ) );
+                System.out.println( trackingData );
+            }
+            catch ( IOException e )
+            {
+                throw new UncheckedIOException( e );
+            }
+        }
+    }
+
+    /**
+     * The event "artifact resolved" if fired WHENEVER an artifact is resolved, BUT, it happens also when an artifact
+     * descriptor (model, the POM) is being built, and parent (and parent of parent...) is being asked for. Hence, this
+     * method "filters" out in WHICH artifact are we interested in, but it intentionally neglects extension, as
+     * ArtifactDescriptorReader modifies extension to "pom" during collect. So all we have to rely on is GAV only.
+     */
+    private boolean isInScope( Artifact artifact, Artifact nodeArtifact )
+    {
+        return Objects.equals( artifact.getGroupId(), nodeArtifact.getGroupId() )
+                && Objects.equals( artifact.getArtifactId(), nodeArtifact.getArtifactId() )
+                && Objects.equals( artifact.getVersion(), nodeArtifact.getVersion() );
+    }

Review Comment:
   No, it does not, as one "collect" step may produce several resolved events, as parent POMs are being resolver, and per definition parent POM GAV must be different (otherwise you have a cycle). Also, this is "demo snippet", and example here only wants to be clear that the event fired does not correspond 1:1 to "collect step" (again, several events are fired per one collect step).
   
   The trace request is added ONLY when collecting, and these events are fired as side effects of artifact descriptor read requests, and those are going to model builder, that in turn resolve (so use cached or fetches from remote) the POM and all POMs (like parents) needed to build artifact descriptor.... Hence, unrelated to actual dependency, artifact descriptor reader effectively goes for their POMs. Also, if you think about it, any classified artifact and main one too uses same one POM.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on a diff in pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#discussion_r884301868


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DependencyCollectorDelegate.java:
##########
@@ -290,6 +290,33 @@ public final CollectResult collectDependencies( RepositorySystemSession session,
         return result;
     }
 
+    /**
+     * Creates child {@link RequestTrace} instance from passed in {@link RequestTrace} and parameters by creating
+     * {@link CollectStepDataImpl} instance out of passed in data. Caller must ensure that passed in parameters are
+     * NOT affected by threading (or that there is no multi threading involved). In other words, the passed in values
+     * should be immutable.
+     *
+     * @param trace   The current trace instance.
+     * @param context The context from {@link CollectRequest#getRequestContext()}, never {@code null}.
+     * @param path    List representing the path of dependency nodes, never {@code null}. Caller must ensure, that this
+     *                list does not change during the lifetime of the requested {@link RequestTrace} instance. If it may
+     *                change, simplest is to pass here a copy of used list.
+     * @param node    Currently collected node, that collector came by following the passed in path.
+     * @return A child request trance instance, never {@code null}.
+     */
+    protected RequestTrace collectStepTrace( RequestTrace trace, String context, List<DependencyNode> path,

Review Comment:
   Am least certain about this method: it does "too little" IMHO. For example, it could just take a copy the passed in "path" parameter list, but OTOH, am unsure how big penalty (heap, GC wise) would this introduce. Hence, am leaving this decision (to copy or not copy the list) to subclass, as subclass should know does it requires a copy or not, or in other words, is it multi threaded or not.
   
   DF for sure does not need to copy it (reason more why not to copy it here). BF once goes to "multi threaded POM download" it may, but as I see, each thread will have it's own context, and context carries the list, so again, I see no need for list copy.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-resolver] cstamas commented on a diff in pull request #182: [MRESOLVER-262] Provide contextual data in trace during collect

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #182:
URL: https://github.com/apache/maven-resolver/pull/182#discussion_r884300349


##########
maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/util/ReverseTreeRepositoryListener.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.maven.resolver.examples.util;
+
+/*
+ * 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.
+ */
+
+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;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A demo class building reverse tree using {@link CollectStepData} trace data provided in {@link RepositoryEvent}
+ * events fired during collection.
+ */
+public class ReverseTreeRepositoryListener
+        extends AbstractRepositoryListener
+{
+    @Override
+    public void artifactResolved( RepositoryEvent event )
+    {
+        requireNonNull( event, "event cannot be null" );
+
+        RequestTrace trace = event.getTrace();
+        CollectStepData collectStepTrace = null;
+        while ( trace != null )
+        {
+            if ( trace.getData() instanceof CollectStepData )
+            {
+                collectStepTrace = (CollectStepData) trace.getData();
+                break;
+            }
+            trace = trace.getParent();
+        }
+
+        if ( collectStepTrace == null )
+        {
+            return;
+        }
+
+        Artifact resolvedArtifact = event.getArtifact();
+        Artifact nodeArtifact = collectStepTrace.getNode().getArtifact();
+
+        if ( isInScope( resolvedArtifact, nodeArtifact ) )
+        {
+            Dependency node = collectStepTrace.getNode();
+            String trackingData = node.toString() + " (" + collectStepTrace.getContext() + ")\n";
+            String indent = "";
+            ListIterator<DependencyNode> iter = collectStepTrace.getPath()
+                    .listIterator( collectStepTrace.getPath().size() );
+            while ( iter.hasPrevious() )
+            {
+                DependencyNode curr = iter.previous();
+                indent += "  ";
+                trackingData += indent + curr + " (" + collectStepTrace.getContext() + ")\n";
+            }
+            try
+            {
+                Path trackingDir = resolvedArtifact.getFile().getParentFile().toPath().resolve( ".tracking" );
+                Files.createDirectories( trackingDir );
+                Path trackingFile = trackingDir.resolve( collectStepTrace.getPath().get( 0 )
+                        .getArtifact().toString().replace( ":", "_" ) );
+                Files.write( trackingFile, trackingData.getBytes( StandardCharsets.UTF_8 ) );
+                System.out.println( trackingData );
+            }
+            catch ( IOException e )
+            {
+                throw new UncheckedIOException( e );
+            }
+        }
+    }
+
+    /**
+     * The event "artifact resolved" if fired WHENEVER an artifact is resolved, BUT, it happens also when an artifact
+     * descriptor (model, the POM) is being built, and parent (and parent of parent...) is being asked for. Hence, this
+     * method "filters" out in WHICH artifact are we interested in, but it intentionally neglects extension, as
+     * ArtifactDescriptorReader modifies extension to "pom" during collect. So all we have to rely on is GAV only.
+     */
+    private boolean isInScope( Artifact artifact, Artifact nodeArtifact )
+    {
+        return Objects.equals( artifact.getGroupId(), nodeArtifact.getGroupId() )
+                && Objects.equals( artifact.getArtifactId(), nodeArtifact.getArtifactId() )
+                && Objects.equals( artifact.getVersion(), nodeArtifact.getVersion() );
+    }

Review Comment:
   No, it does not, as one "collect" event may produce several events, as parent POMs are being collected, and per definition parent POM GAV must be different (otherwise you have a cycle). Also, this is "demo snippet", and example here only wants to be clear that the event fired does not correspond 1:1 to "collect step" (again, several events are fired per one collect step).
   
   The trace request is added ONLY when collecting, and these events are fired as side effects of artifact descriptor read requests, and those are going to model builder, that in turn resolve (so use cached or fetches from remote) the POM and all POMs (like parents) needed to build artifact descriptor.... Hence, unrelated to actual dependency, artifact descriptor reader effectively goes for their POMs. Also, if you think about it, any classified artifact and main one too uses same one POM.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org