grgrzybek commented on code in PR #1058: URL: https://github.com/apache/maven/pull/1058#discussion_r1140503778
########## maven-core/src/main/java/org/apache/maven/internal/aether/ReverseTreeRepositoryListener.java: ########## @@ -49,45 +56,128 @@ class ReverseTreeRepositoryListener extends AbstractRepositoryListener { public void artifactResolved(RepositoryEvent event) { requireNonNull(event, "event cannot be null"); - if (!isLocalRepositoryArtifact(event.getSession(), event.getArtifact())) { + if (!isLocalRepositoryArtifactOrMissing(event.getSession(), event.getArtifact())) { return; } - CollectStepData collectStepTrace = lookupCollectStepData(event.getTrace()); - if (collectStepTrace == null) { - return; + RequestTrace trace = event.getTrace(); + + CollectStepData collectStepTrace = null; + ArtifactRequest artifactRequest = null; + ArtifactDescriptorRequest artifactDescriptorRequest = null; + Plugin plugin = null; + + while (trace != null) { + Object data = trace.getData(); + if (data instanceof CollectStepData) { + collectStepTrace = (CollectStepData) data; + } else if (data instanceof ArtifactDescriptorRequest) { + artifactDescriptorRequest = (ArtifactDescriptorRequest) data; + } else if (data instanceof ArtifactRequest) { + artifactRequest = (ArtifactRequest) data; + } else if (data instanceof Plugin) { + plugin = (Plugin) data; + } + trace = trace.getParent(); } - Artifact resolvedArtifact = event.getArtifact(); - Artifact nodeArtifact = collectStepTrace.getNode().getArtifact(); - - if (isInScope(resolvedArtifact, nodeArtifact)) { - Dependency node = collectStepTrace.getNode(); - ArrayList<String> trackingData = new ArrayList<>(); - trackingData.add(node + " (" + collectStepTrace.getContext() + ")"); - String indent = ""; - ListIterator<DependencyNode> iter = collectStepTrace - .getPath() - .listIterator(collectStepTrace.getPath().size()); - while (iter.hasPrevious()) { - DependencyNode curr = iter.previous(); + Path trackingDir; + boolean missing = event.getFile() == null; + if (missing) { + // missing artifact - let's track the path anyway + File dir = event.getSession().getLocalRepository().getBasedir(); + dir = new File( + dir, event.getSession().getLocalRepositoryManager().getPathForLocalArtifact(event.getArtifact())); + trackingDir = dir.getParentFile().toPath().resolve(".tracking"); + } else { + trackingDir = event.getFile().getParentFile().toPath().resolve(".tracking"); + } + + String baseName; + String ext = missing ? ".miss" : ".dep"; + Path trackingFile = null; + + String indent = ""; + ArrayList<String> trackingData = new ArrayList<>(); + + if (collectStepTrace == null && plugin != null) { + ext = ".plugin"; + baseName = plugin.getGroupId() + "_" + plugin.getArtifactId() + "_" + plugin.getVersion(); + trackingFile = trackingDir.resolve(baseName + ext); + if (Files.exists(trackingFile)) { + return; + } + + if (event.getArtifact() != null) { + trackingData.add(indent + event.getArtifact()); + indent += " "; + } + trackingData.add(indent + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion()); + indent += " "; + + InputLocation location = plugin.getLocation(""); + if (location != null && location.getSource() != null) { + trackingData.add(indent + location.getSource().getModelId() + " (implicit)"); indent += " "; - trackingData.add(indent + curr + " (" + collectStepTrace.getContext() + ")"); } - try { - Path trackingDir = - resolvedArtifact.getFile().getParentFile().toPath().resolve(".tracking"); - Files.createDirectories(trackingDir); - Path trackingFile = trackingDir.resolve(collectStepTrace + } else if (collectStepTrace != null) { + baseName = + collectStepTrace.getPath().get(0).getArtifact().toString().replace(":", "_"); Review Comment: Thanks for comment - I'll review on Monday. -- 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-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org