You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "grgrzybek (via GitHub)" <gi...@apache.org> on 2023/03/16 10:48:51 UTC

[GitHub] [maven] grgrzybek opened a new pull request, #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

grgrzybek opened a new pull request, #1058:
URL: https://github.com/apache/maven/pull/1058

   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed
          for the change (usually before you start working on it).  Trivial changes like typos do not
          require a JIRA issue. Your pull request should address just this issue, without
          pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[MNG-XXX] SUMMARY`,
          where you replace `MNG-XXX` and `SUMMARY` with the appropriate JIRA issue.
    - [ ] Also format the first line of the commit message like `[MNG-XXX] SUMMARY`.
          Best practice is to use the JIRA issue title in both the pull request title and in the first line of the commit message.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
          be performed on your pull request automatically.
    - [ ] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
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] cstamas commented on pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1058:
URL: https://github.com/apache/maven/pull/1058#issuecomment-1505033221

   @michael-o anything to fix here? Good to merge?


-- 
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] cstamas merged pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #1058:
URL: https://github.com/apache/maven/pull/1058


-- 
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] grgrzybek commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "grgrzybek (via GitHub)" <gi...@apache.org>.
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-unsubscribe@maven.apache.org

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


[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
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<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:
   @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-unsubscribe@maven.apache.org

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


[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
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<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:
   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-unsubscribe@maven.apache.org

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


[GitHub] [maven] cstamas commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #1058:
URL: https://github.com/apache/maven/pull/1058#discussion_r1143248770


##########
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:
   https://github.com/apache/maven-resolver/blob/master/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java#L28 maybe?



-- 
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] grgrzybek commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "grgrzybek (via GitHub)" <gi...@apache.org>.
grgrzybek commented on code in PR #1058:
URL: https://github.com/apache/maven/pull/1058#discussion_r1143267697


##########
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:
   And `ArtifactIdUtils` uses `SEP = ':'` anyway... I want `_`.



-- 
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] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
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<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:
   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-unsubscribe@maven.apache.org

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


[GitHub] [maven] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
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<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:
   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-unsubscribe@maven.apache.org

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


[GitHub] [maven] grgrzybek commented on pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "grgrzybek (via GitHub)" <gi...@apache.org>.
grgrzybek commented on PR #1058:
URL: https://github.com/apache/maven/pull/1058#issuecomment-1505089530

   Thanks!
   
   I was skeptical about `org.eclipse.aether.internal.impl.synccontext.named.GAVNameMapper.fileGav()` and tilde (`~`) wasn't mentioned before... And indeed it's only a tracking file name. Anyway - thanks for understanding.


-- 
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] michael-o commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
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<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:
   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-unsubscribe@maven.apache.org

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


[GitHub] [maven] grgrzybek commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "grgrzybek (via GitHub)" <gi...@apache.org>.
grgrzybek commented on code in PR #1058:
URL: https://github.com/apache/maven/pull/1058#discussion_r1141759571


##########
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:
   @michael-o after quick look ... can you point me to the right "to ID function"?



-- 
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] grgrzybek commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "grgrzybek (via GitHub)" <gi...@apache.org>.
grgrzybek commented on code in PR #1058:
URL: https://github.com/apache/maven/pull/1058#discussion_r1142976951


##########
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:
   Hmm, `org.eclipse.aether.artifact.AbstractArtifact#toString()` also uses extension and classifier, but `org.eclipse.aether.internal.impl.synccontext.named.GAVNameMapper#getArtifactName()` does not (and it's private, but using `nameLocks()` sounds like mixing concepts here - I don't deal with locks...)
   
   Is there any other sanitizing method?



-- 
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] cstamas commented on pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1058:
URL: https://github.com/apache/maven/pull/1058#issuecomment-1505091856

   Yes, moreover, the tilde originates from Takari Shared Local Repo as initially we tried to create "compatible" file locking, but gave up as Takari implementation had issues, but the tilde somehow remained in out codebase, but again, is really irrelevant. Personally, as these files are for human consumption, underscore makes much more sense (would make even for locking, but this is what it is).


-- 
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] cstamas commented on pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1058:
URL: https://github.com/apache/maven/pull/1058#issuecomment-1505066814

   IMHO this is irrelevant, the info gathered here is really just a "verbose log-like" output for human consumption, nothing produced here is to be reused by any code... so IMHO forcing some "we did it before" is really not needed.


-- 
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] grgrzybek commented on a diff in pull request #1058: [MNG-7741] Track missing files, plugin and parent pom dependencies

Posted by "grgrzybek (via GitHub)" <gi...@apache.org>.
grgrzybek commented on code in PR #1058:
URL: https://github.com/apache/maven/pull/1058#discussion_r1143265861


##########
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, checking.
   However current it's just toString + replace: https://github.com/apache/maven/blob/maven-3.9.1/maven-core/src/main/java/org/apache/maven/internal/aether/ReverseTreeRepositoryListener.java#L81-L86



-- 
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