[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies
michael-o commented on code in PR #1058: URL: https://github.com/apache/maven/pull/1058#discussion_r1143278882 ## 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 trackingData = new ArrayList<>(); -trackingData.add(node + " (" + collectStepTrace.getContext() + ")"); -String indent = ""; -ListIterator 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 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: @grgrzybek, please file an issue regarding the separator. -- 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:
[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies
michael-o commented on code in PR #1058: URL: https://github.com/apache/maven/pull/1058#discussion_r1143278548 ## 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 trackingData = new ArrayList<>(); -trackingData.add(node + " (" + collectStepTrace.getContext() + ")"); -String indent = ""; -ListIterator 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 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: Yes, that is not (yet) flexible, use a `replace()` for now. -- 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
[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies
michael-o commented on code in PR #1058: URL: https://github.com/apache/maven/pull/1058#discussion_r1143265427 ## 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 trackingData = new ArrayList<>(); -trackingData.add(node + " (" + collectStepTrace.getContext() + ")"); -String indent = ""; -ListIterator 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 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: Correct, meant this one and wasn't able to register. Then the colon can be exchanges for a tilde. -- 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 se
[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies
michael-o commented on code in PR #1058: URL: https://github.com/apache/maven/pull/1058#discussion_r1142610436 ## 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 trackingData = new ArrayList<>(); -trackingData.add(node + " (" + collectStepTrace.getContext() + ")"); -String indent = ""; -ListIterator 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 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: Please see org.eclipse.aether.internal.impl.synccontext.named.GAVNameMapper.fileGav() -- 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, pleas
[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies
michael-o commented on code in PR #1058: URL: https://github.com/apache/maven/pull/1058#discussion_r1140319956 ## 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 trackingData = new ArrayList<>(); -trackingData.add(node + " (" + collectStepTrace.getContext() + ")"); -String indent = ""; -ListIterator 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 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: There is a generic to ID function, I would rather prefer that. -- 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