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 2022/10/31 12:32:33 UTC

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

elharo commented on code in PR #135:
URL: https://github.com/apache/maven-dependency-plugin/pull/135#discussion_r1009346626


##########
src/it/projects/mdep-568-go-offline-exclude/pom.xml:
##########
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   Why all the tildes in the license?



##########
src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java:
##########
@@ -0,0 +1,130 @@
+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 org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+
+    protected final String includeIds;
+    protected final String excludeIds;
+
+    AbstractDependencyFilter( String includeIds, String excludeIds )
+    {
+        this.includeIds = includeIds == null ? "" : includeIds;
+        this.excludeIds = excludeIds == null ? "" : excludeIds;
+    }
+
+
+    @Override
+    public Set<Dependency> filter( Set<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        filtered = filterincludeIds( filtered );
+        filtered = filterexcludeIds( filtered );
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterexcludeIds( Set<Dependency> dependencies )

Review Comment:
   filterExcludeIds



##########
src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java:
##########
@@ -0,0 +1,130 @@
+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 org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+
+    protected final String includeIds;
+    protected final String excludeIds;
+
+    AbstractDependencyFilter( String includeIds, String excludeIds )
+    {
+        this.includeIds = includeIds == null ? "" : includeIds;
+        this.excludeIds = excludeIds == null ? "" : excludeIds;
+    }
+
+
+    @Override
+    public Set<Dependency> filter( Set<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        filtered = filterincludeIds( filtered );
+        filtered = filterexcludeIds( filtered );
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterexcludeIds( Set<Dependency> dependencies )
+    {
+        if ( excludeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        final Set<String> excludedIds = splitExcludeIds( excludeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( excludedIds.contains( getContainsProperty( dependency ) ) )
+            {
+                continue;
+            }
+
+            filtered.add( dependency );
+        }
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterincludeIds( Set<Dependency> dependencies )

Review Comment:
   filterIncludeIds



##########
src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java:
##########
@@ -0,0 +1,130 @@
+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 org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+
+    protected final String includeIds;
+    protected final String excludeIds;
+
+    AbstractDependencyFilter( String includeIds, String excludeIds )
+    {
+        this.includeIds = includeIds == null ? "" : includeIds;
+        this.excludeIds = excludeIds == null ? "" : excludeIds;
+    }
+
+
+    @Override
+    public Set<Dependency> filter( Set<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        filtered = filterincludeIds( filtered );
+        filtered = filterexcludeIds( filtered );
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterexcludeIds( Set<Dependency> dependencies )
+    {
+        if ( excludeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        final Set<String> excludedIds = splitExcludeIds( excludeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( excludedIds.contains( getContainsProperty( dependency ) ) )
+            {
+                continue;
+            }
+
+            filtered.add( dependency );
+        }
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterincludeIds( Set<Dependency> dependencies )
+    {
+        if ( includeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        Set<String> includedIds = splitIncludeIds( includeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( includedIds.contains( getContainsProperty( dependency ) ) )

Review Comment:
   ditto



##########
src/main/java/org/apache/maven/plugins/dependency/filters/DependencyFilter.java:
##########
@@ -0,0 +1,37 @@
+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.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Dependencies filter. Used to filter dependencies by one or more of their properties.
+ */
+public interface DependencyFilter
+{
+    /**
+     * Filters the given dependencies and returns a new unmodifiable set of filtered dependencies.

Review Comment:
   Interface can't really guarantee that the set returned is unmodifiable. Maybe it is, maybe it isn't. 



##########
src/main/java/org/apache/maven/plugins/dependency/filters/FilterDependencies.java:
##########
@@ -0,0 +1,85 @@
+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 static java.util.Collections.unmodifiableSet;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Applies a given list of filters to a given collection of dependencies.

Review Comment:
   delete given



##########
src/main/java/org/apache/maven/plugins/dependency/filters/FilterDependencies.java:
##########
@@ -0,0 +1,85 @@
+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 static java.util.Collections.unmodifiableSet;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Applies a given list 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 ) );
+    }
+
+    /**
+     * Filter the given dependencies using the filters from this instance.
+     *
+     * @param dependencies The {@link Dependency}s to filter.
+     * @return the remaining dependencies as unmodifiable set.
+     */
+    public Set<Dependency> filter( Collection<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        for ( DependencyFilter filter : filters )
+        {
+            filtered = filter.filter( filtered );
+        }
+
+        return unmodifiableSet( filtered );
+    }
+
+    /**
+     * <p>Getter for the field <code>filters</code>.</p>

Review Comment:
   Less general and without reference to internal implementation details



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )
+    {
+        super( includeScope, excludeScope );
+    }
+
+    @Override
+    protected String getContainsProperty( Dependency dependency )
+    {
+        return dependency.getScope();
+    }
+
+    /*
+     * runtime exclude scope excludes runtime and compile dependencies,

Review Comment:
   Format this as list for HTML outpu



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )
+    {
+        super( includeScope, excludeScope );
+    }
+
+    @Override
+    protected String getContainsProperty( Dependency dependency )
+    {
+        return dependency.getScope();
+    }
+
+    /*
+     * runtime exclude scope excludes runtime and compile dependencies,
+     * compile exclude scope excludes compile, provided, and system dependencies,
+     * test exclude scope excludes all dependencies, then not really a legitimate option: it will
+     * fail, you probably meant to configure includeScope = compile
+     * provided exclude scope just excludes provided dependencies,
+     * system exclude scope just excludes system dependencies.
+     * @param scope to be excluded
+     * @return Set with excluded scopes
+     */
+    @Override
+    protected Set<String> splitExcludeIds( String scope )
+    {
+        switch ( scope )
+        {
+            case Artifact.SCOPE_RUNTIME:
+                return new HashSet<>( asList(
+                        Artifact.SCOPE_RUNTIME,
+                        Artifact.SCOPE_COMPILE ) );
+            case Artifact.SCOPE_COMPILE:
+                return new HashSet<>( asList(
+                        Artifact.SCOPE_COMPILE,
+                        Artifact.SCOPE_PROVIDED,
+                        Artifact.SCOPE_SYSTEM ) );
+            case Artifact.SCOPE_TEST:
+                throw new IllegalArgumentException( "invalid exclude scope: test. Did you mean compile?" );

Review Comment:
   why is this invalid?



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )
+    {
+        super( includeScope, excludeScope );
+    }
+
+    @Override
+    protected String getContainsProperty( Dependency dependency )
+    {
+        return dependency.getScope();
+    }
+
+    /*
+     * runtime exclude scope excludes runtime and compile dependencies,
+     * compile exclude scope excludes compile, provided, and system dependencies,
+     * test exclude scope excludes all dependencies, then not really a legitimate option: it will
+     * fail, you probably meant to configure includeScope = compile
+     * provided exclude scope just excludes provided dependencies,
+     * system exclude scope just excludes system dependencies.
+     * @param scope to be excluded
+     * @return Set with excluded scopes
+     */
+    @Override
+    protected Set<String> splitExcludeIds( String scope )
+    {
+        switch ( scope )
+        {
+            case Artifact.SCOPE_RUNTIME:
+                return new HashSet<>( asList(
+                        Artifact.SCOPE_RUNTIME,
+                        Artifact.SCOPE_COMPILE ) );
+            case Artifact.SCOPE_COMPILE:
+                return new HashSet<>( asList(
+                        Artifact.SCOPE_COMPILE,
+                        Artifact.SCOPE_PROVIDED,
+                        Artifact.SCOPE_SYSTEM ) );
+            case Artifact.SCOPE_TEST:
+                throw new IllegalArgumentException( "invalid exclude scope: test. Did you mean compile?" );
+            case Artifact.SCOPE_PROVIDED:
+                return new HashSet<>( singletonList( Artifact.SCOPE_PROVIDED ) );
+            case Artifact.SCOPE_SYSTEM:
+                return new HashSet<>( singletonList( Artifact.SCOPE_SYSTEM ) );
+            default:
+                throw new IllegalArgumentException( "Invalid Scope: " + scope );
+        }
+    }
+
+    /**
+     * runtime include scope gives runtime and compile dependencies,
+     * compile include scope gives compile, provided, and system dependencies,
+     * test include scope gives all dependencies (equivalent to default),
+     * provided include scope just gives provided dependencies,

Review Comment:
   remove just



##########
src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java:
##########
@@ -0,0 +1,130 @@
+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 org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+
+    protected final String includeIds;
+    protected final String excludeIds;
+
+    AbstractDependencyFilter( String includeIds, String excludeIds )
+    {
+        this.includeIds = includeIds == null ? "" : includeIds;
+        this.excludeIds = excludeIds == null ? "" : excludeIds;
+    }
+
+
+    @Override
+    public Set<Dependency> filter( Set<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        filtered = filterincludeIds( filtered );
+        filtered = filterexcludeIds( filtered );
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterexcludeIds( Set<Dependency> dependencies )
+    {
+        if ( excludeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        final Set<String> excludedIds = splitExcludeIds( excludeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( excludedIds.contains( getContainsProperty( dependency ) ) )

Review Comment:
   This is a bit awkward. Might be worth adding a local variable, renaming, the method, and/or refactoring with a more complete method



##########
src/it/projects/mdep-568-go-offline-exclude/pom.xml:
##########
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.dependency</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Test</name>
+  <description>
+    Test dependency:go-offline
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.6</version>
+    </dependency>
+    <dependency>
+      <groupId>non.existant.group</groupId>

Review Comment:
   nit: existent with an e



##########
src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java:
##########
@@ -0,0 +1,130 @@
+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 org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+
+    protected final String includeIds;
+    protected final String excludeIds;
+
+    AbstractDependencyFilter( String includeIds, String excludeIds )
+    {
+        this.includeIds = includeIds == null ? "" : includeIds;
+        this.excludeIds = excludeIds == null ? "" : excludeIds;
+    }
+
+
+    @Override
+    public Set<Dependency> filter( Set<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        filtered = filterincludeIds( filtered );
+        filtered = filterexcludeIds( filtered );
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterexcludeIds( Set<Dependency> dependencies )
+    {
+        if ( excludeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        final Set<String> excludedIds = splitExcludeIds( excludeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( excludedIds.contains( getContainsProperty( dependency ) ) )
+            {
+                continue;
+            }
+
+            filtered.add( dependency );
+        }
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterincludeIds( Set<Dependency> dependencies )
+    {
+        if ( includeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        Set<String> includedIds = splitIncludeIds( includeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( includedIds.contains( getContainsProperty( dependency ) ) )
+            {
+                filtered.add( dependency );
+            }
+        }
+
+        return filtered;
+    }
+
+    protected Set<String> splitExcludeIds( String excludeIds )
+    {
+        return splitValues( excludeIds );
+    }
+
+    protected Set<String> splitIncludeIds( String includeIds )
+    {
+        return splitValues( includeIds );
+    }
+
+    protected Set<String> splitValues( String csvValueList )
+    {
+        final String[] values = csvValueList.split( "," );
+        Set<String> excludeScope = new HashSet<>();
+
+        for ( String value : values )

Review Comment:
   why is any case conversion necessary? Shouldn't this match including case?



##########
src/test/java/org/apache/maven/plugins/dependency/filters/ClassifierFilterTest.java:
##########
@@ -0,0 +1,74 @@
+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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Test;
+
+public class ClassifierFilterTest extends AbstractArtifactFilterTest
+{
+
+    @Test
+    public void testArtifactFilterExclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;

Review Comment:
   local variables seem redundant here



##########
src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java:
##########
@@ -0,0 +1,130 @@
+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 org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+
+    protected final String includeIds;
+    protected final String excludeIds;
+
+    AbstractDependencyFilter( String includeIds, String excludeIds )
+    {
+        this.includeIds = includeIds == null ? "" : includeIds;
+        this.excludeIds = excludeIds == null ? "" : excludeIds;
+    }
+
+
+    @Override
+    public Set<Dependency> filter( Set<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        filtered = filterincludeIds( filtered );
+        filtered = filterexcludeIds( filtered );
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterexcludeIds( Set<Dependency> dependencies )
+    {
+        if ( excludeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        final Set<String> excludedIds = splitExcludeIds( excludeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( excludedIds.contains( getContainsProperty( dependency ) ) )
+            {
+                continue;
+            }
+
+            filtered.add( dependency );
+        }
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterincludeIds( Set<Dependency> dependencies )
+    {
+        if ( includeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        Set<String> includedIds = splitIncludeIds( includeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( includedIds.contains( getContainsProperty( dependency ) ) )
+            {
+                filtered.add( dependency );
+            }
+        }
+
+        return filtered;
+    }
+
+    protected Set<String> splitExcludeIds( String excludeIds )
+    {
+        return splitValues( excludeIds );
+    }
+
+    protected Set<String> splitIncludeIds( String includeIds )
+    {
+        return splitValues( includeIds );
+    }
+
+    protected Set<String> splitValues( String csvValueList )
+    {
+        final String[] values = csvValueList.split( "," );
+        Set<String> excludeScope = new HashSet<>();
+
+        for ( String value : values )
+        {
+            // value is expected to be a scope, classifier, etc.
+            // thus assuming an english word. Do not rely on Locale.getDefault()!
+            final String cleanScope = value.trim().toLowerCase( Locale.ENGLISH );
+
+            if ( cleanScope.isEmpty() )
+            {
+                continue;

Review Comment:
   avoid continue



##########
src/main/java/org/apache/maven/plugins/dependency/filters/AbstractDependencyFilter.java:
##########
@@ -0,0 +1,130 @@
+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 org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+
+abstract class AbstractDependencyFilter implements DependencyFilter
+{
+
+    protected final String includeIds;
+    protected final String excludeIds;
+
+    AbstractDependencyFilter( String includeIds, String excludeIds )
+    {
+        this.includeIds = includeIds == null ? "" : includeIds;
+        this.excludeIds = excludeIds == null ? "" : excludeIds;
+    }
+
+
+    @Override
+    public Set<Dependency> filter( Set<Dependency> dependencies )
+    {
+        Set<Dependency> filtered = new HashSet<>( dependencies );
+
+        filtered = filterincludeIds( filtered );
+        filtered = filterexcludeIds( filtered );
+
+        return filtered;
+    }
+
+    private Set<Dependency> filterexcludeIds( Set<Dependency> dependencies )
+    {
+        if ( excludeIds.trim().isEmpty() )
+        {
+            return dependencies;
+        }
+
+        final Set<String> excludedIds = splitExcludeIds( excludeIds );
+
+        Set<Dependency> filtered = new HashSet<>( dependencies.size() );
+        for ( Dependency dependency : dependencies )
+        {
+            if ( excludedIds.contains( getContainsProperty( dependency ) ) )
+            {
+                continue;

Review Comment:
   don't use continue; just change the if to if not



##########
src/main/java/org/apache/maven/plugins/dependency/filters/TypeFilter.java:
##########
@@ -0,0 +1,39 @@
+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 org.apache.maven.model.Dependency;
+
+/**
+ * Filters dependencies by type.
+ */
+public class TypeFilter extends AbstractDependencyFilter
+{
+    public TypeFilter( String includeTypes, String excludeTypes )

Review Comment:
   api doc



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ArtifactIdFilter.java:
##########
@@ -0,0 +1,39 @@
+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 org.apache.maven.model.Dependency;
+
+/**
+ * Filters dependencies by artifact ID.
+ */
+public class ArtifactIdFilter extends AbstractDependencyFilter
+{
+    public ArtifactIdFilter( String includeArtifactIds, String excludeArtifactIds )

Review Comment:
   needs API doc



##########
src/test/java/org/apache/maven/plugins/dependency/filters/ArtifactIdFilterTest.java:
##########
@@ -0,0 +1,69 @@
+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.Collections.singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Test;
+
+public class ArtifactIdFilterTest extends AbstractArtifactFilterTest
+{
+
+    @Test
+    public void testArtifactFilterExclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;
+        final ArtifactIdFilter tools = new ArtifactIdFilter( "", comSunTools.getArtifactId() );
+
+        // when:
+        final Set<Dependency> filtered = tools.filter( singleton( comSunTools ) );
+
+        // then:
+        assertTrue( filtered.isEmpty() );
+    }
+
+
+    @Test
+    public void testArtifactFilterInclude()
+    {
+        // given

Review Comment:
   local variables seem redundant here



##########
src/main/java/org/apache/maven/plugins/dependency/filters/FilterDependencies.java:
##########
@@ -0,0 +1,85 @@
+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 static java.util.Collections.unmodifiableSet;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Applies a given list 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 ) );
+    }
+
+    /**
+     * Filter the given dependencies using the filters from this instance.
+     *
+     * @param dependencies The {@link Dependency}s to filter.

Review Comment:
   no period;
   also dependencies



##########
src/main/java/org/apache/maven/plugins/dependency/filters/FilterDependencies.java:
##########
@@ -0,0 +1,85 @@
+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 static java.util.Collections.unmodifiableSet;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Applies a given list 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 ) );
+    }
+
+    /**
+     * Filter the given dependencies using the filters from this instance.
+     *
+     * @param dependencies The {@link Dependency}s to filter.
+     * @return the remaining dependencies as unmodifiable set.

Review Comment:
   no period



##########
src/main/java/org/apache/maven/plugins/dependency/filters/DependencyFilter.java:
##########
@@ -0,0 +1,37 @@
+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.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Dependencies filter. Used to filter dependencies by one or more of their properties.
+ */
+public interface DependencyFilter
+{
+    /**
+     * Filters the given dependencies and returns a new unmodifiable set of filtered dependencies.
+     * @param dependencies the dependencies to filter.

Review Comment:
   nit: no period, per Oracle Javadoc guidelines as this is not a complete sentence



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ClassifierFilter.java:
##########
@@ -0,0 +1,41 @@
+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 org.apache.maven.model.Dependency;
+
+/**
+ * Filters dependencies by classifier.
+ */
+public class ClassifierFilter extends AbstractDependencyFilter
+{
+
+    public ClassifierFilter( String includeClassifiers, String excludeClassifiers )

Review Comment:
   needs API doc



##########
src/main/java/org/apache/maven/plugins/dependency/filters/GroupIdFilter.java:
##########
@@ -0,0 +1,39 @@
+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 org.apache.maven.model.Dependency;
+
+/**
+ * Filters dependencies by group ID.
+ */
+public class GroupIdFilter extends AbstractDependencyFilter
+{
+    public GroupIdFilter( String includeGroupIds, String excludeGroupIds )

Review Comment:
   javadoc



##########
src/main/java/org/apache/maven/plugins/dependency/filters/FilterDependencies.java:
##########
@@ -0,0 +1,85 @@
+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 static java.util.Collections.unmodifiableSet;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Applies a given list of filters to a given collection of dependencies.
+ */
+public class FilterDependencies
+{
+
+    private final List<DependencyFilter> filters;
+
+    /**
+     * Created new instance.

Review Comment:
   Less general doc comment needed



##########
src/main/java/org/apache/maven/plugins/dependency/filters/DependencyFilter.java:
##########
@@ -0,0 +1,37 @@
+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.Set;
+
+import org.apache.maven.model.Dependency;
+
+/**
+ * Dependencies filter. Used to filter dependencies by one or more of their properties.
+ */
+public interface DependencyFilter
+{
+    /**
+     * Filters the given dependencies and returns a new unmodifiable set of filtered dependencies.
+     * @param dependencies the dependencies to filter.
+     * @return the filtered dependencies.

Review Comment:
   no period



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )
+    {
+        super( includeScope, excludeScope );
+    }
+
+    @Override
+    protected String getContainsProperty( Dependency dependency )
+    {
+        return dependency.getScope();
+    }
+
+    /*
+     * runtime exclude scope excludes runtime and compile dependencies,
+     * compile exclude scope excludes compile, provided, and system dependencies,
+     * test exclude scope excludes all dependencies, then not really a legitimate option: it will
+     * fail, you probably meant to configure includeScope = compile
+     * provided exclude scope just excludes provided dependencies,
+     * system exclude scope just excludes system dependencies.
+     * @param scope to be excluded
+     * @return Set with excluded scopes

Review Comment:
   set



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )
+    {
+        super( includeScope, excludeScope );
+    }
+
+    @Override
+    protected String getContainsProperty( Dependency dependency )
+    {
+        return dependency.getScope();
+    }
+
+    /*
+     * runtime exclude scope excludes runtime and compile dependencies,
+     * compile exclude scope excludes compile, provided, and system dependencies,
+     * test exclude scope excludes all dependencies, then not really a legitimate option: it will
+     * fail, you probably meant to configure includeScope = compile
+     * provided exclude scope just excludes provided dependencies,

Review Comment:
   delete just



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )
+    {
+        super( includeScope, excludeScope );
+    }
+
+    @Override
+    protected String getContainsProperty( Dependency dependency )
+    {
+        return dependency.getScope();
+    }
+
+    /*
+     * runtime exclude scope excludes runtime and compile dependencies,
+     * compile exclude scope excludes compile, provided, and system dependencies,
+     * test exclude scope excludes all dependencies, then not really a legitimate option: it will
+     * fail, you probably meant to configure includeScope = compile
+     * provided exclude scope just excludes provided dependencies,
+     * system exclude scope just excludes system dependencies.

Review Comment:
   delete just



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )

Review Comment:
   javadoc



##########
src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java:
##########
@@ -207,4 +239,14 @@ protected ArtifactsFilter getMarkedArtifactFilter()
     {
         return null;
     }
+
+    /**
+     * Returns a read-only set of dependencies used for going offline.
+     * @return an immutable set of dependencies used for going offline.

Review Comment:
   blank line before return



##########
src/test/java/org/apache/maven/plugins/dependency/filters/ArtifactIdFilterTest.java:
##########
@@ -0,0 +1,69 @@
+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.Collections.singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Test;
+
+public class ArtifactIdFilterTest extends AbstractArtifactFilterTest
+{
+
+    @Test
+    public void testArtifactFilterExclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;

Review Comment:
   local variables seem redundant here



##########
src/main/java/org/apache/maven/plugins/dependency/filters/ScopeFilter.java:
##########
@@ -0,0 +1,122 @@
+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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+/**
+ * Filters dependencies by scope.
+ */
+public class ScopeFilter extends AbstractDependencyFilter
+{
+    public ScopeFilter( String includeScope, String excludeScope )
+    {
+        super( includeScope, excludeScope );
+    }
+
+    @Override
+    protected String getContainsProperty( Dependency dependency )
+    {
+        return dependency.getScope();
+    }
+
+    /*
+     * runtime exclude scope excludes runtime and compile dependencies,
+     * compile exclude scope excludes compile, provided, and system dependencies,
+     * test exclude scope excludes all dependencies, then not really a legitimate option: it will
+     * fail, you probably meant to configure includeScope = compile
+     * provided exclude scope just excludes provided dependencies,
+     * system exclude scope just excludes system dependencies.
+     * @param scope to be excluded
+     * @return Set with excluded scopes
+     */
+    @Override
+    protected Set<String> splitExcludeIds( String scope )
+    {
+        switch ( scope )
+        {
+            case Artifact.SCOPE_RUNTIME:
+                return new HashSet<>( asList(
+                        Artifact.SCOPE_RUNTIME,
+                        Artifact.SCOPE_COMPILE ) );
+            case Artifact.SCOPE_COMPILE:
+                return new HashSet<>( asList(
+                        Artifact.SCOPE_COMPILE,
+                        Artifact.SCOPE_PROVIDED,
+                        Artifact.SCOPE_SYSTEM ) );
+            case Artifact.SCOPE_TEST:
+                throw new IllegalArgumentException( "invalid exclude scope: test. Did you mean compile?" );
+            case Artifact.SCOPE_PROVIDED:
+                return new HashSet<>( singletonList( Artifact.SCOPE_PROVIDED ) );
+            case Artifact.SCOPE_SYSTEM:
+                return new HashSet<>( singletonList( Artifact.SCOPE_SYSTEM ) );
+            default:
+                throw new IllegalArgumentException( "Invalid Scope: " + scope );
+        }
+    }
+
+    /**
+     * runtime include scope gives runtime and compile dependencies,

Review Comment:
   Use HTML list or perhaps complete sentences. 



##########
src/test/java/org/apache/maven/plugins/dependency/filters/GroupIdFilterTest.java:
##########
@@ -0,0 +1,69 @@
+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.Collections.singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Test;
+
+public class GroupIdFilterTest extends AbstractArtifactFilterTest
+{
+
+    @Test
+    public void testGroupFilterExclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;
+        final GroupIdFilter tools = new GroupIdFilter( "", comSunTools.getGroupId() );
+
+        // when:
+        final Set<Dependency> filtered = tools.filter( singleton( comSunTools ) );
+
+        // then:
+        assertTrue( filtered.isEmpty() );
+    }
+
+
+    @Test
+    public void testGroupFilterInclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;

Review Comment:
   local variables seem redundant here



##########
src/test/java/org/apache/maven/plugins/dependency/filters/TypeFilterTest.java:
##########
@@ -0,0 +1,71 @@
+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.Collections.singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Test;
+
+public class TypeFilterTest extends AbstractArtifactFilterTest
+{
+
+    @Test
+    public void testTypeFilterExclude()
+    {
+        // given

Review Comment:
   local variables seem redundant here



##########
src/test/java/org/apache/maven/plugins/dependency/filters/ClassifierFilterTest.java:
##########
@@ -0,0 +1,74 @@
+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 org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Test;
+
+public class ClassifierFilterTest extends AbstractArtifactFilterTest
+{
+
+    @Test
+    public void testArtifactFilterExclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;
+        final Dependency mavenArtifactTests = MAVEN_ARTIFACT_TESTS_TEST_JAR;
+        final ClassifierFilter tools = new ClassifierFilter( "", mavenArtifactTests.getClassifier() );
+        final HashSet<Dependency> dependencies = new HashSet<>( 2 );
+        dependencies.add( comSunTools );
+        dependencies.add( mavenArtifactTests );
+
+        // when:
+        final Set<Dependency> filtered = tools.filter( dependencies );
+
+        // then:
+        assertEquals( 1, filtered.size() );
+        assertTrue( filtered.contains( comSunTools ) );
+    }
+
+
+    @Test
+    public void testArtifactFilterInclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;

Review Comment:
   local variables seem redundant here



##########
src/test/java/org/apache/maven/plugins/dependency/filters/ScopeFilterTest.java:
##########
@@ -0,0 +1,86 @@
+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.Collections.singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.model.Dependency;
+import org.junit.Test;
+
+public class ScopeFilterTest extends AbstractArtifactFilterTest
+{
+
+    @Test
+    public void testScopeFilterExclude()
+    {
+        // given
+        final Dependency comSunTools = COM_SUN_TOOLS_SYSTEM_JAR;

Review Comment:
   local variables seem redundant here



##########
src/test/java/org/apache/maven/plugins/dependency/resolvers/TestGoOfflineMojo.java:
##########
@@ -0,0 +1,105 @@
+package org.apache.maven.plugins.dependency.resolvers;
+
+/*
+ * 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.Collections.singletonList;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase;
+import org.apache.maven.plugins.dependency.utils.DependencyStatusSets;
+import org.apache.maven.project.MavenProject;
+
+public class TestGoOfflineMojo extends AbstractDependencyMojoTestCase
+{
+
+    protected void setUp() throws Exception

Review Comment:
   Override



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