You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/06/01 12:24:48 UTC

[GitHub] [maven-dependency-plugin] elharo commented on a change in pull request #135: [MDEP-568] go offline filter

elharo commented on a change in pull request #135:
URL: https://github.com/apache/maven-dependency-plugin/pull/135#discussion_r643041054



##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java
##########
@@ -0,0 +1,59 @@
+package org.apache.maven.plugins.dependency.filters;

Review comment:
       Is this introducing a new package? Probably not needed. 

##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java
##########
@@ -0,0 +1,59 @@
+package org.apache.maven.plugins.dependency.filters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+    public boolean isDependencyIncluded( Dependency dependency )

Review comment:
       Use `@Override` where appropriate

##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/ClassifierFilter.java
##########
@@ -0,0 +1,98 @@
+package org.apache.maven.plugins.dependency.filters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Filters dependencies by Classifier.

Review comment:
       classifier (lower case)

##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/FilterDependencies.java
##########
@@ -0,0 +1,91 @@
+package org.apache.maven.plugins.dependency.filters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.unmodifiableList;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Applies null to any number of filters to a given collection of dependencies.

Review comment:
       I can't quite parse this comment.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/FilterDependencies.java
##########
@@ -0,0 +1,91 @@
+package org.apache.maven.plugins.dependency.filters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.unmodifiableList;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Applies null to any number of filters to a given collection of dependencies.
+ */
+public class FilterDependencies
+{
+
+    private final List<DependencyFilter> filters;
+
+    /**
+     * Created new instance.
+     */
+    public FilterDependencies( DependencyFilter... filters )
+    {
+        this.filters = unmodifiableList( asList( filters ) );
+    }
+
+    /**
+     * <p>filter.</p>
+     *
+     * @param dependencies The {@link Dependency}s to filter.
+     * @return The resulting artifacts set.
+     */
+    public Set<Dependency> filter( Collection<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        for ( DependencyFilter filter : filters )
+        {
+            try
+            {
+                filtered = filter.filter( filtered );
+            }
+            catch ( NullPointerException e )
+            {
+                // TODO: log

Review comment:
       what an NPE here imply? why not let it bubble up?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/GroupIdFilter.java
##########
@@ -0,0 +1,98 @@
+package org.apache.maven.plugins.dependency.filters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Filters dependencies by GroupId.

Review comment:
       group ID.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java
##########
@@ -0,0 +1,59 @@
+package org.apache.maven.plugins.dependency.filters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+    public boolean isDependencyIncluded( Dependency dependency )
+    {
+        Set<Dependency> set = new LinkedHashSet<>();
+        set.add( dependency );
+
+        set = filter( set );
+        return set.contains( dependency );

Review comment:
       It feels like this could be done more directly without creating a new set.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java
##########
@@ -0,0 +1,59 @@
+package org.apache.maven.plugins.dependency.filters;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+    public boolean isDependencyIncluded( Dependency dependency )
+    {
+        Set<Dependency> set = new LinkedHashSet<>();
+        set.add( dependency );
+
+        set = filter( set );
+        return set.contains( dependency );
+    }
+
+    protected Set<String> splitValues( String csvScopeList )
+    {
+        final String[] scopes = csvScopeList.split( "," );
+        Set<String> excludeScope = new HashSet<>();
+
+        for ( String scope : scopes )
+        {
+            final String cleanScope = scope.trim().toLowerCase( Locale.ROOT );

Review comment:
       Interesting. What does Locale.ROOT imply for the lowercasing?




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

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