[ 
https://issues.apache.org/jira/browse/MRESOLVER-494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816638#comment-17816638
 ] 

ASF GitHub Bot commented on MRESOLVER-494:
------------------------------------------

gnodet commented on code in PR #428:
URL: https://github.com/apache/maven-resolver/pull/428#discussion_r1486318353


##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java:
##########
@@ -199,25 +199,27 @@ public DependencyManagement manageDependency(Dependency 
dependency) {
                 }
                 management.setScope(scope);
 
-                if (!systemScopePredicate.test(scope)
-                        && 
dependency.getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null) != 
null) {
+                if (!systemScopeHandler.isSystemScope(scope)
+                        && systemScopeHandler.getSystemPath(
+                                        
dependency.getArtifact().getProperties())
+                                != null) {
                     Map<String, String> properties =
                             new 
HashMap<>(dependency.getArtifact().getProperties());
-                    properties.remove(ArtifactProperties.LOCAL_PATH);
+                    systemScopeHandler.setSystemPath(properties, null);

Review Comment:
   I fail to see how this code is relevant. 
   If this is really needed ? that would mean that the scope isn't solely 
determined by the `dependency.getScope()`.



##########
maven-resolver-api/src/main/java/org/eclipse/aether/SystemScopeHandler.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether;
+
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * In Resolver 1.x line, the "system" scope represented special artifacts. In 
2.x resolver testing for this scope
+ * is now delegated to consumer application. Class or component that wants to 
test for this special dependency scope
+ * should use this interface, with implementation provided by consumer 
application.
+ * <p>
+ * System is a special scope that tells resolver that dependency is not to be 
found in any regular repository, so it
+ * should not even try to resolve the artifact from them. Dependency in this 
scope does not have artifact descriptor
+ * either. Artifacts in this scope should have the "local path" property set, 
pointing to a file on local system, where
+ * the backing file should reside. Resolution of artifacts in this scope 
fails, if backing file does not exist
+ * (no property set, or property contains invalid path, or the path points to 
a non-existent file).
+ *
+ * @since 2.0.0
+ */
+public interface SystemScopeHandler {
+    /**
+     * Returns {@code true} if given scope label is "system" scope.
+     */
+    boolean isSystemScope(String scope);
+
+    /**
+     * Returns {@code true} if given dependency is in "system" scope.
+     */
+    default boolean isSystemScope(Dependency dependency) {
+        return isSystemScope(dependency.getScope());
+    }
+
+    /**
+     * Returns {@code true} if given dependency node dependency is in "system" 
scope.
+     */
+    default boolean isSystemScope(DependencyNode dependencyNode) {
+        return dependencyNode.getDependency() != null && 
isSystemScope(dependencyNode.getDependency());

Review Comment:
   `dependencyNode` may be null here too



##########
maven-resolver-api/src/main/java/org/eclipse/aether/SystemScopeHandler.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether;
+
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * In Resolver 1.x line, the "system" scope represented special artifacts. In 
2.x resolver testing for this scope
+ * is now delegated to consumer application. Class or component that wants to 
test for this special dependency scope
+ * should use this interface, with implementation provided by consumer 
application.
+ * <p>
+ * System is a special scope that tells resolver that dependency is not to be 
found in any regular repository, so it
+ * should not even try to resolve the artifact from them. Dependency in this 
scope does not have artifact descriptor
+ * either. Artifacts in this scope should have the "local path" property set, 
pointing to a file on local system, where
+ * the backing file should reside. Resolution of artifacts in this scope 
fails, if backing file does not exist
+ * (no property set, or property contains invalid path, or the path points to 
a non-existent file).
+ *
+ * @since 2.0.0
+ */
+public interface SystemScopeHandler {
+    /**
+     * Returns {@code true} if given scope label is "system" scope.
+     */
+    boolean isSystemScope(String scope);
+
+    /**
+     * Returns {@code true} if given dependency is in "system" scope.
+     */
+    default boolean isSystemScope(Dependency dependency) {
+        return isSystemScope(dependency.getScope());
+    }
+
+    /**
+     * Returns {@code true} if given dependency node dependency is in "system" 
scope.
+     */
+    default boolean isSystemScope(DependencyNode dependencyNode) {
+        return dependencyNode.getDependency() != null && 
isSystemScope(dependencyNode.getDependency());
+    }
+
+    /**
+     * Returns system path string of provided artifact, or {@code null}.
+     *
+     * @return the system path from passed in properties, or {@code null} if 
not present.
+     */
+    String getSystemPath(Map<String, String> properties);

Review Comment:
   I wonder if we should abstract slightly more and have:
   ```
   String getSystemPath(Artifact artifact);
   ```



##########
maven-resolver-api/src/main/java/org/eclipse/aether/SystemScopeHandler.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether;
+
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * In Resolver 1.x line, the "system" scope represented special artifacts. In 
2.x resolver testing for this scope
+ * is now delegated to consumer application. Class or component that wants to 
test for this special dependency scope
+ * should use this interface, with implementation provided by consumer 
application.
+ * <p>
+ * System is a special scope that tells resolver that dependency is not to be 
found in any regular repository, so it
+ * should not even try to resolve the artifact from them. Dependency in this 
scope does not have artifact descriptor
+ * either. Artifacts in this scope should have the "local path" property set, 
pointing to a file on local system, where
+ * the backing file should reside. Resolution of artifacts in this scope 
fails, if backing file does not exist
+ * (no property set, or property contains invalid path, or the path points to 
a non-existent file).
+ *
+ * @since 2.0.0
+ */
+public interface SystemScopeHandler {
+    /**
+     * Returns {@code true} if given scope label is "system" scope.
+     */
+    boolean isSystemScope(String scope);
+
+    /**
+     * Returns {@code true} if given dependency is in "system" scope.
+     */
+    default boolean isSystemScope(Dependency dependency) {
+        return isSystemScope(dependency.getScope());
+    }
+
+    /**
+     * Returns {@code true} if given dependency node dependency is in "system" 
scope.
+     */
+    default boolean isSystemScope(DependencyNode dependencyNode) {
+        return dependencyNode.getDependency() != null && 
isSystemScope(dependencyNode.getDependency());
+    }
+
+    /**
+     * Returns system path string of provided artifact, or {@code null}.
+     *
+     * @return the system path from passed in properties, or {@code null} if 
not present.
+     */
+    String getSystemPath(Map<String, String> properties);
+
+    /**
+     * Sets system path in properties. The passed in {@code systemPath} can be 
{@code null}, in which case this is
+     * "remove" operation (or "unset").
+     */
+    void setSystemPath(Map<String, String> properties, String systemPath);

Review Comment:
   This method does not make much sense to me. It should not be needed, as the 
code calling the resolver is now responsible for the system scope.  The 
resolver should not alter what has been given.



##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java:
##########
@@ -199,25 +199,27 @@ public DependencyManagement manageDependency(Dependency 
dependency) {
                 }
                 management.setScope(scope);
 
-                if (!systemScopePredicate.test(scope)
-                        && 
dependency.getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null) != 
null) {
+                if (!systemScopeHandler.isSystemScope(scope)
+                        && systemScopeHandler.getSystemPath(
+                                        
dependency.getArtifact().getProperties())
+                                != null) {
                     Map<String, String> properties =
                             new 
HashMap<>(dependency.getArtifact().getProperties());
-                    properties.remove(ArtifactProperties.LOCAL_PATH);
+                    systemScopeHandler.setSystemPath(properties, null);
                     management.setProperties(properties);
                 }
             }
 
-            if ((systemScopePredicate.test(scope))
-                    || (scope == null && 
systemScopePredicate.test(dependency.getScope()))) {
+            if ((systemScopeHandler.isSystemScope(scope))
+                    || (scope == null && 
systemScopeHandler.isSystemScope(dependency.getScope()))) {
                 String localPath = managedLocalPaths.get(key);

Review Comment:
   The managedLocalPaths should be integrated into the systemScopeHandler imho.



##########
maven-resolver-api/src/main/java/org/eclipse/aether/SystemScopeHandler.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether;
+
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * In Resolver 1.x line, the "system" scope represented special artifacts. In 
2.x resolver testing for this scope
+ * is now delegated to consumer application. Class or component that wants to 
test for this special dependency scope
+ * should use this interface, with implementation provided by consumer 
application.
+ * <p>
+ * System is a special scope that tells resolver that dependency is not to be 
found in any regular repository, so it
+ * should not even try to resolve the artifact from them. Dependency in this 
scope does not have artifact descriptor
+ * either. Artifacts in this scope should have the "local path" property set, 
pointing to a file on local system, where
+ * the backing file should reside. Resolution of artifacts in this scope 
fails, if backing file does not exist
+ * (no property set, or property contains invalid path, or the path points to 
a non-existent file).
+ *
+ * @since 2.0.0
+ */
+public interface SystemScopeHandler {
+    /**
+     * Returns {@code true} if given scope label is "system" scope.
+     */
+    boolean isSystemScope(String scope);

Review Comment:
   Is `scope` supposed to be nullable ? It seems the code is given `null`.  If 
that's really expected we should indicate that on the javadoc.



##########
maven-resolver-api/src/main/java/org/eclipse/aether/SystemScopeHandler.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether;
+
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * In Resolver 1.x line, the "system" scope represented special artifacts. In 
2.x resolver testing for this scope
+ * is now delegated to consumer application. Class or component that wants to 
test for this special dependency scope
+ * should use this interface, with implementation provided by consumer 
application.
+ * <p>
+ * System is a special scope that tells resolver that dependency is not to be 
found in any regular repository, so it
+ * should not even try to resolve the artifact from them. Dependency in this 
scope does not have artifact descriptor
+ * either. Artifacts in this scope should have the "local path" property set, 
pointing to a file on local system, where
+ * the backing file should reside. Resolution of artifacts in this scope 
fails, if backing file does not exist
+ * (no property set, or property contains invalid path, or the path points to 
a non-existent file).
+ *
+ * @since 2.0.0
+ */
+public interface SystemScopeHandler {
+    /**
+     * Returns {@code true} if given scope label is "system" scope.
+     */
+    boolean isSystemScope(String scope);
+
+    /**
+     * Returns {@code true} if given dependency is in "system" scope.
+     */
+    default boolean isSystemScope(Dependency dependency) {
+        return isSystemScope(dependency.getScope());

Review Comment:
   Is `dependency` nullable or not ?
   If yes, we should test for a null `dependency` and have:
   ```
       return dependency != null && isSystemScope(dependency.getScope());
   ```





> LOCAL_PATH Artifact property really belongs to "system" scope (or is at least 
> very related to it)
> -------------------------------------------------------------------------------------------------
>
>                 Key: MRESOLVER-494
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-494
>             Project: Maven Resolver
>          Issue Type: Improvement
>          Components: Resolver
>            Reporter: Tamas Cservenak
>            Assignee: Tamas Cservenak
>            Priority: Major
>             Fix For: 2.0.0-alpha-8, 2.0.0
>
>
> LOCAL_PATH Artifact property really belongs to "system" scope (or is at least 
> very related to it).
> It may need to be removed as well?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to