You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2024/06/04 19:19:48 UTC
(maven-common-artifact-filters) branch parent-42-maven-3.6.3 updated (29aa1b5 -> 960fd03)
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a change to branch parent-42-maven-3.6.3
in repository https://gitbox.apache.org/repos/asf/maven-common-artifact-filters.git
discard 29aa1b5 [MSHARED-1301] Upgrade to Parent 42 and Maven 3.6.3
new 3aa2026 [MSHARED-1301] Upgrade to Parent 42 and Maven 3.6.3
new 960fd03 Ignore blame revs
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (29aa1b5)
\
N -- N -- N refs/heads/parent-42-maven-3.6.3 (960fd03)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.git-blame-ignore-revs | 1 +
pom.xml | 6 +-
.../AbstractStrictPatternArtifactFilter.java | 93 ++-
.../filter/PatternExcludesArtifactFilter.java | 34 +-
.../filter/PatternIncludesArtifactFilter.java | 617 ++++++++-----------
.../artifact/filter/ScopeArtifactFilter.java | 246 +++-----
.../filter/StatisticsReportingArtifactFilter.java | 11 +-
.../StrictPatternExcludesArtifactFilter.java | 14 +-
.../StrictPatternIncludesArtifactFilter.java | 14 +-
.../collection/AbstractArtifactFeatureFilter.java | 99 ++-
.../filter/collection/AbstractArtifactsFilter.java | 23 +-
.../filter/collection/ArtifactFilterException.java | 34 +-
.../filter/collection/ArtifactIdFilter.java | 22 +-
.../collection/ArtifactTransitivityFilter.java | 56 +-
.../filter/collection/ArtifactsFilter.java | 18 +-
.../filter/collection/ClassifierFilter.java | 21 +-
.../filter/collection/FilterArtifacts.java | 54 +-
.../artifact/filter/collection/GroupIdFilter.java | 27 +-
.../collection/ProjectTransitivityFilter.java | 43 +-
.../artifact/filter/collection/ScopeFilter.java | 130 ++--
.../artifact/filter/collection/TypeFilter.java | 19 +-
.../shared/artifact/filter/internal/Utils.java | 15 +-
.../artifact/filter/resolve/AbstractFilter.java | 15 +-
.../shared/artifact/filter/resolve/AndFilter.java | 23 +-
.../artifact/filter/resolve/ExclusionsFilter.java | 22 +-
.../artifact/filter/resolve/FilterTransformer.java | 22 +-
.../maven/shared/artifact/filter/resolve/Node.java | 9 +-
.../shared/artifact/filter/resolve/OrFilter.java | 25 +-
.../filter/resolve/PatternExclusionsFilter.java | 27 +-
.../filter/resolve/PatternInclusionsFilter.java | 27 +-
.../artifact/filter/resolve/ScopeFilter.java | 52 +-
.../filter/resolve/TransformableFilter.java | 10 +-
.../ArtifactIncludeFilterTransformer.java | 89 +--
.../resolve/transform/ArtifactIncludeNode.java | 38 +-
.../transform/EclipseAetherFilterTransformer.java | 120 ++--
.../resolve/transform/EclipseAetherNode.java | 55 +-
.../filter/AbstractPatternArtifactFilterTest.java | 631 +++++++++----------
.../AbstractStrictPatternArtifactFilterTest.java | 357 +++++------
.../filter/GNPatternIncludesArtifactFilter.java | 675 ++++++++-------------
.../filter/OldPatternIncludesArtifactFilter.java | 286 ++++-----
.../filter/PatternExcludesArtifactFilterTest.java | 21 +-
.../artifact/filter/PatternFilterPerfTest.java | 116 ++--
.../filter/PatternIncludesArtifactFilterTest.java | 20 +-
.../artifact/filter/ScopeArtifactFilterTest.java | 382 ++++++------
.../StrictPatternExcludesArtifactFilterTest.java | 21 +-
.../StrictPatternIncludesArtifactFilterTest.java | 16 +-
.../AbstractArtifactFeatureFilterTest.java | 98 ++-
.../filter/collection/TestArtifactFilter.java | 48 +-
.../filter/collection/TestClassifierFilter.java | 50 +-
.../filter/collection/TestFilterArtifacts.java | 117 ++--
.../filter/collection/TestGroupIdFilter.java | 100 ++-
.../collection/TestProjectTransitivityFilter.java | 65 +-
.../filter/collection/TestScopeFilter.java | 208 +++----
.../artifact/filter/collection/TestTypeFilter.java | 103 ++--
.../ArtifactIncludeFilterTransformerTest.java | 238 ++++----
.../resolve/transform/ArtifactIncludeNodeTest.java | 153 ++---
.../EclipseAetherFilterTransformerTest.java | 153 ++---
.../resolve/transform/EclipseAetherNodeTest.java | 153 +++--
58 files changed, 2512 insertions(+), 3630 deletions(-)
create mode 100644 .git-blame-ignore-revs
(maven-common-artifact-filters) 01/02: [MSHARED-1301] Upgrade to Parent 42 and Maven 3.6.3
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch parent-42-maven-3.6.3
in repository https://gitbox.apache.org/repos/asf/maven-common-artifact-filters.git
commit 3aa202665cc24b8ddb8e36029436ad6e3ec5529a
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Jun 4 20:49:04 2024 +0200
[MSHARED-1301] Upgrade to Parent 42 and Maven 3.6.3
This closes #36
---
pom.xml | 23 +-
.../AbstractStrictPatternArtifactFilter.java | 93 ++-
.../filter/PatternExcludesArtifactFilter.java | 34 +-
.../filter/PatternIncludesArtifactFilter.java | 617 ++++++++-----------
.../artifact/filter/ScopeArtifactFilter.java | 246 +++-----
.../filter/StatisticsReportingArtifactFilter.java | 11 +-
.../StrictPatternExcludesArtifactFilter.java | 14 +-
.../StrictPatternIncludesArtifactFilter.java | 14 +-
.../collection/AbstractArtifactFeatureFilter.java | 99 ++-
.../filter/collection/AbstractArtifactsFilter.java | 23 +-
.../filter/collection/ArtifactFilterException.java | 34 +-
.../filter/collection/ArtifactIdFilter.java | 22 +-
.../collection/ArtifactTransitivityFilter.java | 56 +-
.../filter/collection/ArtifactsFilter.java | 18 +-
.../filter/collection/ClassifierFilter.java | 21 +-
.../filter/collection/FilterArtifacts.java | 54 +-
.../artifact/filter/collection/GroupIdFilter.java | 27 +-
.../collection/ProjectTransitivityFilter.java | 43 +-
.../artifact/filter/collection/ScopeFilter.java | 130 ++--
.../artifact/filter/collection/TypeFilter.java | 19 +-
.../shared/artifact/filter/internal/Utils.java | 15 +-
.../artifact/filter/resolve/AbstractFilter.java | 15 +-
.../shared/artifact/filter/resolve/AndFilter.java | 23 +-
.../artifact/filter/resolve/ExclusionsFilter.java | 22 +-
.../artifact/filter/resolve/FilterTransformer.java | 22 +-
.../maven/shared/artifact/filter/resolve/Node.java | 9 +-
.../shared/artifact/filter/resolve/OrFilter.java | 25 +-
.../filter/resolve/PatternExclusionsFilter.java | 27 +-
.../filter/resolve/PatternInclusionsFilter.java | 27 +-
.../artifact/filter/resolve/ScopeFilter.java | 52 +-
.../filter/resolve/TransformableFilter.java | 10 +-
.../ArtifactIncludeFilterTransformer.java | 89 +--
.../resolve/transform/ArtifactIncludeNode.java | 38 +-
.../transform/EclipseAetherFilterTransformer.java | 120 ++--
.../resolve/transform/EclipseAetherNode.java | 55 +-
.../filter/AbstractPatternArtifactFilterTest.java | 631 +++++++++----------
.../AbstractStrictPatternArtifactFilterTest.java | 357 +++++------
.../filter/GNPatternIncludesArtifactFilter.java | 675 ++++++++-------------
.../filter/OldPatternIncludesArtifactFilter.java | 286 ++++-----
.../filter/PatternExcludesArtifactFilterTest.java | 21 +-
.../artifact/filter/PatternFilterPerfTest.java | 116 ++--
.../filter/PatternIncludesArtifactFilterTest.java | 20 +-
.../artifact/filter/ScopeArtifactFilterTest.java | 382 ++++++------
.../StrictPatternExcludesArtifactFilterTest.java | 21 +-
.../StrictPatternIncludesArtifactFilterTest.java | 16 +-
.../AbstractArtifactFeatureFilterTest.java | 98 ++-
.../filter/collection/TestArtifactFilter.java | 48 +-
.../filter/collection/TestClassifierFilter.java | 50 +-
.../filter/collection/TestFilterArtifacts.java | 117 ++--
.../filter/collection/TestGroupIdFilter.java | 100 ++-
.../collection/TestProjectTransitivityFilter.java | 65 +-
.../filter/collection/TestScopeFilter.java | 208 +++----
.../artifact/filter/collection/TestTypeFilter.java | 103 ++--
.../ArtifactIncludeFilterTransformerTest.java | 238 ++++----
.../resolve/transform/ArtifactIncludeNodeTest.java | 153 ++---
.../EclipseAetherFilterTransformerTest.java | 153 ++---
.../resolve/transform/EclipseAetherNodeTest.java | 153 +++--
57 files changed, 2519 insertions(+), 3639 deletions(-)
diff --git a/pom.xml b/pom.xml
index 709f678..8606ede 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
+<?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
@@ -21,9 +21,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>maven-shared-components</artifactId>
<groupId>org.apache.maven.shared</groupId>
- <version>37</version>
+ <artifactId>maven-shared-components</artifactId>
+ <version>42</version>
<relativePath />
</parent>
@@ -36,8 +36,8 @@
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-common-artifact-filters.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-common-artifact-filters.git</developerConnection>
- <url>https://github.com/apache/maven-common-artifact-filters/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/maven-common-artifact-filters/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>jira</system>
@@ -55,9 +55,9 @@
</distributionManagement>
<properties>
- <maven.version>3.2.5</maven.version>
<javaVersion>8</javaVersion>
- <resolver.version>1.6.3</resolver.version>
+ <mavenVersion>3.6.3</mavenVersion>
+ <resolverVersion>1.4.1</resolverVersion>
<checkstyle.violation.ignore>MethodLength</checkstyle.violation.ignore>
<project.build.outputTimestamp>2022-09-12T19:17:26Z</project.build.outputTimestamp>
</properties>
@@ -72,32 +72,31 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
- <version>${maven.version}</version>
+ <version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
- <version>${maven.version}</version>
+ <version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
+ <version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
- <version>${resolver.version}</version>
+ <version>${resolverVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
- <version>${resolver.version}</version>
- <scope>provided</scope>
+ <version>${resolverVersion}</version>
</dependency>
<dependency>
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
index 5f2f56d..420b040 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter;
* "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
+ * 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
@@ -18,6 +16,9 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
+
+import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
@@ -25,8 +26,6 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
-import java.util.List;
-
/**
* Filter to include or exclude artifacts from a list of patterns. The artifact pattern syntax is of the form:
*
@@ -44,8 +43,7 @@ import java.util.List;
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
*/
-public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFilter
-{
+public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFilter {
// fields -----------------------------------------------------------------
/**
@@ -70,8 +68,7 @@ public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFil
* <code>true</code> to include artifacts that match the patterns, or <code>false</code> to exclude
* them
*/
- public AbstractStrictPatternArtifactFilter( List<String> patterns, boolean include )
- {
+ public AbstractStrictPatternArtifactFilter(List<String> patterns, boolean include) {
this.patterns = patterns;
this.include = include;
}
@@ -79,14 +76,11 @@ public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFil
// ArtifactFilter methods -------------------------------------------------
/** {@inheritDoc} */
- public boolean include( Artifact artifact )
- {
+ public boolean include(Artifact artifact) {
boolean matched = false;
- for ( String pattern : patterns )
- {
- if ( include( artifact, pattern ) )
- {
+ for (String pattern : patterns) {
+ if (include(artifact, pattern)) {
matched = true;
break;
}
@@ -99,30 +93,25 @@ public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFil
/**
* Gets whether the specified artifact matches the specified pattern.
- *
+ *
* @param artifact
* the artifact to check
* @param pattern
* the pattern to match, as defined above
* @return <code>true</code> if the specified artifact is matched by the specified pattern
*/
- private boolean include( Artifact artifact, String pattern )
- {
+ private boolean include(Artifact artifact, String pattern) {
String[] tokens = new String[] {
- artifact.getGroupId(),
- artifact.getArtifactId(),
- artifact.getType(),
- artifact.getBaseVersion()
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getBaseVersion()
};
- String[] patternTokens = pattern.split( ":" );
+ String[] patternTokens = pattern.split(":");
// fail immediately if pattern tokens outnumber tokens to match
boolean matched = patternTokens.length <= tokens.length;
- for ( int i = 0; matched && i < patternTokens.length; i++ )
- {
- matched = matches( tokens[i], patternTokens[i] );
+ for (int i = 0; matched && i < patternTokens.length; i++) {
+ matched = matches(tokens[i], patternTokens[i]);
}
return matched;
@@ -130,65 +119,53 @@ public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFil
/**
* Gets whether the specified token matches the specified pattern segment.
- *
+ *
* @param token
* the token to check
* @param pattern
* the pattern segment to match, as defined above
* @return <code>true</code> if the specified token is matched by the specified pattern segment
*/
- private boolean matches( String token, String pattern )
- {
+ private boolean matches(String token, String pattern) {
boolean matches;
// support full wildcard and implied wildcard
- if ( "*".equals( pattern ) || pattern.length() == 0 )
- {
+ if ("*".equals(pattern) || pattern.length() == 0) {
matches = true;
}
// support contains wildcard
- else if ( pattern.startsWith( "*" ) && pattern.endsWith( "*" ) )
- {
- String contains = pattern.substring( 1, pattern.length() - 1 );
+ else if (pattern.startsWith("*") && pattern.endsWith("*")) {
+ String contains = pattern.substring(1, pattern.length() - 1);
- matches = token.contains( contains );
+ matches = token.contains(contains);
}
// support leading wildcard
- else if ( pattern.startsWith( "*" ) )
- {
- matches = token.endsWith( pattern.substring( 1 ) );
+ else if (pattern.startsWith("*")) {
+ matches = token.endsWith(pattern.substring(1));
}
// support trailing wildcard
- else if ( pattern.endsWith( "*" ) )
- {
- String prefix = pattern.substring( 0, pattern.length() - 1 );
+ else if (pattern.endsWith("*")) {
+ String prefix = pattern.substring(0, pattern.length() - 1);
- matches = token.startsWith( prefix );
+ matches = token.startsWith(prefix);
}
- // support versions range
- else if ( pattern.startsWith( "[" ) || pattern.startsWith( "(" ) )
- {
- matches = isVersionIncludedInRange( token, pattern );
+ // support versions range
+ else if (pattern.startsWith("[") || pattern.startsWith("(")) {
+ matches = isVersionIncludedInRange(token, pattern);
}
// support exact match
- else
- {
- matches = token.equals( pattern );
+ else {
+ matches = token.equals(pattern);
}
return matches;
}
- private boolean isVersionIncludedInRange( final String version, final String range )
- {
- try
- {
- return VersionRange.createFromVersionSpec( range ).containsVersion( new DefaultArtifactVersion( version ) );
- }
- catch ( InvalidVersionSpecificationException e )
- {
+ private boolean isVersionIncludedInRange(final String version, final String range) {
+ try {
+ return VersionRange.createFromVersionSpec(range).containsVersion(new DefaultArtifactVersion(version));
+ } catch (InvalidVersionSpecificationException e) {
return false;
}
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
index c975886..b44d04b 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.Collection;
@@ -29,17 +28,14 @@ import org.apache.maven.artifact.Artifact;
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @see StrictPatternExcludesArtifactFilter
*/
-public class PatternExcludesArtifactFilter
- extends PatternIncludesArtifactFilter
-{
+public class PatternExcludesArtifactFilter extends PatternIncludesArtifactFilter {
/**
* <p>Constructor for PatternExcludesArtifactFilter.</p>
*
* @param patterns The pattern to be used.
*/
- public PatternExcludesArtifactFilter( Collection<String> patterns )
- {
- super( patterns );
+ public PatternExcludesArtifactFilter(Collection<String> patterns) {
+ super(patterns);
}
/**
@@ -48,34 +44,28 @@ public class PatternExcludesArtifactFilter
* @param patterns The pattern which will be used.
* @param actTransitively yes/no.
*/
- public PatternExcludesArtifactFilter( Collection<String> patterns, boolean actTransitively )
- {
- super( patterns, actTransitively );
+ public PatternExcludesArtifactFilter(Collection<String> patterns, boolean actTransitively) {
+ super(patterns, actTransitively);
}
@Override
- public boolean include( Artifact artifact )
- {
- boolean shouldInclude = !patternMatches( artifact );
+ public boolean include(Artifact artifact) {
+ boolean shouldInclude = !patternMatches(artifact);
- if ( !shouldInclude )
- {
- addFilteredArtifact( artifact );
+ if (!shouldInclude) {
+ addFilteredArtifact(artifact);
}
return shouldInclude;
}
@Override
- protected String getFilterDescription()
- {
+ protected String getFilterDescription() {
return "artifact exclusion filter";
}
@Override
- public String toString()
- {
+ public String toString() {
return "Excludes filter:" + getPatternsAsString();
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
index 274e885..4d212a9 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,8 +43,7 @@ import static java.util.Objects.requireNonNull;
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @see StrictPatternIncludesArtifactFilter
*/
-public class PatternIncludesArtifactFilter implements ArtifactFilter, StatisticsReportingArtifactFilter
-{
+public class PatternIncludesArtifactFilter implements ArtifactFilter, StatisticsReportingArtifactFilter {
private static final String SEP = System.lineSeparator();
/**
@@ -73,9 +71,8 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
*
* @param patterns The pattern to be used.
*/
- public PatternIncludesArtifactFilter( final Collection<String> patterns )
- {
- this( patterns, false );
+ public PatternIncludesArtifactFilter(final Collection<String> patterns) {
+ this(patterns, false);
}
/**
@@ -84,54 +81,43 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
* @param patterns The pattern to be used.
* @param actTransitively transitive yes/no.
*/
- public PatternIncludesArtifactFilter( final Collection<String> patterns, final boolean actTransitively )
- {
+ public PatternIncludesArtifactFilter(final Collection<String> patterns, final boolean actTransitively) {
this.actTransitively = actTransitively;
final Set<Pattern> pat = new LinkedHashSet<>();
- if ( patterns != null && !patterns.isEmpty() )
- {
- for ( String pattern : patterns )
- {
- Pattern p = compile( pattern );
- pat.add( p );
+ if (patterns != null && !patterns.isEmpty()) {
+ for (String pattern : patterns) {
+ Pattern p = compile(pattern);
+ pat.add(p);
}
}
this.patterns = pat;
}
@Override
- public boolean include( final Artifact artifact )
- {
- final boolean shouldInclude = patternMatches( artifact );
+ public boolean include(final Artifact artifact) {
+ final boolean shouldInclude = patternMatches(artifact);
- if ( !shouldInclude )
- {
- addFilteredArtifact( artifact );
+ if (!shouldInclude) {
+ addFilteredArtifact(artifact);
}
return shouldInclude;
}
- protected boolean patternMatches( final Artifact artifact )
- {
- Boolean match = match( adapt( artifact ) );
- if ( match != null )
- {
+ protected boolean patternMatches(final Artifact artifact) {
+ Boolean match = match(adapt(artifact));
+ if (match != null) {
return match;
}
- if ( actTransitively )
- {
+ if (actTransitively) {
final List<String> depTrail = artifact.getDependencyTrail();
- if ( depTrail != null && depTrail.size() > 1 )
- {
- for ( String trailItem : depTrail )
- {
- Artifactoid artifactoid = adapt( trailItem );
- match = match( artifactoid );
- if ( match != null )
- {
+ if (depTrail != null && depTrail.size() > 1) {
+ for (String trailItem : depTrail) {
+ Artifactoid artifactoid = adapt(trailItem);
+ match = match(artifactoid);
+ if (match != null) {
return match;
}
}
@@ -141,14 +127,11 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
return false;
}
- private Boolean match( Artifactoid artifactoid )
- {
- for ( Pattern pattern : patterns )
- {
- if ( pattern.matches( artifactoid ) )
- {
- patternsTriggered.add( pattern );
- return !( pattern instanceof NegativePattern );
+ private Boolean match(Artifactoid artifactoid) {
+ for (Pattern pattern : patterns) {
+ if (pattern.matches(artifactoid)) {
+ patternsTriggered.add(pattern);
+ return !(pattern instanceof NegativePattern);
}
}
@@ -160,111 +143,96 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
*
* @param artifact add artifact to the filtered artifacts list.
*/
- protected void addFilteredArtifact( final Artifact artifact )
- {
- filteredArtifact.add( artifact );
+ protected void addFilteredArtifact(final Artifact artifact) {
+ filteredArtifact.add(artifact);
}
@Override
- public void reportMissedCriteria( final Logger logger )
- {
+ public void reportMissedCriteria(final Logger logger) {
// if there are no patterns, there is nothing to report.
- if ( !patterns.isEmpty() )
- {
- final List<Pattern> missed = new ArrayList<>( patterns );
- missed.removeAll( patternsTriggered );
+ if (!patterns.isEmpty()) {
+ final List<Pattern> missed = new ArrayList<>(patterns);
+ missed.removeAll(patternsTriggered);
- if ( !missed.isEmpty() && logger.isWarnEnabled() )
- {
+ if (!missed.isEmpty() && logger.isWarnEnabled()) {
final StringBuilder buffer = new StringBuilder();
- buffer.append( "The following patterns were never triggered in this " );
- buffer.append( getFilterDescription() );
- buffer.append( ':' );
+ buffer.append("The following patterns were never triggered in this ");
+ buffer.append(getFilterDescription());
+ buffer.append(':');
- for ( Pattern pattern : missed )
- {
- buffer.append( SEP ) .append( "o '" ).append( pattern ).append( "'" );
+ for (Pattern pattern : missed) {
+ buffer.append(SEP).append("o '").append(pattern).append("'");
}
- buffer.append( SEP );
+ buffer.append(SEP);
- logger.warn( buffer.toString() );
+ logger.warn(buffer.toString());
}
}
}
@Override
- public String toString()
- {
+ public String toString() {
return "Includes filter:" + getPatternsAsString();
}
- protected String getPatternsAsString()
- {
+ protected String getPatternsAsString() {
final StringBuilder buffer = new StringBuilder();
- for ( Pattern pattern : patterns )
- {
- buffer.append( SEP ).append( "o '" ).append( pattern ).append( "'" );
+ for (Pattern pattern : patterns) {
+ buffer.append(SEP).append("o '").append(pattern).append("'");
}
return buffer.toString();
}
- protected String getFilterDescription()
- {
+ protected String getFilterDescription() {
return "artifact inclusion filter";
}
@Override
- public void reportFilteredArtifacts( final Logger logger )
- {
- if ( !filteredArtifact.isEmpty() && logger.isDebugEnabled() )
- {
- final StringBuilder buffer = new StringBuilder(
- "The following artifacts were removed by this " + getFilterDescription() + ": " );
-
- for ( Artifact artifactId : filteredArtifact )
- {
- buffer.append( SEP ).append( artifactId.getId() );
+ public void reportFilteredArtifacts(final Logger logger) {
+ if (!filteredArtifact.isEmpty() && logger.isDebugEnabled()) {
+ final StringBuilder buffer =
+ new StringBuilder("The following artifacts were removed by this " + getFilterDescription() + ": ");
+
+ for (Artifact artifactId : filteredArtifact) {
+ buffer.append(SEP).append(artifactId.getId());
}
- logger.debug( buffer.toString() );
+ logger.debug(buffer.toString());
}
}
@Override
- public boolean hasMissedCriteria()
- {
+ public boolean hasMissedCriteria() {
// if there are no patterns, there is nothing to report.
- if ( !patterns.isEmpty() )
- {
- final List<Pattern> missed = new ArrayList<>( patterns );
- missed.removeAll( patternsTriggered );
+ if (!patterns.isEmpty()) {
+ final List<Pattern> missed = new ArrayList<>(patterns);
+ missed.removeAll(patternsTriggered);
return !missed.isEmpty();
}
return false;
}
- private enum Coordinate
- {
- GROUP_ID, ARTIFACT_ID, TYPE, CLASSIFIER, BASE_VERSION
+ private enum Coordinate {
+ GROUP_ID,
+ ARTIFACT_ID,
+ TYPE,
+ CLASSIFIER,
+ BASE_VERSION
}
- private interface Artifactoid
- {
- String getCoordinate( Coordinate coordinate );
+ private interface Artifactoid {
+ String getCoordinate(Coordinate coordinate);
}
- private static Artifactoid adapt( final Artifact artifact )
- {
- requireNonNull( artifact );
- return coordinate ->
- {
- requireNonNull( coordinate );
- switch ( coordinate )
- {
+ private static Artifactoid adapt(final Artifact artifact) {
+ requireNonNull(artifact);
+ return coordinate -> {
+ requireNonNull(coordinate);
+ switch (coordinate) {
case GROUP_ID:
return artifact.getGroupId();
case ARTIFACT_ID:
@@ -277,7 +245,7 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
return artifact.getType();
default:
}
- throw new IllegalArgumentException( "unknown coordinate: " + coordinate );
+ throw new IllegalArgumentException("unknown coordinate: " + coordinate);
};
}
@@ -285,32 +253,26 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
* Parses elements of {@link Artifact#getDependencyTrail()} list, they are either {@code G:A:T:V} or if artifact
* has classifier {@code G:A:T:C:V}, so strictly 4 or 5 segments only.
*/
- private static Artifactoid adapt( final String depTrailString )
- {
- requireNonNull( depTrailString );
- String[] coordinates = depTrailString.split( ":" );
- if ( coordinates.length != 4 && coordinates.length != 5 )
- {
- throw new IllegalArgumentException( "Bad dep trail string: " + depTrailString );
+ private static Artifactoid adapt(final String depTrailString) {
+ requireNonNull(depTrailString);
+ String[] coordinates = depTrailString.split(":");
+ if (coordinates.length != 4 && coordinates.length != 5) {
+ throw new IllegalArgumentException("Bad dep trail string: " + depTrailString);
}
final HashMap<Coordinate, String> map = new HashMap<>();
- map.put( Coordinate.GROUP_ID, coordinates[0] );
- map.put( Coordinate.ARTIFACT_ID, coordinates[1] );
- map.put( Coordinate.TYPE, coordinates[2] );
- if ( coordinates.length == 5 )
- {
- map.put( Coordinate.CLASSIFIER, coordinates[3] );
- map.put( Coordinate.BASE_VERSION, coordinates[4] );
- }
- else
- {
- map.put( Coordinate.BASE_VERSION, coordinates[3] );
- }
-
- return coordinate ->
- {
- requireNonNull( coordinate );
- return map.get( coordinate );
+ map.put(Coordinate.GROUP_ID, coordinates[0]);
+ map.put(Coordinate.ARTIFACT_ID, coordinates[1]);
+ map.put(Coordinate.TYPE, coordinates[2]);
+ if (coordinates.length == 5) {
+ map.put(Coordinate.CLASSIFIER, coordinates[3]);
+ map.put(Coordinate.BASE_VERSION, coordinates[4]);
+ } else {
+ map.put(Coordinate.BASE_VERSION, coordinates[3]);
+ }
+
+ return coordinate -> {
+ requireNonNull(coordinate);
+ return map.get(coordinate);
};
}
@@ -320,12 +282,10 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
* Splits the pattern string into tokens, replacing empty tokens with {@link #ANY} for patterns like {@code ::val}
* so it retains the position of token.
*/
- private static String[] splitAndTokenize( String pattern )
- {
- String[] stokens = pattern.split( ":" );
+ private static String[] splitAndTokenize(String pattern) {
+ String[] stokens = pattern.split(":");
String[] tokens = new String[stokens.length];
- for ( int i = 0; i < stokens.length; i++ )
- {
+ for (int i = 0; i < stokens.length; i++) {
String str = stokens[i];
tokens[i] = str != null && !str.isEmpty() ? str : ANY;
}
@@ -338,41 +298,31 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
* TODO: patterns seems NOT documented anywhere, so best we have is source below.
* TODO: patterns in some cases (3, 2 tokens) seems ambiguous, we may need to clean up the specs
*/
- private static Pattern compile( String pattern )
- {
- if ( pattern.startsWith( "!" ) )
- {
- return new NegativePattern( pattern, compile( pattern.substring( 1 ) ) );
- }
- else
- {
- String[] tokens = splitAndTokenize( pattern );
- if ( tokens.length < 1 || tokens.length > 5 )
- {
- throw new IllegalArgumentException( "Invalid pattern: " + pattern );
+ private static Pattern compile(String pattern) {
+ if (pattern.startsWith("!")) {
+ return new NegativePattern(pattern, compile(pattern.substring(1)));
+ } else {
+ String[] tokens = splitAndTokenize(pattern);
+ if (tokens.length < 1 || tokens.length > 5) {
+ throw new IllegalArgumentException("Invalid pattern: " + pattern);
}
- ArrayList<Pattern> patterns = new ArrayList<>( 5 );
+ ArrayList<Pattern> patterns = new ArrayList<>(5);
- if ( tokens.length == 5 )
- {
+ if (tokens.length == 5) {
// trivial, full pattern w/ classifier: G:A:T:C:V
- patterns.add( toPattern( tokens[0], Coordinate.GROUP_ID ) );
- patterns.add( toPattern( tokens[1], Coordinate.ARTIFACT_ID ) );
- patterns.add( toPattern( tokens[2], Coordinate.TYPE ) );
- patterns.add( toPattern( tokens[3], Coordinate.CLASSIFIER ) );
- patterns.add( toPattern( tokens[4], Coordinate.BASE_VERSION ) );
- }
- else if ( tokens.length == 4 )
- {
+ patterns.add(toPattern(tokens[0], Coordinate.GROUP_ID));
+ patterns.add(toPattern(tokens[1], Coordinate.ARTIFACT_ID));
+ patterns.add(toPattern(tokens[2], Coordinate.TYPE));
+ patterns.add(toPattern(tokens[3], Coordinate.CLASSIFIER));
+ patterns.add(toPattern(tokens[4], Coordinate.BASE_VERSION));
+ } else if (tokens.length == 4) {
// trivial, full pattern w/ version or classifier: G:A:T:V or G:A:T:C
- patterns.add( toPattern( tokens[0], Coordinate.GROUP_ID ) );
- patterns.add( toPattern( tokens[1], Coordinate.ARTIFACT_ID ) );
- patterns.add( toPattern( tokens[2], Coordinate.TYPE ) );
- patterns.add( toPattern( tokens[3], Coordinate.BASE_VERSION, Coordinate.CLASSIFIER ) );
- }
- else if ( tokens.length == 3 )
- {
+ patterns.add(toPattern(tokens[0], Coordinate.GROUP_ID));
+ patterns.add(toPattern(tokens[1], Coordinate.ARTIFACT_ID));
+ patterns.add(toPattern(tokens[2], Coordinate.TYPE));
+ patterns.add(toPattern(tokens[3], Coordinate.BASE_VERSION, Coordinate.CLASSIFIER));
+ } else if (tokens.length == 3) {
// tricky: may be "*:artifact:*" but also "*:war:*"
// *:*:* -> ALL
@@ -383,154 +333,114 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
// xxx:*:yyy -> G(xxx) + TC(yyy)
// xxx:yyy:* -> G(xxx)+A(yyy)
// xxx:yyy:zzz -> G(xxx)+A(yyy)+T(zzz)
- if ( ANY.equals( tokens[0] ) && ANY.equals( tokens[1] ) && ANY.equals( tokens[2] ) )
- {
- patterns.add( MATCH_ALL_PATTERN );
- }
- else if ( ANY.equals( tokens[0] ) && ANY.equals( tokens[1] ) )
- {
- patterns.add( toPattern( pattern, tokens[2], Coordinate.TYPE, Coordinate.CLASSIFIER ) );
- }
- else if ( ANY.equals( tokens[0] ) && ANY.equals( tokens[2] ) )
- {
- patterns.add( toPattern( pattern, tokens[1], Coordinate.ARTIFACT_ID, Coordinate.TYPE ) );
- }
- else if ( ANY.equals( tokens[0] ) )
- {
- patterns.add( toPattern( pattern, tokens[1], Coordinate.GROUP_ID, Coordinate.ARTIFACT_ID ) );
- patterns.add( toPattern( pattern, tokens[2], Coordinate.TYPE, Coordinate.CLASSIFIER ) );
- }
- else if ( ANY.equals( tokens[1] ) && ANY.equals( tokens[2] ) )
- {
- patterns.add( toPattern( pattern, tokens[0], Coordinate.GROUP_ID, Coordinate.ARTIFACT_ID ) );
- }
- else if ( ANY.equals( tokens[1] ) )
- {
- patterns.add( toPattern( tokens[0], tokens[0], Coordinate.GROUP_ID ) );
- patterns.add( toPattern( pattern, tokens[2], Coordinate.TYPE, Coordinate.CLASSIFIER ) );
- }
- else if ( ANY.equals( tokens[2] ) )
- {
- patterns.add( toPattern( tokens[0], Coordinate.GROUP_ID ) );
- patterns.add( toPattern( tokens[1], Coordinate.ARTIFACT_ID ) );
- }
- else
- {
- patterns.add( toPattern( tokens[0], Coordinate.GROUP_ID ) );
- patterns.add( toPattern( tokens[1], Coordinate.ARTIFACT_ID ) );
- patterns.add( toPattern( tokens[2], Coordinate.TYPE ) );
+ if (ANY.equals(tokens[0]) && ANY.equals(tokens[1]) && ANY.equals(tokens[2])) {
+ patterns.add(MATCH_ALL_PATTERN);
+ } else if (ANY.equals(tokens[0]) && ANY.equals(tokens[1])) {
+ patterns.add(toPattern(pattern, tokens[2], Coordinate.TYPE, Coordinate.CLASSIFIER));
+ } else if (ANY.equals(tokens[0]) && ANY.equals(tokens[2])) {
+ patterns.add(toPattern(pattern, tokens[1], Coordinate.ARTIFACT_ID, Coordinate.TYPE));
+ } else if (ANY.equals(tokens[0])) {
+ patterns.add(toPattern(pattern, tokens[1], Coordinate.GROUP_ID, Coordinate.ARTIFACT_ID));
+ patterns.add(toPattern(pattern, tokens[2], Coordinate.TYPE, Coordinate.CLASSIFIER));
+ } else if (ANY.equals(tokens[1]) && ANY.equals(tokens[2])) {
+ patterns.add(toPattern(pattern, tokens[0], Coordinate.GROUP_ID, Coordinate.ARTIFACT_ID));
+ } else if (ANY.equals(tokens[1])) {
+ patterns.add(toPattern(tokens[0], tokens[0], Coordinate.GROUP_ID));
+ patterns.add(toPattern(pattern, tokens[2], Coordinate.TYPE, Coordinate.CLASSIFIER));
+ } else if (ANY.equals(tokens[2])) {
+ patterns.add(toPattern(tokens[0], Coordinate.GROUP_ID));
+ patterns.add(toPattern(tokens[1], Coordinate.ARTIFACT_ID));
+ } else {
+ patterns.add(toPattern(tokens[0], Coordinate.GROUP_ID));
+ patterns.add(toPattern(tokens[1], Coordinate.ARTIFACT_ID));
+ patterns.add(toPattern(tokens[2], Coordinate.TYPE));
}
- }
- else if ( tokens.length == 2 )
- {
+ } else if (tokens.length == 2) {
// tricky: may be "*:artifact" but also "*:war"
// *:* -> ALL
// *:xxx -> GATV(xxx)
// xxx:* -> G(xxx)
// xxx:yyy -> G(xxx)+A(yyy)
- if ( ANY.equals( tokens[0] ) && ANY.equals( tokens[1] ) )
- {
- patterns.add( MATCH_ALL_PATTERN );
- }
- else if ( ANY.equals( tokens[0] ) )
- {
- patterns.add( toPattern( pattern, tokens[1],
- Coordinate.GROUP_ID, Coordinate.ARTIFACT_ID, Coordinate.TYPE, Coordinate.BASE_VERSION ) );
- }
- else if ( ANY.equals( tokens[1] ) )
- {
- patterns.add( toPattern( tokens[0], Coordinate.GROUP_ID ) );
+ if (ANY.equals(tokens[0]) && ANY.equals(tokens[1])) {
+ patterns.add(MATCH_ALL_PATTERN);
+ } else if (ANY.equals(tokens[0])) {
+ patterns.add(toPattern(
+ pattern,
+ tokens[1],
+ Coordinate.GROUP_ID,
+ Coordinate.ARTIFACT_ID,
+ Coordinate.TYPE,
+ Coordinate.BASE_VERSION));
+ } else if (ANY.equals(tokens[1])) {
+ patterns.add(toPattern(tokens[0], Coordinate.GROUP_ID));
+ } else {
+ patterns.add(toPattern(tokens[0], Coordinate.GROUP_ID));
+ patterns.add(toPattern(tokens[1], Coordinate.ARTIFACT_ID));
}
- else
- {
- patterns.add( toPattern( tokens[0], Coordinate.GROUP_ID ) );
- patterns.add( toPattern( tokens[1], Coordinate.ARTIFACT_ID ) );
- }
- }
- else
- {
+ } else {
// trivial: G
- patterns.add( toPattern( tokens[0], Coordinate.GROUP_ID ) );
+ patterns.add(toPattern(tokens[0], Coordinate.GROUP_ID));
}
// build result if needed and retains pattern string
- if ( patterns.size() == 1 )
- {
- Pattern pat = patterns.get( 0 );
- if ( pat == MATCH_ALL_PATTERN )
- {
- return new MatchAllPattern( pattern );
- }
- else
- {
+ if (patterns.size() == 1) {
+ Pattern pat = patterns.get(0);
+ if (pat == MATCH_ALL_PATTERN) {
+ return new MatchAllPattern(pattern);
+ } else {
return pat;
}
- }
- else
- {
- return new AndPattern( pattern, patterns.toArray( new Pattern[0] ) );
+ } else {
+ return new AndPattern(pattern, patterns.toArray(new Pattern[0]));
}
}
}
- private static Pattern toPattern( final String token, final Coordinate... coordinates )
- {
- return toPattern( token, token, coordinates );
+ private static Pattern toPattern(final String token, final Coordinate... coordinates) {
+ return toPattern(token, token, coordinates);
}
- private static Pattern toPattern( final String pattern, final String token, final Coordinate... coordinates )
- {
- if ( ANY.equals( token ) )
- {
+ private static Pattern toPattern(final String pattern, final String token, final Coordinate... coordinates) {
+ if (ANY.equals(token)) {
return MATCH_ALL_PATTERN;
- }
- else
- {
- EnumSet<Coordinate> coordinateSet = EnumSet.noneOf( Coordinate.class );
- coordinateSet.addAll( Arrays.asList( coordinates ) );
- return new CoordinateMatchingPattern( pattern, token, coordinateSet );
+ } else {
+ EnumSet<Coordinate> coordinateSet = EnumSet.noneOf(Coordinate.class);
+ coordinateSet.addAll(Arrays.asList(coordinates));
+ return new CoordinateMatchingPattern(pattern, token, coordinateSet);
}
}
- private static final Pattern MATCH_ALL_PATTERN = new MatchAllPattern( ANY );
+ private static final Pattern MATCH_ALL_PATTERN = new MatchAllPattern(ANY);
- private abstract static class Pattern
- {
+ private abstract static class Pattern {
protected final String pattern;
- private Pattern( String pattern )
- {
- this.pattern = requireNonNull( pattern );
+ private Pattern(String pattern) {
+ this.pattern = requireNonNull(pattern);
}
- public abstract boolean matches( Artifactoid artifact );
+ public abstract boolean matches(Artifactoid artifact);
@Override
- public String toString()
- {
+ public String toString() {
return pattern;
}
}
- private static class AndPattern extends Pattern
- {
+ private static class AndPattern extends Pattern {
private final Pattern[] patterns;
- private AndPattern( String pattern, Pattern[] patterns )
- {
- super( pattern );
+ private AndPattern(String pattern, Pattern[] patterns) {
+ super(pattern);
this.patterns = patterns;
}
@Override
- public boolean matches( Artifactoid artifactoid )
- {
- for ( Pattern pattern : patterns )
- {
- if ( !pattern.matches( artifactoid ) )
- {
+ public boolean matches(Artifactoid artifactoid) {
+ for (Pattern pattern : patterns) {
+ if (!pattern.matches(artifactoid)) {
return false;
}
}
@@ -538,8 +448,7 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
}
}
- private static class CoordinateMatchingPattern extends Pattern
- {
+ private static class CoordinateMatchingPattern extends Pattern {
private final String token;
private final EnumSet<Coordinate> coordinates;
@@ -550,55 +459,39 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
private final VersionRange optionalVersionRange;
- private CoordinateMatchingPattern( String pattern, String token, EnumSet<Coordinate> coordinates )
- {
- super( pattern );
+ private CoordinateMatchingPattern(String pattern, String token, EnumSet<Coordinate> coordinates) {
+ super(pattern);
this.token = token;
this.coordinates = coordinates;
- this.containsAsterisk = token.contains( "*" );
- this.containsWildcard = this.containsAsterisk || token.contains( "?" );
- if ( !this.containsWildcard && coordinates.equals( EnumSet.of( Coordinate.BASE_VERSION ) ) && (
- token.startsWith( "[" ) || token.startsWith( "(" ) ) )
- {
- try
- {
- this.optionalVersionRange = VersionRange.createFromVersionSpec( token );
- }
- catch ( InvalidVersionSpecificationException e )
- {
- throw new IllegalArgumentException( "Wrong version spec: " + token, e );
+ this.containsAsterisk = token.contains("*");
+ this.containsWildcard = this.containsAsterisk || token.contains("?");
+ if (!this.containsWildcard
+ && coordinates.equals(EnumSet.of(Coordinate.BASE_VERSION))
+ && (token.startsWith("[") || token.startsWith("("))) {
+ try {
+ this.optionalVersionRange = VersionRange.createFromVersionSpec(token);
+ } catch (InvalidVersionSpecificationException e) {
+ throw new IllegalArgumentException("Wrong version spec: " + token, e);
}
- }
- else
- {
+ } else {
this.optionalVersionRange = null;
}
}
@Override
- public boolean matches( Artifactoid artifactoid )
- {
- for ( Coordinate coordinate : coordinates )
- {
- String value = artifactoid.getCoordinate( coordinate );
- if ( Coordinate.BASE_VERSION == coordinate && optionalVersionRange != null )
- {
- if ( optionalVersionRange.containsVersion( new DefaultArtifactVersion( value ) ) )
- {
+ public boolean matches(Artifactoid artifactoid) {
+ for (Coordinate coordinate : coordinates) {
+ String value = artifactoid.getCoordinate(coordinate);
+ if (Coordinate.BASE_VERSION == coordinate && optionalVersionRange != null) {
+ if (optionalVersionRange.containsVersion(new DefaultArtifactVersion(value))) {
return true;
}
- }
- else if ( containsWildcard )
- {
- if ( match( token, containsAsterisk, value ) )
- {
+ } else if (containsWildcard) {
+ if (match(token, containsAsterisk, value)) {
return true;
}
- }
- else
- {
- if ( token.equals( value ) )
- {
+ } else {
+ if (token.equals(value)) {
return true;
}
}
@@ -610,16 +503,13 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
/**
* Matches all input
*/
- private static class MatchAllPattern extends Pattern
- {
- private MatchAllPattern( String pattern )
- {
- super( pattern );
+ private static class MatchAllPattern extends Pattern {
+ private MatchAllPattern(String pattern) {
+ super(pattern);
}
@Override
- public boolean matches( Artifactoid artifactoid )
- {
+ public boolean matches(Artifactoid artifactoid) {
return true;
}
}
@@ -627,28 +517,24 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
/**
* Negative pattern
*/
- private static class NegativePattern extends Pattern
- {
+ private static class NegativePattern extends Pattern {
private final Pattern inner;
- private NegativePattern( String pattern, Pattern inner )
- {
- super( pattern );
+ private NegativePattern(String pattern, Pattern inner) {
+ super(pattern);
this.inner = inner;
}
@Override
- public boolean matches( Artifactoid artifactoid )
- {
- return inner.matches( artifactoid );
+ public boolean matches(Artifactoid artifactoid) {
+ return inner.matches(artifactoid);
}
}
// this beauty below must be salvaged
- @SuppressWarnings( "InnerAssignment" )
- private static boolean match( final String pattern, final boolean containsAsterisk, final String value )
- {
+ @SuppressWarnings("InnerAssignment")
+ private static boolean match(final String pattern, final boolean containsAsterisk, final String value) {
char[] patArr = pattern.toCharArray();
char[] strArr = value != null ? value.toCharArray() : new char[0];
int patIdxStart = 0;
@@ -657,47 +543,37 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
int strIdxEnd = strArr.length - 1;
char ch;
- if ( !containsAsterisk )
- {
+ if (!containsAsterisk) {
// No '*'s, so we make a shortcut
- if ( patIdxEnd != strIdxEnd )
- {
+ if (patIdxEnd != strIdxEnd) {
return false; // Pattern and string do not have the same size
}
- for ( int i = 0; i <= patIdxEnd; i++ )
- {
+ for (int i = 0; i <= patIdxEnd; i++) {
ch = patArr[i];
- if ( ch != '?' && ch != strArr[i] )
- {
+ if (ch != '?' && ch != strArr[i]) {
return false; // Character mismatch
}
}
return true; // String matches against pattern
}
- if ( patIdxEnd == 0 )
- {
+ if (patIdxEnd == 0) {
return true; // Pattern contains only '*', which matches anything
}
// Process characters before first star
- while ( ( ch = patArr[patIdxStart] ) != '*' && strIdxStart <= strIdxEnd )
- {
- if ( ch != '?' && ch != strArr[strIdxStart] )
- {
+ while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) {
+ if (ch != '?' && ch != strArr[strIdxStart]) {
return false; // Character mismatch
}
patIdxStart++;
strIdxStart++;
}
- if ( strIdxStart > strIdxEnd )
- {
+ if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
- for ( int i = patIdxStart; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] != '*' )
- {
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {
+ if (patArr[i] != '*') {
return false;
}
}
@@ -705,23 +581,18 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
}
// Process characters after last star
- while ( ( ch = patArr[patIdxEnd] ) != '*' && strIdxStart <= strIdxEnd )
- {
- if ( ch != '?' && ch != strArr[strIdxEnd] )
- {
+ while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {
+ if (ch != '?' && ch != strArr[strIdxEnd]) {
return false; // Character mismatch
}
patIdxEnd--;
strIdxEnd--;
}
- if ( strIdxStart > strIdxEnd )
- {
+ if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
- for ( int i = patIdxStart; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] != '*' )
- {
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {
+ if (patArr[i] != '*') {
return false;
}
}
@@ -730,36 +601,29 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
// process pattern between stars. padIdxStart and patIdxEnd point
// always to a '*'.
- while ( patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd )
- {
+ while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
int patIdxTmp = -1;
- for ( int i = patIdxStart + 1; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] == '*' )
- {
+ for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
+ if (patArr[i] == '*') {
patIdxTmp = i;
break;
}
}
- if ( patIdxTmp == patIdxStart + 1 )
- {
+ if (patIdxTmp == patIdxStart + 1) {
// Two stars next to each other, skip the first one.
patIdxStart++;
continue;
}
// Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd
- int patLength = ( patIdxTmp - patIdxStart - 1 );
- int strLength = ( strIdxEnd - strIdxStart + 1 );
+ int patLength = (patIdxTmp - patIdxStart - 1);
+ int strLength = (strIdxEnd - strIdxStart + 1);
int foundIdx = -1;
strLoop:
- for ( int i = 0; i <= strLength - patLength; i++ )
- {
- for ( int j = 0; j < patLength; j++ )
- {
+ for (int i = 0; i <= strLength - patLength; i++) {
+ for (int j = 0; j < patLength; j++) {
ch = patArr[patIdxStart + j + 1];
- if ( ch != '?' && ch != strArr[strIdxStart + i + j] )
- {
+ if (ch != '?' && ch != strArr[strIdxStart + i + j]) {
continue strLoop;
}
}
@@ -768,8 +632,7 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
break;
}
- if ( foundIdx == -1 )
- {
+ if (foundIdx == -1) {
return false;
}
@@ -779,10 +642,8 @@ public class PatternIncludesArtifactFilter implements ArtifactFilter, Statistics
// All characters in the string are used. Check if only '*'s are left
// in the pattern. If so, we succeeded. Otherwise failure.
- for ( int i = patIdxStart; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] != '*' )
- {
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {
+ if (patArr[i] != '*') {
return false;
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
index d2c9517..ac47979 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.ArrayList;
import java.util.List;
@@ -36,9 +35,7 @@ import org.slf4j.Logger;
* UNLESS the corresponding XXXWithImplications() method is used to enable that
* scope.
*/
-public class ScopeArtifactFilter
- implements ArtifactFilter, StatisticsReportingArtifactFilter
-{
+public class ScopeArtifactFilter implements ArtifactFilter, StatisticsReportingArtifactFilter {
private boolean includeCompileScope;
private boolean includeRuntimeScope;
@@ -48,9 +45,9 @@ public class ScopeArtifactFilter
private boolean includeProvidedScope;
private boolean includeSystemScope;
-
+
private boolean includeNullScope = true;
-
+
private boolean nullScopeHit = false;
private boolean compileScopeHit = false;
@@ -64,15 +61,14 @@ public class ScopeArtifactFilter
private boolean systemScopeHit = false;
private final List<String> filteredArtifactIds = new ArrayList<>();
-
+
/**
* Constructor that is meant to be used with fine-grained manipulation to
* enable/disable specific scopes using the associated mutator methods.
*/
- public ScopeArtifactFilter()
- {
+ public ScopeArtifactFilter() {
// don't enable anything by default.
- this( null );
+ this(null);
}
/**
@@ -82,82 +78,56 @@ public class ScopeArtifactFilter
*
* @param scope the scope
*/
- public ScopeArtifactFilter( String scope )
- {
- if ( DefaultArtifact.SCOPE_COMPILE.equals( scope ) )
- {
- setIncludeCompileScopeWithImplications( true );
- }
- else if ( DefaultArtifact.SCOPE_RUNTIME.equals( scope ) )
- {
- setIncludeRuntimeScopeWithImplications( true );
- }
- else if ( DefaultArtifact.SCOPE_TEST.equals( scope ) )
- {
- setIncludeTestScopeWithImplications( true );
- }
- else if ( DefaultArtifact.SCOPE_PROVIDED.equals( scope ) )
- {
- setIncludeProvidedScope( true );
- }
- else if ( DefaultArtifact.SCOPE_SYSTEM.equals( scope ) )
- {
- setIncludeSystemScope( true );
+ public ScopeArtifactFilter(String scope) {
+ if (DefaultArtifact.SCOPE_COMPILE.equals(scope)) {
+ setIncludeCompileScopeWithImplications(true);
+ } else if (DefaultArtifact.SCOPE_RUNTIME.equals(scope)) {
+ setIncludeRuntimeScopeWithImplications(true);
+ } else if (DefaultArtifact.SCOPE_TEST.equals(scope)) {
+ setIncludeTestScopeWithImplications(true);
+ } else if (DefaultArtifact.SCOPE_PROVIDED.equals(scope)) {
+ setIncludeProvidedScope(true);
+ } else if (DefaultArtifact.SCOPE_SYSTEM.equals(scope)) {
+ setIncludeSystemScope(true);
}
}
/** {@inheritDoc} */
- public boolean include( Artifact artifact )
- {
+ public boolean include(Artifact artifact) {
boolean result = true;
-
- if ( artifact.getScope() == null )
- {
+
+ if (artifact.getScope() == null) {
nullScopeHit = true;
result = includeNullScope;
- }
- else if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
- {
+ } else if (Artifact.SCOPE_COMPILE.equals(artifact.getScope())) {
compileScopeHit = true;
result = includeCompileScope;
- }
- else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
- {
+ } else if (Artifact.SCOPE_RUNTIME.equals(artifact.getScope())) {
runtimeScopeHit = true;
result = includeRuntimeScope;
- }
- else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
- {
+ } else if (Artifact.SCOPE_TEST.equals(artifact.getScope())) {
testScopeHit = true;
result = includeTestScope;
- }
- else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
- {
+ } else if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
providedScopeHit = true;
result = includeProvidedScope;
- }
- else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
- {
+ } else if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
systemScopeHit = true;
result = includeSystemScope;
}
- if ( !result )
- {
- // We have to be very careful with artifacts that have ranges,
- // because DefaultArtifact.getId() as of <= 2.1.0-M1 will throw a NPE
+ if (!result) {
+ // We have to be very careful with artifacts that have ranges,
+ // because DefaultArtifact.getId() as of <= 2.1.0-M1 will throw a NPE
// if a range is specified.
String id;
- if ( artifact.getVersionRange() != null )
- {
+ if (artifact.getVersionRange() != null) {
id = artifact.getDependencyConflictId() + ":" + artifact.getVersionRange();
- }
- else
- {
+ } else {
id = artifact.getId();
}
-
- filteredArtifactIds.add( id );
+
+ filteredArtifactIds.add(id);
}
return result;
@@ -168,71 +138,59 @@ public class ScopeArtifactFilter
*
* @return Information converted to a string.
*/
- public String toString()
- {
+ public String toString() {
return "Scope filter [null-scope=" + includeNullScope + ", compile=" + includeCompileScope + ", runtime="
- + includeRuntimeScope + ", test=" + includeTestScope + ", provided=" + includeProvidedScope + ", system="
- + includeSystemScope + "]";
+ + includeRuntimeScope + ", test=" + includeTestScope + ", provided=" + includeProvidedScope
+ + ", system="
+ + includeSystemScope + "]";
}
/** {@inheritDoc} */
- public void reportFilteredArtifacts( Logger logger )
- {
- if ( !filteredArtifactIds.isEmpty() && logger.isDebugEnabled() )
- {
- StringBuilder buffer = new StringBuilder( "The following artifacts were removed by this filter: " );
-
- for ( String artifactId : filteredArtifactIds )
- {
- buffer.append( '\n' ).append( artifactId );
+ public void reportFilteredArtifacts(Logger logger) {
+ if (!filteredArtifactIds.isEmpty() && logger.isDebugEnabled()) {
+ StringBuilder buffer = new StringBuilder("The following artifacts were removed by this filter: ");
+
+ for (String artifactId : filteredArtifactIds) {
+ buffer.append('\n').append(artifactId);
}
- logger.debug( buffer.toString() );
+ logger.debug(buffer.toString());
}
}
/** {@inheritDoc} */
- public void reportMissedCriteria( Logger logger )
- {
- if ( logger.isDebugEnabled() )
- {
+ public void reportMissedCriteria(Logger logger) {
+ if (logger.isDebugEnabled()) {
StringBuilder buffer = new StringBuilder();
boolean report = false;
- if ( !nullScopeHit )
- {
- buffer.append( "\no [Null Scope]" );
+ if (!nullScopeHit) {
+ buffer.append("\no [Null Scope]");
report = true;
}
- if ( !compileScopeHit )
- {
- buffer.append( "\no Compile" );
+ if (!compileScopeHit) {
+ buffer.append("\no Compile");
report = true;
}
- if ( !runtimeScopeHit )
- {
- buffer.append( "\no Runtime" );
+ if (!runtimeScopeHit) {
+ buffer.append("\no Runtime");
report = true;
}
- if ( !testScopeHit )
- {
- buffer.append( "\no Test" );
+ if (!testScopeHit) {
+ buffer.append("\no Test");
report = true;
}
- if ( !providedScopeHit )
- {
- buffer.append( "\no Provided" );
+ if (!providedScopeHit) {
+ buffer.append("\no Provided");
report = true;
}
- if ( !systemScopeHit )
- {
- buffer.append( "\no System" );
+ if (!systemScopeHit) {
+ buffer.append("\no System");
report = true;
}
- if ( report && logger.isDebugEnabled() )
- {
- logger.debug( "The following scope filters were not used: " + buffer );
+ if (report && logger.isDebugEnabled()) {
+ logger.debug("The following scope filters were not used: " + buffer);
}
}
}
@@ -242,19 +200,21 @@ public class ScopeArtifactFilter
*
* @return a boolean.
*/
- public boolean hasMissedCriteria()
- {
- return !nullScopeHit || !compileScopeHit || !runtimeScopeHit || !testScopeHit || !providedScopeHit
+ public boolean hasMissedCriteria() {
+ return !nullScopeHit
+ || !compileScopeHit
+ || !runtimeScopeHit
+ || !testScopeHit
+ || !providedScopeHit
|| !systemScopeHit;
}
-
+
/**
* <p>isIncludeCompileScope.</p>
*
* @return {@link #includeCompileScope}
*/
- public boolean isIncludeCompileScope()
- {
+ public boolean isIncludeCompileScope() {
return includeCompileScope;
}
@@ -264,10 +224,9 @@ public class ScopeArtifactFilter
* @param pIncludeCompileScope true/false.
* @return {@link org.apache.maven.shared.artifact.filter.ScopeArtifactFilter}
*/
- public ScopeArtifactFilter setIncludeCompileScope( boolean pIncludeCompileScope )
- {
+ public ScopeArtifactFilter setIncludeCompileScope(boolean pIncludeCompileScope) {
this.includeCompileScope = pIncludeCompileScope;
-
+
return this;
}
@@ -276,8 +235,7 @@ public class ScopeArtifactFilter
*
* @return {@link #includeRuntimeScope}
*/
- public boolean isIncludeRuntimeScope()
- {
+ public boolean isIncludeRuntimeScope() {
return includeRuntimeScope;
}
@@ -287,10 +245,9 @@ public class ScopeArtifactFilter
* @param pIncludeRuntimeScope true/false
* @return {@link org.apache.maven.shared.artifact.filter.ScopeArtifactFilter}
*/
- public ScopeArtifactFilter setIncludeRuntimeScope( boolean pIncludeRuntimeScope )
- {
+ public ScopeArtifactFilter setIncludeRuntimeScope(boolean pIncludeRuntimeScope) {
this.includeRuntimeScope = pIncludeRuntimeScope;
-
+
return this;
}
@@ -299,8 +256,7 @@ public class ScopeArtifactFilter
*
* @return {@link #includeTestScope}
*/
- public boolean isIncludeTestScope()
- {
+ public boolean isIncludeTestScope() {
return includeTestScope;
}
@@ -310,10 +266,9 @@ public class ScopeArtifactFilter
* @param pIncludeTestScope {@link #includeTestScope}
* @return {@link org.apache.maven.shared.artifact.filter.ScopeArtifactFilter}
*/
- public ScopeArtifactFilter setIncludeTestScope( boolean pIncludeTestScope )
- {
+ public ScopeArtifactFilter setIncludeTestScope(boolean pIncludeTestScope) {
this.includeTestScope = pIncludeTestScope;
-
+
return this;
}
@@ -322,8 +277,7 @@ public class ScopeArtifactFilter
*
* @return {@link #includeProvidedScope}
*/
- public boolean isIncludeProvidedScope()
- {
+ public boolean isIncludeProvidedScope() {
return includeProvidedScope;
}
@@ -333,10 +287,9 @@ public class ScopeArtifactFilter
* @param pIncludeProvidedScope yes/no.
* @return {@link #ScopeArtifactFilter()}
*/
- public ScopeArtifactFilter setIncludeProvidedScope( boolean pIncludeProvidedScope )
- {
+ public ScopeArtifactFilter setIncludeProvidedScope(boolean pIncludeProvidedScope) {
this.includeProvidedScope = pIncludeProvidedScope;
-
+
return this;
}
@@ -345,8 +298,7 @@ public class ScopeArtifactFilter
*
* @return {@link #includeSystemScope}
*/
- public boolean isIncludeSystemScope()
- {
+ public boolean isIncludeSystemScope() {
return includeSystemScope;
}
@@ -356,13 +308,12 @@ public class ScopeArtifactFilter
* @param pIncludeSystemScope a boolean.
* @return a {@link org.apache.maven.shared.artifact.filter.ScopeArtifactFilter} object.
*/
- public ScopeArtifactFilter setIncludeSystemScope( boolean pIncludeSystemScope )
- {
+ public ScopeArtifactFilter setIncludeSystemScope(boolean pIncludeSystemScope) {
this.includeSystemScope = pIncludeSystemScope;
-
+
return this;
}
-
+
/**
* Manages the following scopes:
*
@@ -375,15 +326,14 @@ public class ScopeArtifactFilter
* @param enabled whether specified scopes should be included
* @return this instance
*/
- public ScopeArtifactFilter setIncludeCompileScopeWithImplications( boolean enabled )
- {
+ public ScopeArtifactFilter setIncludeCompileScopeWithImplications(boolean enabled) {
includeSystemScope = enabled;
includeProvidedScope = enabled;
includeCompileScope = enabled;
-
+
return this;
}
-
+
/**
* Manages the following scopes:
*
@@ -395,11 +345,10 @@ public class ScopeArtifactFilter
* @param enabled whether specified scopes should be included
* @return this instance
*/
- public ScopeArtifactFilter setIncludeRuntimeScopeWithImplications( boolean enabled )
- {
+ public ScopeArtifactFilter setIncludeRuntimeScopeWithImplications(boolean enabled) {
includeCompileScope = enabled;
includeRuntimeScope = enabled;
-
+
return this;
}
@@ -417,44 +366,41 @@ public class ScopeArtifactFilter
* @param enabled whether specified scopes should be included
* @return this instance
*/
- public ScopeArtifactFilter setIncludeTestScopeWithImplications( boolean enabled )
- {
+ public ScopeArtifactFilter setIncludeTestScopeWithImplications(boolean enabled) {
includeSystemScope = enabled;
includeProvidedScope = enabled;
includeCompileScope = enabled;
includeRuntimeScope = enabled;
includeTestScope = enabled;
-
+
return this;
}
-
+
/**
* Determine whether artifacts that have a null scope are included or excluded.
*
* @param enable whether null-scope should be included
* @return this instance
*/
- public ScopeArtifactFilter setIncludeNullScope( boolean enable )
- {
+ public ScopeArtifactFilter setIncludeNullScope(boolean enable) {
includeNullScope = enable;
-
+
return this;
}
-
+
/**
* Reset hit counts and tracking of filtered artifacts, BUT NOT ENABLED SCOPES.
*
* @return this instance
*/
- public ScopeArtifactFilter reset()
- {
+ public ScopeArtifactFilter reset() {
compileScopeHit = false;
runtimeScopeHit = false;
testScopeHit = false;
providedScopeHit = false;
systemScopeHit = false;
filteredArtifactIds.clear();
-
+
return this;
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java
index fe755da..c75ed4c 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,28 +16,28 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import org.slf4j.Logger;
/**
* StatisticsReportingArtifactFilter interface.
*/
-public interface StatisticsReportingArtifactFilter
-{
+public interface StatisticsReportingArtifactFilter {
/**
* <p>reportMissedCriteria.</p>
*
* @param logger the logger
*/
- void reportMissedCriteria( Logger logger );
+ void reportMissedCriteria(Logger logger);
/**
* <p>reportFilteredArtifacts.</p>
*
* @param logger the logger
*/
- void reportFilteredArtifacts( Logger logger );
+ void reportFilteredArtifacts(Logger logger);
/**
* <p>hasMissedCriteria.</p>
@@ -47,5 +45,4 @@ public interface StatisticsReportingArtifactFilter
* @return {@code true} if missed criteria; {@code false} otherwise.
*/
boolean hasMissedCriteria();
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
index a042b8f..57dadad 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.List;
@@ -29,17 +28,14 @@ import java.util.List;
* @see AbstractStrictPatternArtifactFilter
* @see PatternExcludesArtifactFilter
*/
-public class StrictPatternExcludesArtifactFilter
- extends AbstractStrictPatternArtifactFilter
-{
+public class StrictPatternExcludesArtifactFilter extends AbstractStrictPatternArtifactFilter {
/**
* Creates a new filter that excludes artifacts that match the specified patterns.
*
* @param patterns
* the list of artifact patterns to match, as described above
*/
- public StrictPatternExcludesArtifactFilter( List<String> patterns )
- {
- super( patterns, false );
+ public StrictPatternExcludesArtifactFilter(List<String> patterns) {
+ super(patterns, false);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
index 5df722d..9c1e8ee 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.List;
@@ -29,17 +28,14 @@ import java.util.List;
* @see AbstractStrictPatternArtifactFilter
* @see PatternIncludesArtifactFilter
*/
-public class StrictPatternIncludesArtifactFilter
- extends AbstractStrictPatternArtifactFilter
-{
+public class StrictPatternIncludesArtifactFilter extends AbstractStrictPatternArtifactFilter {
/**
* Creates a new filter that includes artifacts that match the specified patterns.
*
* @param patterns
* the list of artifact patterns to match, as described above
*/
- public StrictPatternIncludesArtifactFilter( List<String> patterns )
- {
- super( patterns, true );
+ public StrictPatternIncludesArtifactFilter(List<String> patterns) {
+ super(patterns, true);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java
index cbf45e2..8709876 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import java.util.Arrays;
import java.util.LinkedHashSet;
@@ -34,9 +33,7 @@ import static org.apache.maven.shared.artifact.filter.internal.Utils.isNotEmpty;
*
* @author <a href="richardv@mxtelecom.com">Richard van der Hoff</a>
*/
-public abstract class AbstractArtifactFeatureFilter
- extends AbstractArtifactsFilter
-{
+public abstract class AbstractArtifactFeatureFilter extends AbstractArtifactsFilter {
/** The list of types or classifiers to include */
private List<String> includes;
@@ -51,10 +48,9 @@ public abstract class AbstractArtifactFeatureFilter
* @param include comma separated list with includes.
* @param exclude comma separated list with excludes.
*/
- public AbstractArtifactFeatureFilter( String include, String exclude )
- {
- setExcludes( exclude );
- setIncludes( include );
+ public AbstractArtifactFeatureFilter(String include, String exclude) {
+ setExcludes(exclude);
+ setIncludes(include);
}
/**
@@ -62,18 +58,15 @@ public abstract class AbstractArtifactFeatureFilter
*
* This function determines if filtering needs to be performed. Includes are processed before Excludes.
*/
- public Set<Artifact> filter( Set<Artifact> artifacts )
- {
+ public Set<Artifact> filter(Set<Artifact> artifacts) {
Set<Artifact> results = artifacts;
- if ( this.includes != null && !this.includes.isEmpty() )
- {
- results = filterIncludes( results, this.includes );
+ if (this.includes != null && !this.includes.isEmpty()) {
+ results = filterIncludes(results, this.includes);
}
- if ( this.excludes != null && !this.excludes.isEmpty() )
- {
- results = filterExcludes( results, this.excludes );
+ if (this.excludes != null && !this.excludes.isEmpty()) {
+ results = filterExcludes(results, this.excludes);
}
return results;
@@ -81,26 +74,22 @@ public abstract class AbstractArtifactFeatureFilter
/**
* Processes the dependencies list and includes the dependencies that match a filter in the list.
- *
+ *
* @param artifacts List of dependencies.
* @param theIncludes List of types or classifiers to include.
* @return a set of filtered artifacts.
*/
- private Set<Artifact> filterIncludes( Set<Artifact> artifacts, List<String> theIncludes )
- {
+ private Set<Artifact> filterIncludes(Set<Artifact> artifacts, List<String> theIncludes) {
Set<Artifact> result = new LinkedHashSet<>();
- for ( Artifact artifact : artifacts )
- {
- for ( String include : theIncludes )
- {
+ for (Artifact artifact : artifacts) {
+ for (String include : theIncludes) {
// if the classifier or type of the artifact
// matches the feature
// to include, add to the
// results
- if ( compareFeatures( getArtifactFeature( artifact ), include ) )
- {
- result.add( artifact );
+ if (compareFeatures(getArtifactFeature(artifact), include)) {
+ result.add(artifact);
}
}
}
@@ -109,35 +98,30 @@ public abstract class AbstractArtifactFeatureFilter
/**
* Processes the dependencies list and excludes the dependencies that match a filter in the list.
- *
+ *
* @param artifacts List of dependencies.
* @param theExcludes List of types or classifiers to exclude.
* @return a set of filtered artifacts.
*/
- private Set<Artifact> filterExcludes( Set<Artifact> artifacts, List<String> theExcludes )
- {
+ private Set<Artifact> filterExcludes(Set<Artifact> artifacts, List<String> theExcludes) {
Set<Artifact> result = new LinkedHashSet<>();
- for ( Artifact artifact : artifacts )
- {
+ for (Artifact artifact : artifacts) {
boolean exclude = false;
- String artifactFeature = getArtifactFeature( artifact );
+ String artifactFeature = getArtifactFeature(artifact);
// look through all types or classifiers. If no
// matches are found
// then it can be added to the results.
- for ( String excludeFeature : theExcludes )
- {
- if ( compareFeatures( artifactFeature, excludeFeature ) )
- {
+ for (String excludeFeature : theExcludes) {
+ if (compareFeatures(artifactFeature, excludeFeature)) {
exclude = true;
break;
}
}
- if ( !exclude )
- {
- result.add( artifact );
+ if (!exclude) {
+ result.add(artifact);
}
}
@@ -150,18 +134,16 @@ public abstract class AbstractArtifactFeatureFilter
* @param artifact artifact to return type or classifier of
* @return type or classifier
*/
- protected abstract String getArtifactFeature( Artifact artifact );
+ protected abstract String getArtifactFeature(Artifact artifact);
/**
* <p>Setter for the field <code>excludes</code>.</p>
*
* @param excludeString comma separated list with excludes.
*/
- public void setExcludes( String excludeString )
- {
- if ( isNotEmpty( excludeString ) )
- {
- this.excludes = Arrays.asList( excludeString.split( "," ) );
+ public void setExcludes(String excludeString) {
+ if (isNotEmpty(excludeString)) {
+ this.excludes = Arrays.asList(excludeString.split(","));
}
}
@@ -170,11 +152,9 @@ public abstract class AbstractArtifactFeatureFilter
*
* @param includeString comma separated list with includes.
*/
- public void setIncludes( String includeString )
- {
- if ( isNotEmpty( includeString ) )
- {
- this.includes = Arrays.asList( includeString.split( "," ) );
+ public void setIncludes(String includeString) {
+ if (isNotEmpty(includeString)) {
+ this.includes = Arrays.asList(includeString.split(","));
}
}
@@ -183,8 +163,7 @@ public abstract class AbstractArtifactFeatureFilter
*
* @return Returns the excludes.
*/
- public List<String> getExcludes()
- {
+ public List<String> getExcludes() {
return this.excludes;
}
@@ -193,8 +172,7 @@ public abstract class AbstractArtifactFeatureFilter
*
* @return Returns the includes.
*/
- public List<String> getIncludes()
- {
+ public List<String> getIncludes() {
return this.includes;
}
@@ -205,8 +183,7 @@ public abstract class AbstractArtifactFeatureFilter
* @param rhs String feature from exclude or include list
* @return boolean true if features match
*/
- protected boolean compareFeatures( String lhs, String rhs )
- {
- return ( Objects.equals( lhs, rhs ) );
+ protected boolean compareFeatures(String lhs, String rhs) {
+ return (Objects.equals(lhs, rhs));
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java
index 4a2fe78..30cb1fb 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -29,17 +28,13 @@ import org.apache.maven.artifact.Artifact;
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public abstract class AbstractArtifactsFilter
- implements ArtifactsFilter
-{
+public abstract class AbstractArtifactsFilter implements ArtifactsFilter {
/** {@inheritDoc} */
- public boolean isArtifactIncluded( Artifact artifact )
- throws ArtifactFilterException
- {
+ public boolean isArtifactIncluded(Artifact artifact) throws ArtifactFilterException {
Set<Artifact> set = new LinkedHashSet<>();
- set.add( artifact );
+ set.add(artifact);
- set = filter( set );
- return set.contains( artifact );
+ set = filter(set);
+ return set.contains(artifact);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactFilterException.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactFilterException.java
index 0ff0592..298e9d8 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactFilterException.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactFilterException.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,34 +7,32 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
/**
* <p>ArtifactFilterException class.</p>
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class ArtifactFilterException
- extends Exception
-{
+public class ArtifactFilterException extends Exception {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
/**
* Create an instance.
*/
- public ArtifactFilterException()
- {
+ public ArtifactFilterException() {
super();
}
@@ -46,9 +42,8 @@ public class ArtifactFilterException
* @param theMessage The message which describes what happends.
* @param theCause The cause.
*/
- public ArtifactFilterException( String theMessage, Throwable theCause )
- {
- super( theMessage, theCause );
+ public ArtifactFilterException(String theMessage, Throwable theCause) {
+ super(theMessage, theCause);
}
/**
@@ -56,9 +51,8 @@ public class ArtifactFilterException
*
* @param theMessage The message which describes what happends.
*/
- public ArtifactFilterException( String theMessage )
- {
- super( theMessage );
+ public ArtifactFilterException(String theMessage) {
+ super(theMessage);
}
/**
@@ -66,9 +60,7 @@ public class ArtifactFilterException
*
* @param theCause {@link java.lang.Throwable}Â cause of the problem.
*/
- public ArtifactFilterException( Throwable theCause )
- {
- super( theCause );
+ public ArtifactFilterException(Throwable theCause) {
+ super(theCause);
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java
index ef44896..7c0b053 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import org.apache.maven.artifact.Artifact;
@@ -27,25 +26,20 @@ import org.apache.maven.artifact.Artifact;
* @author clove
* @since 2.0-alpha-2
*/
-public class ArtifactIdFilter
- extends AbstractArtifactFeatureFilter
-{
+public class ArtifactIdFilter extends AbstractArtifactFeatureFilter {
/**
* Will setup super with 'ArtifactId' as the filterType
*
* @param include comma separated list of artifactIds to include, may be {@code null}
* @param exclude comma separated list of artifactIds to exclude, may be {@code null}
*/
- public ArtifactIdFilter( String include, String exclude )
- {
- super( include, exclude );
+ public ArtifactIdFilter(String include, String exclude) {
+ super(include, exclude);
}
/** {@inheritDoc} */
@Override
- protected String getArtifactFeature( Artifact artifact )
- {
+ protected String getArtifactFeature(Artifact artifact) {
return artifact.getArtifactId();
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
index e7747ce..042df2f 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,15 +7,19 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
@@ -29,17 +31,12 @@ import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingResult;
import org.eclipse.aether.graph.Dependency;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
/**
* This filter will exclude everything that is not a dependency of the selected artifact.
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class ArtifactTransitivityFilter
- extends AbstractArtifactsFilter
-{
+public class ArtifactTransitivityFilter extends AbstractArtifactsFilter {
/**
* List of dependencyConflictIds of transitiveArtifacts
*/
@@ -65,36 +62,30 @@ public class ArtifactTransitivityFilter
* @param projectBuilder the projectBuilder
* @throws ProjectBuildingException if the project descriptor could not be successfully built
*/
- public ArtifactTransitivityFilter( Artifact artifact, ProjectBuildingRequest buildingRequest,
- ProjectBuilder projectBuilder )
- throws ProjectBuildingException
- {
- ProjectBuildingRequest request = new DefaultProjectBuildingRequest( buildingRequest );
+ public ArtifactTransitivityFilter(
+ Artifact artifact, ProjectBuildingRequest buildingRequest, ProjectBuilder projectBuilder)
+ throws ProjectBuildingException {
+ ProjectBuildingRequest request = new DefaultProjectBuildingRequest(buildingRequest);
- request.setResolveDependencies( true );
+ request.setResolveDependencies(true);
- ProjectBuildingResult buildingResult = projectBuilder.build( artifact, request );
+ ProjectBuildingResult buildingResult = projectBuilder.build(artifact, request);
DependencyResolutionResult resolutionResult = buildingResult.getDependencyResolutionResult();
- if ( resolutionResult != null )
- {
- for ( Dependency dependency : resolutionResult.getDependencies() )
- {
- Artifact mavenArtifact = RepositoryUtils.toArtifact( dependency.getArtifact() );
- transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
+ if (resolutionResult != null) {
+ for (Dependency dependency : resolutionResult.getDependencies()) {
+ Artifact mavenArtifact = RepositoryUtils.toArtifact(dependency.getArtifact());
+ transitiveArtifacts.add(mavenArtifact.getDependencyConflictId());
}
}
}
/** {@inheritDoc} */
- public Set<Artifact> filter( Set<Artifact> artifacts )
- {
+ public Set<Artifact> filter(Set<Artifact> artifacts) {
Set<Artifact> result = new LinkedHashSet<>();
- for ( Artifact artifact : artifacts )
- {
- if ( artifactIsATransitiveDependency( artifact ) )
- {
- result.add( artifact );
+ for (Artifact artifact : artifacts) {
+ if (artifactIsATransitiveDependency(artifact)) {
+ result.add(artifact);
}
}
return result;
@@ -106,8 +97,7 @@ public class ArtifactTransitivityFilter
* @param artifact representing the item to compare.
* @return true if artifact is a transitive dependency
*/
- public boolean artifactIsATransitiveDependency( Artifact artifact )
- {
- return transitiveArtifacts.contains( artifact.getDependencyConflictId() );
+ public boolean artifactIsATransitiveDependency(Artifact artifact) {
+ return transitiveArtifacts.contains(artifact.getDependencyConflictId());
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java
index 1d2e612..472f638 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import java.util.Set;
@@ -28,8 +27,7 @@ import org.apache.maven.artifact.Artifact;
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public interface ArtifactsFilter
-{
+public interface ArtifactsFilter {
/**
* <p>filter.</p>
*
@@ -37,8 +35,7 @@ public interface ArtifactsFilter
* @return Set of artifacts.
* @throws org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException in case of a failure.
*/
- Set<Artifact> filter( Set<Artifact> artifacts )
- throws ArtifactFilterException;
+ Set<Artifact> filter(Set<Artifact> artifacts) throws ArtifactFilterException;
/**
* <p>isArtifactIncluded.</p>
@@ -47,6 +44,5 @@ public interface ArtifactsFilter
* @return {@code true} if artifact is included {@code false} otherwise.
* @throws org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException in case of a failure.
*/
- boolean isArtifactIncluded( Artifact artifact )
- throws ArtifactFilterException;
+ boolean isArtifactIncluded(Artifact artifact) throws ArtifactFilterException;
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java
index fa58795..1034050 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import org.apache.maven.artifact.Artifact;
@@ -26,23 +25,19 @@ import org.apache.maven.artifact.Artifact;
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class ClassifierFilter
- extends AbstractArtifactFeatureFilter
-{
+public class ClassifierFilter extends AbstractArtifactFeatureFilter {
/**
* <p>Constructor for ClassifierFilter.</p>
*
* @param include comma separated list with includes.
* @param exclude comma separated list with excludes.
*/
- public ClassifierFilter( String include, String exclude )
- {
- super( include, exclude );
+ public ClassifierFilter(String include, String exclude) {
+ super(include, exclude);
}
/** {@inheritDoc} */
- protected String getArtifactFeature( Artifact artifact )
- {
+ protected String getArtifactFeature(Artifact artifact) {
return artifact.getClassifier();
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java
index b2347c5..5968aba 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import java.util.ArrayList;
import java.util.List;
@@ -30,23 +29,20 @@ import org.apache.maven.artifact.Artifact;
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class FilterArtifacts
-{
+public class FilterArtifacts {
private List<ArtifactsFilter> filters;
/**
* Created new instance.
*/
- public FilterArtifacts()
- {
+ public FilterArtifacts() {
filters = new ArrayList<>();
}
/**
* Removes all of the elements from this list. The list will be empty after this call returns.
*/
- public void clearFilters()
- {
+ public void clearFilters() {
filters.clear();
}
@@ -55,11 +51,9 @@ public class FilterArtifacts
*
* @param filter element to be appended to this list.
*/
- public void addFilter( ArtifactsFilter filter )
- {
- if ( filter != null )
- {
- filters.add( filter );
+ public void addFilter(ArtifactsFilter filter) {
+ if (filter != null) {
+ filters.add(filter);
}
}
@@ -71,11 +65,9 @@ public class FilterArtifacts
* @param filter the filter to be inserted.
* @throws IndexOutOfBoundsException if index is out of range <code>(index < 0 || index > size())</code>.
*/
- public void addFilter( int index, ArtifactsFilter filter )
- {
- if ( filter != null )
- {
- filters.add( index, filter );
+ public void addFilter(int index, ArtifactsFilter filter) {
+ if (filter != null) {
+ filters.add(index, filter);
}
}
@@ -86,19 +78,13 @@ public class FilterArtifacts
* @return The resulting artifacts set.
* @throws org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException in case of a failure.
*/
- public Set<Artifact> filter( Set<Artifact> artifacts )
- throws ArtifactFilterException
- {
+ public Set<Artifact> filter(Set<Artifact> artifacts) throws ArtifactFilterException {
// apply filters
- for ( ArtifactsFilter filter : filters )
- {
+ for (ArtifactsFilter filter : filters) {
// log(artifacts,log);
- try
- {
- artifacts = filter.filter( artifacts );
- }
- catch ( NullPointerException e )
- {
+ try {
+ artifacts = filter.filter(artifacts);
+ } catch (NullPointerException e) {
// don't do anything, just skip this.
}
}
@@ -111,8 +97,7 @@ public class FilterArtifacts
*
* @return the filters.
*/
- public List<ArtifactsFilter> getFilters()
- {
+ public List<ArtifactsFilter> getFilters() {
return this.filters;
}
@@ -121,8 +106,7 @@ public class FilterArtifacts
*
* @param filters The filters to set.
*/
- public void setFilters( List<ArtifactsFilter> filters )
- {
+ public void setFilters(List<ArtifactsFilter> filters) {
this.filters = filters;
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java
index c4cd109..39580e1 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import org.apache.maven.artifact.Artifact;
@@ -27,9 +26,7 @@ import org.apache.maven.artifact.Artifact;
* @author clove
* @since 2.0
*/
-public class GroupIdFilter
- extends AbstractArtifactFeatureFilter
-{
+public class GroupIdFilter extends AbstractArtifactFeatureFilter {
/**
* Construction will setup the super call with a filtertype of 'GroupId'
@@ -37,23 +34,19 @@ public class GroupIdFilter
* @param include comma separated list of groupIds to include, may be {@code null}
* @param exclude comma separated list of groupIds to exclude, may be {@code null}
*/
- public GroupIdFilter( String include, String exclude )
- {
- super( include, exclude );
+ public GroupIdFilter(String include, String exclude) {
+ super(include, exclude);
}
/** {@inheritDoc} */
@Override
- protected String getArtifactFeature( Artifact artifact )
- {
+ protected String getArtifactFeature(Artifact artifact) {
return artifact.getGroupId();
}
/** {@inheritDoc} */
@Override
- protected boolean compareFeatures( String lhs, String rhs )
- {
- return lhs.startsWith( rhs );
+ protected boolean compareFeatures(String lhs, String rhs) {
+ return lhs.startsWith(rhs);
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java
index 4db9e6d..990b4e3 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -29,9 +28,7 @@ import org.apache.maven.artifact.Artifact;
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class ProjectTransitivityFilter
- extends AbstractArtifactsFilter
-{
+public class ProjectTransitivityFilter extends AbstractArtifactsFilter {
private boolean excludeTransitive;
@@ -43,28 +40,23 @@ public class ProjectTransitivityFilter
* @param directDependencies set of direct dependencies.
* @param excludeTransitive {@code true} exclude transitive deps {@code false} otherwise.
*/
- public ProjectTransitivityFilter( Set<Artifact> directDependencies, boolean excludeTransitive )
- {
+ public ProjectTransitivityFilter(Set<Artifact> directDependencies, boolean excludeTransitive) {
this.excludeTransitive = excludeTransitive;
this.directDependencies = directDependencies;
}
/** {@inheritDoc} */
- public Set<Artifact> filter( Set<Artifact> artifacts )
- {
+ public Set<Artifact> filter(Set<Artifact> artifacts) {
// why not just take the directDependencies here?
// because if this filter is run after some other process, the
// set of artifacts may not be the same as the directDependencies.
Set<Artifact> result = artifacts;
- if ( excludeTransitive )
- {
+ if (excludeTransitive) {
result = new LinkedHashSet<>();
- for ( Artifact artifact : artifacts )
- {
- if ( artifactIsADirectDependency( artifact ) )
- {
- result.add( artifact );
+ for (Artifact artifact : artifacts) {
+ if (artifactIsADirectDependency(artifact)) {
+ result.add(artifact);
}
}
}
@@ -77,12 +69,9 @@ public class ProjectTransitivityFilter
* @param artifact representing the item to compare.
* @return true if artifact is a direct dependency
*/
- public boolean artifactIsADirectDependency( Artifact artifact )
- {
- for ( Artifact dependency : this.directDependencies )
- {
- if ( dependency.equals( artifact ) )
- {
+ public boolean artifactIsADirectDependency(Artifact artifact) {
+ for (Artifact dependency : this.directDependencies) {
+ if (dependency.equals(artifact)) {
return true;
}
}
@@ -94,8 +83,7 @@ public class ProjectTransitivityFilter
*
* @return Returns the excludeTransitive.
*/
- public boolean isExcludeTransitive()
- {
+ public boolean isExcludeTransitive() {
return this.excludeTransitive;
}
@@ -104,8 +92,7 @@ public class ProjectTransitivityFilter
*
* @param excludeTransitive The excludeTransitive to set.
*/
- public void setExcludeTransitive( boolean excludeTransitive )
- {
+ public void setExcludeTransitive(boolean excludeTransitive) {
this.excludeTransitive = excludeTransitive;
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java
index 0d44bcc..b60d5bd 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -33,9 +32,7 @@ import static org.apache.maven.shared.artifact.filter.internal.Utils.isNotEmpty;
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class ScopeFilter
- extends AbstractArtifactsFilter
-{
+public class ScopeFilter extends AbstractArtifactsFilter {
private String includeScope;
@@ -47,8 +44,7 @@ public class ScopeFilter
* @param includeScope the scope to be included.
* @param excludeScope the scope to be excluded.
*/
- public ScopeFilter( String includeScope, String excludeScope )
- {
+ public ScopeFilter(String includeScope, String excludeScope) {
this.includeScope = includeScope;
this.excludeScope = excludeScope;
}
@@ -59,97 +55,76 @@ public class ScopeFilter
* This function determines if filtering needs to be performed. Excludes are
* ignored if Includes are used.
*/
- public Set<Artifact> filter( Set<Artifact> artifacts )
- throws ArtifactFilterException
- {
+ public Set<Artifact> filter(Set<Artifact> artifacts) throws ArtifactFilterException {
Set<Artifact> results = artifacts;
- if ( isNotEmpty( includeScope ) )
- {
- if ( !Artifact.SCOPE_COMPILE.equals( includeScope ) && !Artifact.SCOPE_TEST.equals( includeScope )
- && !Artifact.SCOPE_PROVIDED.equals( includeScope ) && !Artifact.SCOPE_RUNTIME.equals( includeScope )
- && !Artifact.SCOPE_SYSTEM.equals( includeScope ) )
- {
- throw new ArtifactFilterException( "Invalid Scope in includeScope: " + includeScope );
+ if (isNotEmpty(includeScope)) {
+ if (!Artifact.SCOPE_COMPILE.equals(includeScope)
+ && !Artifact.SCOPE_TEST.equals(includeScope)
+ && !Artifact.SCOPE_PROVIDED.equals(includeScope)
+ && !Artifact.SCOPE_RUNTIME.equals(includeScope)
+ && !Artifact.SCOPE_SYSTEM.equals(includeScope)) {
+ throw new ArtifactFilterException("Invalid Scope in includeScope: " + includeScope);
}
results = new LinkedHashSet<>();
- if ( Artifact.SCOPE_PROVIDED.equals( includeScope ) || Artifact.SCOPE_SYSTEM.equals( includeScope ) )
- {
- results = includeSingleScope( artifacts, includeScope );
- }
- else
- {
- ArtifactFilter saf = new ScopeArtifactFilter( includeScope );
-
- for ( Artifact artifact : artifacts )
- {
- if ( saf.include( artifact ) )
- {
- results.add( artifact );
+ if (Artifact.SCOPE_PROVIDED.equals(includeScope) || Artifact.SCOPE_SYSTEM.equals(includeScope)) {
+ results = includeSingleScope(artifacts, includeScope);
+ } else {
+ ArtifactFilter saf = new ScopeArtifactFilter(includeScope);
+
+ for (Artifact artifact : artifacts) {
+ if (saf.include(artifact)) {
+ results.add(artifact);
}
}
}
- }
- else if ( isNotEmpty( excludeScope ) )
- {
- if ( !Artifact.SCOPE_COMPILE.equals( excludeScope ) && !Artifact.SCOPE_TEST.equals( excludeScope )
- && !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_RUNTIME.equals( excludeScope )
- && !Artifact.SCOPE_SYSTEM.equals( excludeScope ) )
- {
- throw new ArtifactFilterException( "Invalid Scope in excludeScope: " + excludeScope );
+ } else if (isNotEmpty(excludeScope)) {
+ if (!Artifact.SCOPE_COMPILE.equals(excludeScope)
+ && !Artifact.SCOPE_TEST.equals(excludeScope)
+ && !Artifact.SCOPE_PROVIDED.equals(excludeScope)
+ && !Artifact.SCOPE_RUNTIME.equals(excludeScope)
+ && !Artifact.SCOPE_SYSTEM.equals(excludeScope)) {
+ throw new ArtifactFilterException("Invalid Scope in excludeScope: " + excludeScope);
}
results = new LinkedHashSet<>();
// plexus ScopeArtifactFilter doesn't handle the provided scope so
// we
// need special handling for it.
- if ( Artifact.SCOPE_TEST.equals( excludeScope ) )
- {
- throw new ArtifactFilterException( " Can't exclude Test scope, this will exclude everything." );
- }
- else if ( !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_SYSTEM.equals( excludeScope ) )
- {
- ArtifactFilter saf = new ScopeArtifactFilter( excludeScope );
-
- for ( Artifact artifact : artifacts )
- {
- if ( !saf.include( artifact ) )
- {
- results.add( artifact );
+ if (Artifact.SCOPE_TEST.equals(excludeScope)) {
+ throw new ArtifactFilterException(" Can't exclude Test scope, this will exclude everything.");
+ } else if (!Artifact.SCOPE_PROVIDED.equals(excludeScope) && !Artifact.SCOPE_SYSTEM.equals(excludeScope)) {
+ ArtifactFilter saf = new ScopeArtifactFilter(excludeScope);
+
+ for (Artifact artifact : artifacts) {
+ if (!saf.include(artifact)) {
+ results.add(artifact);
}
}
- }
- else
- {
- results = excludeSingleScope( artifacts, excludeScope );
+ } else {
+ results = excludeSingleScope(artifacts, excludeScope);
}
}
return results;
}
- private Set<Artifact> includeSingleScope( Set<Artifact> artifacts, String scope )
- {
+ private Set<Artifact> includeSingleScope(Set<Artifact> artifacts, String scope) {
Set<Artifact> results = new LinkedHashSet<>();
- for ( Artifact artifact : artifacts )
- {
- if ( scope.equals( artifact.getScope() ) )
- {
- results.add( artifact );
+ for (Artifact artifact : artifacts) {
+ if (scope.equals(artifact.getScope())) {
+ results.add(artifact);
}
}
return results;
}
- private Set<Artifact> excludeSingleScope( Set<Artifact> artifacts, String scope )
- {
+ private Set<Artifact> excludeSingleScope(Set<Artifact> artifacts, String scope) {
Set<Artifact> results = new LinkedHashSet<>();
- for ( Artifact artifact : artifacts )
- {
- if ( !scope.equals( artifact.getScope() ) )
- {
- results.add( artifact );
+ for (Artifact artifact : artifacts) {
+ if (!scope.equals(artifact.getScope())) {
+ results.add(artifact);
}
}
return results;
@@ -160,8 +135,7 @@ public class ScopeFilter
*
* @return Returns the includeScope.
*/
- public String getIncludeScope()
- {
+ public String getIncludeScope() {
return this.includeScope;
}
@@ -171,8 +145,7 @@ public class ScopeFilter
* @param scope
* The includeScope to set.
*/
- public void setIncludeScope( String scope )
- {
+ public void setIncludeScope(String scope) {
this.includeScope = scope;
}
@@ -181,8 +154,7 @@ public class ScopeFilter
*
* @return Returns the excludeScope.
*/
- public String getExcludeScope()
- {
+ public String getExcludeScope() {
return this.excludeScope;
}
@@ -192,9 +164,7 @@ public class ScopeFilter
* @param scope
* The excludeScope to set.
*/
- public void setExcludeScope( String scope )
- {
+ public void setExcludeScope(String scope) {
this.excludeScope = scope;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java
index 98ffac9..62a071f 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,15 +7,16 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
import org.apache.maven.artifact.Artifact;
@@ -26,23 +25,19 @@ import org.apache.maven.artifact.Artifact;
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class TypeFilter
- extends AbstractArtifactFeatureFilter
-{
+public class TypeFilter extends AbstractArtifactFeatureFilter {
/**
* <p>Constructor for TypeFilter.</p>
*
* @param include comma separated list with includes.
* @param exclude comma separated list with excludes.
*/
- public TypeFilter( String include, String exclude )
- {
- super( include, exclude );
+ public TypeFilter(String include, String exclude) {
+ super(include, exclude);
}
/** {@inheritDoc} */
- protected String getArtifactFeature( Artifact artifact )
- {
+ protected String getArtifactFeature(Artifact artifact) {
return artifact.getType();
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/internal/Utils.java b/src/main/java/org/apache/maven/shared/artifact/filter/internal/Utils.java
index c3aa289..43360c4 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/internal/Utils.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/internal/Utils.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.internal;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,17 +16,15 @@ package org.apache.maven.shared.artifact.filter.internal;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.internal;
/**
* Utilities.
*
* @since TBD
*/
-public final class Utils
-{
- private Utils()
- {
- }
+public final class Utils {
+ private Utils() {}
/**
* <p>Checks if a String is non <code>null</code> and is
@@ -37,8 +33,7 @@ public final class Utils
* @param str the String to check
* @return true if the String is non-null, and not length zero
*/
- public static boolean isNotEmpty( String str )
- {
- return ( ( str != null ) && ( str.length() > 0 ) );
+ public static boolean isNotEmpty(String str) {
+ return str != null && !str.isEmpty();
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java
index 2e39e22..a5b365a 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AbstractFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
import java.util.List;
@@ -27,14 +26,12 @@ import java.util.List;
* @author Robert Scholte
* @since 3.0
*/
-public abstract class AbstractFilter implements TransformableFilter
-{
+public abstract class AbstractFilter implements TransformableFilter {
/** {@inheritDoc} */
@Override
- public final <T> T transform( FilterTransformer<T> transformer )
- {
- return transformer.transform( this );
+ public final <T> T transform(FilterTransformer<T> transformer) {
+ return transformer.transform(this);
}
/**
@@ -44,5 +41,5 @@ public abstract class AbstractFilter implements TransformableFilter
* @param parents {@link org.apache.maven.shared.artifact.filter.resolve.Node}s.
* @return {@code true} / {@code false}
*/
- public abstract boolean accept( Node node, List<Node> parents );
+ public abstract boolean accept(Node node, List<Node> parents);
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java
index 7e92b34..8becc17 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/AndFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
import java.util.Collection;
import java.util.Collections;
@@ -29,9 +28,7 @@ import java.util.Collections;
* @since 3.0
* @see org.eclipse.aether.util.filter.AndDependencyFilter
*/
-public class AndFilter
- implements TransformableFilter
-{
+public class AndFilter implements TransformableFilter {
private final Collection<TransformableFilter> filters;
/**
@@ -39,9 +36,8 @@ public class AndFilter
*
* @param filters the filters, may not be {@code null}
*/
- public AndFilter( Collection<TransformableFilter> filters )
- {
- this.filters = Collections.unmodifiableCollection( filters );
+ public AndFilter(Collection<TransformableFilter> filters) {
+ this.filters = Collections.unmodifiableCollection(filters);
}
/**
@@ -49,8 +45,7 @@ public class AndFilter
*
* @return the filters, never {@code null}
*/
- public Collection<TransformableFilter> getFilters()
- {
+ public Collection<TransformableFilter> getFilters() {
return filters;
}
@@ -60,9 +55,7 @@ public class AndFilter
* Transform this filter to a tool specific implementation
*/
@Override
- public <T> T transform( FilterTransformer<T> transformer )
- {
- return transformer.transform( this );
+ public <T> T transform(FilterTransformer<T> transformer) {
+ return transformer.transform(this);
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java
index cec4a86..107c9af 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ExclusionsFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
import java.util.Collection;
import java.util.Collections;
@@ -29,9 +28,7 @@ import java.util.Collections;
* @since 3.0
* @see org.eclipse.aether.util.filter.ExclusionsDependencyFilter
*/
-public class ExclusionsFilter
- implements TransformableFilter
-{
+public class ExclusionsFilter implements TransformableFilter {
private final Collection<String> excludes;
/**
@@ -40,9 +37,8 @@ public class ExclusionsFilter
* @param excludes the keys to exclude, may not be {@code null}
* @see org.apache.maven.artifact.Artifact#getDependencyConflictId()
*/
- public ExclusionsFilter( Collection<String> excludes )
- {
- this.excludes = Collections.unmodifiableCollection( excludes );
+ public ExclusionsFilter(Collection<String> excludes) {
+ this.excludes = Collections.unmodifiableCollection(excludes);
}
/**
@@ -50,8 +46,7 @@ public class ExclusionsFilter
*
* @return The list of excludes.
*/
- public final Collection<String> getExcludes()
- {
+ public final Collection<String> getExcludes() {
return excludes;
}
@@ -61,8 +56,7 @@ public class ExclusionsFilter
* Transform this filter to a tool specific implementation
*/
@Override
- public <T> T transform( FilterTransformer<T> transformer )
- {
- return transformer.transform( this );
+ public <T> T transform(FilterTransformer<T> transformer) {
+ return transformer.transform(this);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java
index 7c77ccb..a99b47e 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/FilterTransformer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
/**
* Provide a mechanism to transform a Filter to a tool specific equivalent using the visitor pattern.
@@ -27,15 +26,14 @@ package org.apache.maven.shared.artifact.filter.resolve;
* @param <T> the tool specific filter
* @since 3.0
*/
-public interface FilterTransformer<T>
-{
+public interface FilterTransformer<T> {
/**
* Transform the scopeFilter to T specific implementation
*
* @param scopeFilter the filter
* @return the transformed filter, never {@code null}
*/
- T transform( ScopeFilter scopeFilter );
+ T transform(ScopeFilter scopeFilter);
/**
* Transform the andFilter to T specific implementation
@@ -43,7 +41,7 @@ public interface FilterTransformer<T>
* @param andFilter the filter
* @return the transformed filter, never {@code null}
*/
- T transform( AndFilter andFilter );
+ T transform(AndFilter andFilter);
/**
* Transform the exclusionsFilter to T specific implementation
@@ -51,7 +49,7 @@ public interface FilterTransformer<T>
* @param exclusionsFilter the filter
* @return the transformed filter, never {@code null}
*/
- T transform( ExclusionsFilter exclusionsFilter );
+ T transform(ExclusionsFilter exclusionsFilter);
/**
* Transform the orFilter to T specific implementation
@@ -59,7 +57,7 @@ public interface FilterTransformer<T>
* @param orFilter the filter
* @return the transformed filter, never {@code null}
*/
- T transform( OrFilter orFilter );
+ T transform(OrFilter orFilter);
/**
* Transform the patternExclusionsFilter to T specific implementation
@@ -67,7 +65,7 @@ public interface FilterTransformer<T>
* @param patternExclusionsFilter the filter
* @return the transformed filter, never {@code null}
*/
- T transform( PatternExclusionsFilter patternExclusionsFilter );
+ T transform(PatternExclusionsFilter patternExclusionsFilter);
/**
* Transform the paternInclusionsFilter to T specific implementation
@@ -75,7 +73,7 @@ public interface FilterTransformer<T>
* @param patternInclusionsFilter the filter
* @return the transformed filter, never {@code null}
*/
- T transform( PatternInclusionsFilter patternInclusionsFilter );
+ T transform(PatternInclusionsFilter patternInclusionsFilter);
/**
* Transform a custom filter to T specific implementation
@@ -83,5 +81,5 @@ public interface FilterTransformer<T>
* @param abstractFilter the filter
* @return the transformed filter, never {@code null}
*/
- T transform( AbstractFilter abstractFilter );
+ T transform(AbstractFilter abstractFilter);
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java
index d4e81b2..72ecd69 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/Node.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
/**
* Represents a node of a dependency graph
@@ -25,13 +24,11 @@ package org.apache.maven.shared.artifact.filter.resolve;
* @author Robert Scholte
* @since 3.0
*/
-public interface Node
-{
+public interface Node {
/**
* <p>getDependency.</p>
*
* @return {@link org.apache.maven.model.Dependency}
*/
org.apache.maven.model.Dependency getDependency();
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java
index 691a793..74f4046 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/OrFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
import java.util.Collection;
import java.util.Collections;
@@ -29,8 +28,7 @@ import java.util.Collections;
* @since 3.0
* @see org.eclipse.aether.util.filter.OrDependencyFilter
*/
-public class OrFilter implements TransformableFilter
-{
+public class OrFilter implements TransformableFilter {
private final Collection<TransformableFilter> filters;
@@ -39,29 +37,26 @@ public class OrFilter implements TransformableFilter
*
* @param filters the filters, may not be {@code null}
*/
- public OrFilter( Collection<TransformableFilter> filters )
- {
- this.filters = Collections.unmodifiableCollection( filters );
+ public OrFilter(Collection<TransformableFilter> filters) {
+ this.filters = Collections.unmodifiableCollection(filters);
}
-
+
/**
* Get the filters
*
* @return the filters, never {@code null}
*/
- public Collection<TransformableFilter> getFilters()
- {
+ public Collection<TransformableFilter> getFilters() {
return filters;
}
-
+
/**
* {@inheritDoc}
*
* Transform this filter to a tool specific implementation
*/
@Override
- public <T> T transform( FilterTransformer<T> transformer )
- {
- return transformer.transform( this );
+ public <T> T transform(FilterTransformer<T> transformer) {
+ return transformer.transform(this);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java
index 8778f85..ceaa9ee 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternExclusionsFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
import java.util.Collection;
import java.util.Collections;
@@ -42,28 +41,25 @@ import java.util.Collections;
* @see org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter
* @see org.eclipse.aether.version.VersionScheme
*/
-public class PatternExclusionsFilter implements TransformableFilter
-{
-
+public class PatternExclusionsFilter implements TransformableFilter {
+
private final Collection<String> excludes;
-
+
/**
* The default constructor specifying a collection of pattern based keys which must be excluded.
*
* @param excludes the excludes, must not be {@code null}
*/
- public PatternExclusionsFilter( Collection<String> excludes )
- {
- this.excludes = Collections.unmodifiableCollection( excludes );
+ public PatternExclusionsFilter(Collection<String> excludes) {
+ this.excludes = Collections.unmodifiableCollection(excludes);
}
-
+
/**
* Get the excludes
*
* @return the excluded keys, never {@code null}
*/
- public final Collection<String> getExcludes()
- {
+ public final Collection<String> getExcludes() {
return excludes;
}
@@ -73,8 +69,7 @@ public class PatternExclusionsFilter implements TransformableFilter
* Transform this filter to a tool specific implementation
*/
@Override
- public <T> T transform( FilterTransformer<T> transformer )
- {
- return transformer.transform( this );
+ public <T> T transform(FilterTransformer<T> transformer) {
+ return transformer.transform(this);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java
index ca92cdb..982b986 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/PatternInclusionsFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
import java.util.Collection;
import java.util.Collections;
@@ -43,28 +42,25 @@ import java.util.Collections;
* @see org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter
* @see org.eclipse.aether.version.VersionScheme
*/
-public class PatternInclusionsFilter implements TransformableFilter
-{
-
+public class PatternInclusionsFilter implements TransformableFilter {
+
private final Collection<String> includes;
-
+
/**
* The default constructor specifying a collection of pattern based keys which must be included.
*
* @param includes the includes
*/
- public PatternInclusionsFilter( Collection<String> includes )
- {
- this.includes = Collections.unmodifiableCollection( includes );
+ public PatternInclusionsFilter(Collection<String> includes) {
+ this.includes = Collections.unmodifiableCollection(includes);
}
-
+
/**
* Get the includes
*
* @return the includes,
*/
- public final Collection<String> getIncludes()
- {
+ public final Collection<String> getIncludes() {
return includes;
}
@@ -74,8 +70,7 @@ public class PatternInclusionsFilter implements TransformableFilter
* Transform this filter to a tool specific implementation
*/
@Override
- public <T> T transform( FilterTransformer<T> transformer )
- {
- return transformer.transform( this );
+ public <T> T transform(FilterTransformer<T> transformer) {
+ return transformer.transform(this);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java
index fe874a0..e408190 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/ScopeFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
import java.util.Arrays;
import java.util.Collection;
@@ -30,8 +29,7 @@ import java.util.Collections;
* @since 3.0
* @see org.eclipse.aether.util.filter.ScopeDependencyFilter
*/
-public class ScopeFilter implements TransformableFilter
-{
+public class ScopeFilter implements TransformableFilter {
private final Collection<String> excluded;
private final Collection<String> included;
@@ -42,21 +40,19 @@ public class ScopeFilter implements TransformableFilter
* @param included specific scopes to include or {@code null} to include all
* @param excluded specific scopes to exclude or {@code null} to exclude none
*/
- public ScopeFilter( Collection<String> included, Collection<String> excluded )
- {
- this.included = ( included == null ? null : Collections.unmodifiableCollection( included ) );
- this.excluded = ( excluded == null ? null : Collections.unmodifiableCollection( excluded ) );
+ public ScopeFilter(Collection<String> included, Collection<String> excluded) {
+ this.included = (included == null ? null : Collections.unmodifiableCollection(included));
+ this.excluded = (excluded == null ? null : Collections.unmodifiableCollection(excluded));
}
-
+
/**
* Construct a ScopeFilter based on included scopes
*
* @param included the scopes to include, may be {@code null}
* @return the filter, never {@code null}
*/
- public static ScopeFilter including( Collection<String> included )
- {
- return new ScopeFilter( included, null );
+ public static ScopeFilter including(Collection<String> included) {
+ return new ScopeFilter(included, null);
}
/**
@@ -65,9 +61,8 @@ public class ScopeFilter implements TransformableFilter
* @param included the scopes to include, must not be {@code null}
* @return the filter, never {@code null}
*/
- public static ScopeFilter including( String... included )
- {
- return new ScopeFilter( Arrays.asList( included ), null );
+ public static ScopeFilter including(String... included) {
+ return new ScopeFilter(Arrays.asList(included), null);
}
/**
@@ -76,9 +71,8 @@ public class ScopeFilter implements TransformableFilter
* @param excluded the scopes to exclude, may be {@code null}
* @return the filter, never {@code null}
*/
- public static ScopeFilter excluding( Collection<String> excluded )
- {
- return new ScopeFilter( null, excluded );
+ public static ScopeFilter excluding(Collection<String> excluded) {
+ return new ScopeFilter(null, excluded);
}
/**
@@ -87,9 +81,8 @@ public class ScopeFilter implements TransformableFilter
* @param excluded the scopes to exclude, must not be {@code null}
* @return the filter, never {@code null}
*/
- public static ScopeFilter excluding( String... excluded )
- {
- return new ScopeFilter( null, Arrays.asList( excluded ) );
+ public static ScopeFilter excluding(String... excluded) {
+ return new ScopeFilter(null, Arrays.asList(excluded));
}
/**
@@ -97,28 +90,25 @@ public class ScopeFilter implements TransformableFilter
*
* @return the scopes to exclude, may be {@code null}
*/
- public final Collection<String> getExcluded()
- {
+ public final Collection<String> getExcluded() {
return excluded;
}
-
+
/**
* Get the included scopes
*
* @return the scopes to include, may be {@code null}
*/
- public final Collection<String> getIncluded()
- {
+ public final Collection<String> getIncluded() {
return included;
}
-
+
/**
* {@inheritDoc}
*
* Transform this filter to a tool specific implementation
*/
- public <T> T transform ( FilterTransformer<T> transformer )
- {
- return transformer.transform( this );
+ public <T> T transform(FilterTransformer<T> transformer) {
+ return transformer.transform(this);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/TransformableFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/TransformableFilter.java
index 0b71126..e4392b3 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/TransformableFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/TransformableFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve;
/**
* The element interface of the visitor pattern for transforming filters.
@@ -25,8 +24,7 @@ package org.apache.maven.shared.artifact.filter.resolve;
* @author Robert Scholte
* @since 3.0
*/
-public interface TransformableFilter
-{
+public interface TransformableFilter {
/**
* Subclasses should include the following code:
* <pre>
@@ -41,5 +39,5 @@ public interface TransformableFilter
* @param transformer the tool specific transformer, may not be {@code null}
* @return the transformed value, never {@code null}
*/
- <T> T transform( FilterTransformer<T> transformer );
+ <T> T transform(FilterTransformer<T> transformer);
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java
index 833a911..407e790 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve.transform;
import java.util.ArrayList;
import java.util.Collection;
@@ -46,8 +45,7 @@ import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
* @author Robert Scholte
* @since 3.0
*/
-public class ArtifactIncludeFilterTransformer implements FilterTransformer<ArtifactFilter>
-{
+public class ArtifactIncludeFilterTransformer implements FilterTransformer<ArtifactFilter> {
private boolean includeNullScope = true;
@@ -61,8 +59,7 @@ public class ArtifactIncludeFilterTransformer implements FilterTransformer<Artif
*
* @param includeNullScope set to {@code false} if {@code null}-scoped Artifacts should not be included
*/
- public void setIncludeNullScope( boolean includeNullScope )
- {
+ public void setIncludeNullScope(boolean includeNullScope) {
this.includeNullScope = includeNullScope;
}
@@ -76,41 +73,31 @@ public class ArtifactIncludeFilterTransformer implements FilterTransformer<Artif
* @param actTransitivelyPattern set to {@code true} if this artifact should be included/excluded just like one of
* its ancestors.
*/
- public void setActTransitivelyPattern( boolean actTransitivelyPattern )
- {
+ public void setActTransitivelyPattern(boolean actTransitivelyPattern) {
this.actTransitivelyPattern = actTransitivelyPattern;
}
/** {@inheritDoc} */
@Override
- public ArtifactFilter transform( final ScopeFilter scopeFilter )
- {
- return artifact ->
- {
- if ( artifact.getScope() == null )
- {
+ public ArtifactFilter transform(final ScopeFilter scopeFilter) {
+ return artifact -> {
+ if (artifact.getScope() == null) {
return includeNullScope;
}
boolean isIncluded;
- if ( scopeFilter.getIncluded() != null )
- {
- isIncluded = scopeFilter.getIncluded().contains( artifact.getScope() );
- }
- else
- {
+ if (scopeFilter.getIncluded() != null) {
+ isIncluded = scopeFilter.getIncluded().contains(artifact.getScope());
+ } else {
isIncluded = true;
}
boolean isExcluded;
- if ( scopeFilter.getExcluded() != null )
- {
- isExcluded = scopeFilter.getExcluded().contains( artifact.getScope() );
- }
- else
- {
+ if (scopeFilter.getExcluded() != null) {
+ isExcluded = scopeFilter.getExcluded().contains(artifact.getScope());
+ } else {
isExcluded = false;
}
@@ -120,13 +107,11 @@ public class ArtifactIncludeFilterTransformer implements FilterTransformer<Artif
/** {@inheritDoc} */
@Override
- public AndArtifactFilter transform( AndFilter andFilter )
- {
+ public AndArtifactFilter transform(AndFilter andFilter) {
AndArtifactFilter filter = new AndArtifactFilter();
- for ( TransformableFilter subFilter : andFilter.getFilters() )
- {
- filter.add( subFilter.transform( this ) );
+ for (TransformableFilter subFilter : andFilter.getFilters()) {
+ filter.add(subFilter.transform(this));
}
return filter;
@@ -134,28 +119,23 @@ public class ArtifactIncludeFilterTransformer implements FilterTransformer<Artif
/** {@inheritDoc} */
@Override
- public ArtifactFilter transform( final ExclusionsFilter exclusionsFilter )
- {
- return new ExcludesArtifactFilter( new ArrayList<>( exclusionsFilter.getExcludes() ) );
+ public ArtifactFilter transform(final ExclusionsFilter exclusionsFilter) {
+ return new ExcludesArtifactFilter(new ArrayList<>(exclusionsFilter.getExcludes()));
}
/** {@inheritDoc} */
@Override
- public ArtifactFilter transform( OrFilter orFilter )
- {
- final Collection<ArtifactFilter> filters = new ArrayList<>( orFilter.getFilters().size() );
+ public ArtifactFilter transform(OrFilter orFilter) {
+ final Collection<ArtifactFilter> filters =
+ new ArrayList<>(orFilter.getFilters().size());
- for ( TransformableFilter subFilter : orFilter.getFilters() )
- {
- filters.add( subFilter.transform( this ) );
+ for (TransformableFilter subFilter : orFilter.getFilters()) {
+ filters.add(subFilter.transform(this));
}
- return artifact ->
- {
- for ( ArtifactFilter filter : filters )
- {
- if ( filter.include( artifact ) )
- {
+ return artifact -> {
+ for (ArtifactFilter filter : filters) {
+ if (filter.include(artifact)) {
return true;
}
}
@@ -165,22 +145,19 @@ public class ArtifactIncludeFilterTransformer implements FilterTransformer<Artif
/** {@inheritDoc} */
@Override
- public ArtifactFilter transform( PatternExclusionsFilter patternExclusionsFilter )
- {
- return new PatternExcludesArtifactFilter( patternExclusionsFilter.getExcludes(), actTransitivelyPattern );
+ public ArtifactFilter transform(PatternExclusionsFilter patternExclusionsFilter) {
+ return new PatternExcludesArtifactFilter(patternExclusionsFilter.getExcludes(), actTransitivelyPattern);
}
/** {@inheritDoc} */
@Override
- public ArtifactFilter transform( PatternInclusionsFilter patternInclusionsFilter )
- {
- return new PatternIncludesArtifactFilter( patternInclusionsFilter.getIncludes(), actTransitivelyPattern );
+ public ArtifactFilter transform(PatternInclusionsFilter patternInclusionsFilter) {
+ return new PatternIncludesArtifactFilter(patternInclusionsFilter.getIncludes(), actTransitivelyPattern);
}
/** {@inheritDoc} */
@Override
- public ArtifactFilter transform( final AbstractFilter filter )
- {
- return artifact -> filter.accept( new ArtifactIncludeNode( artifact ), null );
+ public ArtifactFilter transform(final AbstractFilter filter) {
+ return artifact -> filter.accept(new ArtifactIncludeNode(artifact), null);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNode.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNode.java
index 2c8b7c5..346443d 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNode.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNode.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* "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
+ * 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
@@ -18,25 +16,24 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve.transform;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.shared.artifact.filter.resolve.Node;
/**
- *
+ *
* @author Robert Scholte
* @since 3.0
*/
-class ArtifactIncludeNode implements Node
-{
+class ArtifactIncludeNode implements Node {
private final Artifact artifact;
-
- ArtifactIncludeNode( Artifact artifact )
- {
+
+ ArtifactIncludeNode(Artifact artifact) {
this.artifact = artifact;
}
-
+
/**
* {@inheritDoc}
*
@@ -45,20 +42,17 @@ class ArtifactIncludeNode implements Node
* @see EclipseAetherNode
*/
@Override
- public Dependency getDependency()
- {
+ public Dependency getDependency() {
Dependency mavenDependency = new Dependency();
- mavenDependency.setGroupId( artifact.getGroupId() );
- mavenDependency.setArtifactId( artifact.getArtifactId() );
- mavenDependency.setVersion( artifact.getVersion() );
- mavenDependency.setClassifier( artifact.getClassifier() );
- mavenDependency.setType( artifact.getType() );
- mavenDependency.setScope( artifact.getScope() );
- mavenDependency.setOptional( artifact.isOptional() );
+ mavenDependency.setGroupId(artifact.getGroupId());
+ mavenDependency.setArtifactId(artifact.getArtifactId());
+ mavenDependency.setVersion(artifact.getVersion());
+ mavenDependency.setClassifier(artifact.getClassifier());
+ mavenDependency.setType(artifact.getType());
+ mavenDependency.setScope(artifact.getScope());
+ mavenDependency.setOptional(artifact.isOptional());
// no setExcludes possible
-
+
return mavenDependency;
}
-
-
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
index 543302d..2ac4200 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve.transform;
import java.util.ArrayList;
import java.util.Collection;
@@ -25,8 +24,6 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static java.util.Objects.requireNonNull;
-
import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter;
import org.apache.maven.shared.artifact.filter.resolve.AndFilter;
import org.apache.maven.shared.artifact.filter.resolve.ExclusionsFilter;
@@ -44,15 +41,15 @@ import org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter;
import org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter;
import org.eclipse.aether.util.filter.ScopeDependencyFilter;
+import static java.util.Objects.requireNonNull;
+
/**
* FilterTransformer implementation for Eclipse Aether.
*
* @author Robert Scholte
* @since 3.0
*/
-public class EclipseAetherFilterTransformer
- implements FilterTransformer<DependencyFilter>
-{
+public class EclipseAetherFilterTransformer implements FilterTransformer<DependencyFilter> {
/**
* When using as regular expression, group(1) + group(3) will be the coordinate,
* group(2) will be the classifier.
@@ -61,118 +58,97 @@ public class EclipseAetherFilterTransformer
/** {@inheritDoc} */
@Override
- public AndDependencyFilter transform( AndFilter andFilter )
- {
+ public AndDependencyFilter transform(AndFilter andFilter) {
Collection<DependencyFilter> filters = new ArrayList<>();
- for ( TransformableFilter filter : andFilter.getFilters() )
- {
- filters.add( filter.transform( this ) );
+ for (TransformableFilter filter : andFilter.getFilters()) {
+ filters.add(filter.transform(this));
}
- return new AndDependencyFilter( filters );
+ return new AndDependencyFilter(filters);
}
/** {@inheritDoc} */
@Override
- public ExclusionsDependencyFilter transform( ExclusionsFilter filter )
- {
- return new ExclusionsDependencyFilter( filter.getExcludes() );
+ public ExclusionsDependencyFilter transform(ExclusionsFilter filter) {
+ return new ExclusionsDependencyFilter(filter.getExcludes());
}
/** {@inheritDoc} */
@Override
- public OrDependencyFilter transform( OrFilter orFilter )
- {
+ public OrDependencyFilter transform(OrFilter orFilter) {
Collection<DependencyFilter> filters = new ArrayList<>();
- for ( TransformableFilter filter : orFilter.getFilters() )
- {
- filters.add( filter.transform( this ) );
+ for (TransformableFilter filter : orFilter.getFilters()) {
+ filters.add(filter.transform(this));
}
- return new OrDependencyFilter( filters );
+ return new OrDependencyFilter(filters);
}
/** {@inheritDoc} */
@Override
- public ScopeDependencyFilter transform( ScopeFilter filter )
- {
- return new ScopeDependencyFilter( filter.getIncluded(), filter.getExcluded() );
+ public ScopeDependencyFilter transform(ScopeFilter filter) {
+ return new ScopeDependencyFilter(filter.getIncluded(), filter.getExcluded());
}
/** {@inheritDoc} */
@Override
- public DependencyFilter transform( PatternExclusionsFilter filter )
- {
- return new PatternExclusionsDependencyFilter( filter.getExcludes() );
+ public DependencyFilter transform(PatternExclusionsFilter filter) {
+ return new PatternExclusionsDependencyFilter(filter.getExcludes());
}
/** {@inheritDoc} */
@Override
- public DependencyFilter transform( PatternInclusionsFilter filter )
- {
+ public DependencyFilter transform(PatternInclusionsFilter filter) {
// if any include contains a classifier:
// split all includes and make it an or-filter for every include
// for the classifier, add an and-filter with a classifierfilter and patterninclusionfilter
- for ( String include : filter.getIncludes() )
- {
- if ( include.matches( GAE_C_V ) )
- {
- return newAdvancedPatternInclusionFilter( filter.getIncludes() );
+ for (String include : filter.getIncludes()) {
+ if (include.matches(GAE_C_V)) {
+ return newAdvancedPatternInclusionFilter(filter.getIncludes());
}
}
- return new PatternInclusionsDependencyFilter( filter.getIncludes() );
+ return new PatternInclusionsDependencyFilter(filter.getIncludes());
}
/** {@inheritDoc} */
@Override
- public DependencyFilter transform( final AbstractFilter filter )
- {
- return ( node, parents ) ->
- {
- requireNonNull( node, "node cannot be null" );
- requireNonNull( parents, "parents cannot be null" );
-
- return filter.accept( new EclipseAetherNode( node ), null );
+ public DependencyFilter transform(final AbstractFilter filter) {
+ return (node, parents) -> {
+ requireNonNull(node, "node cannot be null");
+ requireNonNull(parents, "parents cannot be null");
+
+ return filter.accept(new EclipseAetherNode(node), null);
};
}
- private DependencyFilter newAdvancedPatternInclusionFilter( Collection<String> includes )
- {
- List<DependencyFilter> filters = new ArrayList<>( includes.size() );
+ private DependencyFilter newAdvancedPatternInclusionFilter(Collection<String> includes) {
+ List<DependencyFilter> filters = new ArrayList<>(includes.size());
- Pattern pattern = Pattern.compile( GAE_C_V );
- for ( String include : includes )
- {
- Matcher matcher = pattern.matcher( include );
- if ( matcher.matches() )
- {
+ Pattern pattern = Pattern.compile(GAE_C_V);
+ for (String include : includes) {
+ Matcher matcher = pattern.matcher(include);
+ if (matcher.matches()) {
DependencyFilter patternFilter =
- new PatternInclusionsDependencyFilter( matcher.group( 1 ) + matcher.group( 3 ) );
+ new PatternInclusionsDependencyFilter(matcher.group(1) + matcher.group(3));
- final String classifier = matcher.group( 2 );
+ final String classifier = matcher.group(2);
- filters.add( new AndDependencyFilter( patternFilter, ( node, parents ) ->
- {
- requireNonNull( node, "node cannot be null" );
- requireNonNull( parents, "parents cannot be null" );
+ filters.add(new AndDependencyFilter(patternFilter, (node, parents) -> {
+ requireNonNull(node, "node cannot be null");
+ requireNonNull(parents, "parents cannot be null");
String nodeClassifier = node.getArtifact().getClassifier();
- if ( nodeClassifier == null )
- {
+ if (nodeClassifier == null) {
return false;
+ } else {
+ return "*".equals(classifier) || nodeClassifier.matches(classifier);
}
- else
- {
- return "*".equals( classifier ) || nodeClassifier.matches( classifier );
- }
- } ) );
- }
- else
- {
- filters.add( new PatternInclusionsDependencyFilter( include ) );
+ }));
+ } else {
+ filters.add(new PatternInclusionsDependencyFilter(include));
}
}
- return new OrDependencyFilter( filters );
+ return new OrDependencyFilter(filters);
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
index eb6c973..05e51cc 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter.resolve.transform;
import java.util.ArrayList;
import java.util.List;
@@ -29,64 +28,56 @@ import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.graph.Exclusion;
/**
- * Adapter of an Eclipse Aether DependencyNode for common Node
- *
+ * Adapter of an Eclipse Aether DependencyNode for common Node
+ *
* @author Robert Scholte
* @since 3.0
*/
-class EclipseAetherNode implements Node
-{
+class EclipseAetherNode implements Node {
private final DependencyNode node;
- EclipseAetherNode( DependencyNode node )
- {
+ EclipseAetherNode(DependencyNode node) {
this.node = node;
}
/** {@inheritDoc} */
@Override
- public org.apache.maven.model.Dependency getDependency()
- {
+ public org.apache.maven.model.Dependency getDependency() {
Dependency nodeDependency = node.getDependency();
- if ( nodeDependency == null )
- {
+ if (nodeDependency == null) {
return null;
}
org.apache.maven.model.Dependency mavenDependency = new org.apache.maven.model.Dependency();
- mavenDependency.setGroupId( nodeDependency.getArtifact().getGroupId() );
- mavenDependency.setArtifactId( nodeDependency.getArtifact().getArtifactId() );
- mavenDependency.setVersion( nodeDependency.getArtifact().getVersion() );
- mavenDependency.setClassifier( nodeDependency.getArtifact().getClassifier() );
- mavenDependency.setType( nodeDependency.getArtifact().getProperty( ArtifactProperties.TYPE, null ) );
- mavenDependency.setScope( nodeDependency.getScope() );
+ mavenDependency.setGroupId(nodeDependency.getArtifact().getGroupId());
+ mavenDependency.setArtifactId(nodeDependency.getArtifact().getArtifactId());
+ mavenDependency.setVersion(nodeDependency.getArtifact().getVersion());
+ mavenDependency.setClassifier(nodeDependency.getArtifact().getClassifier());
+ mavenDependency.setType(nodeDependency.getArtifact().getProperty(ArtifactProperties.TYPE, null));
+ mavenDependency.setScope(nodeDependency.getScope());
// Eclipse Aether supports three-valued logic
- if ( nodeDependency.getOptional() != null )
- {
- mavenDependency.setOptional( nodeDependency.isOptional() );
+ if (nodeDependency.getOptional() != null) {
+ mavenDependency.setOptional(nodeDependency.isOptional());
}
- if ( nodeDependency.getExclusions() != null )
- {
+ if (nodeDependency.getExclusions() != null) {
List<org.apache.maven.model.Exclusion> mavenExclusions =
- new ArrayList<>( nodeDependency.getExclusions().size() );
+ new ArrayList<>(nodeDependency.getExclusions().size());
- for ( Exclusion aetherExclusion : nodeDependency.getExclusions() )
- {
+ for (Exclusion aetherExclusion : nodeDependency.getExclusions()) {
org.apache.maven.model.Exclusion mavenExclusion = new org.apache.maven.model.Exclusion();
- mavenExclusion.setGroupId( aetherExclusion.getGroupId() );
- mavenExclusion.setArtifactId( aetherExclusion.getArtifactId() );
+ mavenExclusion.setGroupId(aetherExclusion.getGroupId());
+ mavenExclusion.setArtifactId(aetherExclusion.getArtifactId());
// that's all folks, although Aether has more metadata
- mavenExclusions.add( mavenExclusion );
+ mavenExclusions.add(mavenExclusion);
}
- mavenDependency.setExclusions( mavenExclusions );
+ mavenDependency.setExclusions(mavenExclusions);
}
return mavenDependency;
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java
index f7e5299..53da5e4 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,8 +24,6 @@ import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.junit.Test;
@@ -35,428 +32,370 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public abstract class AbstractPatternArtifactFilterTest
-{
+public abstract class AbstractPatternArtifactFilterTest {
- protected abstract ArtifactFilter createFilter( List<String> patterns );
+ protected abstract ArtifactFilter createFilter(List<String> patterns);
- protected abstract ArtifactFilter createFilter( List<String> patterns, boolean actTransitively );
+ protected abstract ArtifactFilter createFilter(List<String> patterns, boolean actTransitively);
protected abstract boolean isInclusionNotExpected();
@Test
- public void testShouldTriggerBothPatternsWithWildcards()
- {
+ public void testShouldTriggerBothPatternsWithWildcards() {
final String groupId1 = "group";
final String artifactId1 = "artifact";
final String groupId2 = "group2";
final String artifactId2 = "artifact2";
- Artifact artifact1 = mock( Artifact.class );
- when( artifact1.getGroupId() ).thenReturn( groupId1 );
- when( artifact1.getArtifactId() ).thenReturn( artifactId1 );
- when( artifact1.getType() ).thenReturn( "jar" );
- when( artifact1.getBaseVersion() ).thenReturn( "version" );
-
- Artifact artifact2 = mock( Artifact.class );
- when( artifact2.getGroupId() ).thenReturn( groupId2 );
- when( artifact2.getArtifactId() ).thenReturn( artifactId2 );
- when( artifact2.getType() ).thenReturn( "jar" );
- when( artifact2.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact1 = mock(Artifact.class);
+ when(artifact1.getGroupId()).thenReturn(groupId1);
+ when(artifact1.getArtifactId()).thenReturn(artifactId1);
+ when(artifact1.getType()).thenReturn("jar");
+ when(artifact1.getBaseVersion()).thenReturn("version");
+
+ Artifact artifact2 = mock(Artifact.class);
+ when(artifact2.getGroupId()).thenReturn(groupId2);
+ when(artifact2.getArtifactId()).thenReturn(artifactId2);
+ when(artifact2.getType()).thenReturn("jar");
+ when(artifact2.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( groupId1 + ":" + artifactId1 + ":*" );
- patterns.add( groupId2 + ":" + artifactId2 + ":*" );
+ patterns.add(groupId1 + ":" + artifactId1 + ":*");
+ patterns.add(groupId2 + ":" + artifactId2 + ":*");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact1 ) );
- assertFalse( filter.include( artifact2 ) );
- }
- else
- {
- assertTrue( filter.include( artifact1 ) );
- assertTrue( filter.include( artifact2 ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact1));
+ assertFalse(filter.include(artifact2));
+ } else {
+ assertTrue(filter.include(artifact1));
+ assertTrue(filter.include(artifact2));
}
}
@Test
- public void testShouldTriggerBothPatternsWithNonColonWildcards()
- {
+ public void testShouldTriggerBothPatternsWithNonColonWildcards() {
final String groupId1 = "group";
final String artifactId1 = "artifact";
final String groupId2 = "group2";
final String artifactId2 = "artifact2";
- Artifact artifact1 = mock( Artifact.class );
- when( artifact1.getGroupId() ).thenReturn( groupId1 );
- when( artifact1.getArtifactId() ).thenReturn( artifactId1 );
- when( artifact1.getType() ).thenReturn( "jar" );
- when( artifact1.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact1 = mock(Artifact.class);
+ when(artifact1.getGroupId()).thenReturn(groupId1);
+ when(artifact1.getArtifactId()).thenReturn(artifactId1);
+ when(artifact1.getType()).thenReturn("jar");
+ when(artifact1.getBaseVersion()).thenReturn("version");
- Artifact artifact2 = mock( Artifact.class );
- when( artifact2.getGroupId() ).thenReturn( groupId2 );
- when( artifact2.getArtifactId() ).thenReturn( artifactId2 );
- when( artifact2.getType() ).thenReturn( "jar" );
- when( artifact2.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact2 = mock(Artifact.class);
+ when(artifact2.getGroupId()).thenReturn(groupId2);
+ when(artifact2.getArtifactId()).thenReturn(artifactId2);
+ when(artifact2.getType()).thenReturn("jar");
+ when(artifact2.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( groupId1 + "*" );
- patterns.add( groupId2 + "*" );
+ patterns.add(groupId1 + "*");
+ patterns.add(groupId2 + "*");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact1 ) );
- assertFalse( filter.include( artifact2 ) );
- }
- else
- {
- assertTrue( filter.include( artifact1 ) );
- assertTrue( filter.include( artifact2 ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact1));
+ assertFalse(filter.include(artifact2));
+ } else {
+ assertTrue(filter.include(artifact1));
+ assertTrue(filter.include(artifact2));
}
}
@Test
- public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId()
- {
+ public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
- final ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId ) );
+ final ArtifactFilter filter = createFilter(Collections.singletonList(groupId + ":" + artifactId));
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId()
- {
+ public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
- final ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId + ":jar" ) );
+ final ArtifactFilter filter = createFilter(Collections.singletonList(groupId + ":" + artifactId + ":jar"));
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testShouldNotIncludeWhenGroupIdDiffers()
- {
+ public void testShouldNotIncludeWhenGroupIdDiffers() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "otherGroup:" + artifactId + ":jar" );
- patterns.add( "otherGroup:" + artifactId );
+ patterns.add("otherGroup:" + artifactId + ":jar");
+ patterns.add("otherGroup:" + artifactId);
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertTrue( filter.include( artifact ) );
- }
- else
- {
- assertFalse( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertTrue(filter.include(artifact));
+ } else {
+ assertFalse(filter.include(artifact));
}
}
@Test
- public void testShouldNotIncludeWhenArtifactIdDiffers()
- {
+ public void testShouldNotIncludeWhenArtifactIdDiffers() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( groupId + "otherArtifact:jar" );
- patterns.add( groupId + "otherArtifact" );
+ patterns.add(groupId + "otherArtifact:jar");
+ patterns.add(groupId + "otherArtifact");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertTrue( filter.include( artifact ) );
- }
- else
- {
- assertFalse( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertTrue(filter.include(artifact));
+ } else {
+ assertFalse(filter.include(artifact));
}
}
@Test
- public void testShouldNotIncludeWhenBothIdElementsDiffer()
- {
+ public void testShouldNotIncludeWhenBothIdElementsDiffer() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "otherGroup:otherArtifact:jar" );
- patterns.add( "otherGroup:otherArtifact" );
+ patterns.add("otherGroup:otherArtifact:jar");
+ patterns.add("otherGroup:otherArtifact");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertTrue( filter.include( artifact ) );
- }
- else
- {
- assertFalse( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertTrue(filter.include(artifact));
+ } else {
+ assertFalse(filter.include(artifact));
}
}
@Test
- public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled()
- {
+ public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled() {
final String groupId = "group";
final String artifactId = "artifact";
final String rootDepTrailItem = "current:project:jar:1.0";
final String depTrailItem = "otherGroup:otherArtifact";
- final List<String> depTrail = Arrays.asList( rootDepTrailItem, depTrailItem + ":jar:1.0" );
- final List<String> patterns = Collections.singletonList( depTrailItem );
+ final List<String> depTrail = Arrays.asList(rootDepTrailItem, depTrailItem + ":jar:1.0");
+ final List<String> patterns = Collections.singletonList(depTrailItem);
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
- when( artifact.getDependencyTrail() ).thenReturn( depTrail );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
+ when(artifact.getDependencyTrail()).thenReturn(depTrail);
- final ArtifactFilter filter = createFilter( patterns, true );
+ final ArtifactFilter filter = createFilter(patterns, true);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard()
- {
+ public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard() {
final String groupId = "group";
final String artifactId = "artifact";
final String rootDepTrailItem = "current:project:jar:1.0";
final String depTrailItem = "otherGroup:otherArtifact";
- final List<String> depTrail = Arrays.asList( rootDepTrailItem, depTrailItem + ":jar:1.0" );
- final List<String> patterns = Collections.singletonList( "otherGroup*" );
+ final List<String> depTrail = Arrays.asList(rootDepTrailItem, depTrailItem + ":jar:1.0");
+ final List<String> patterns = Collections.singletonList("otherGroup*");
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
- when( artifact.getDependencyTrail() ).thenReturn( depTrail );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
+ when(artifact.getDependencyTrail()).thenReturn(depTrail);
- final ArtifactFilter filter = createFilter( patterns, true );
+ final ArtifactFilter filter = createFilter(patterns, true);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testShouldNotIncludeWhenNegativeMatch()
- {
+ public void testShouldNotIncludeWhenNegativeMatch() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "!group:artifact:jar" );
+ patterns.add("!group:artifact:jar");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertTrue( filter.include( artifact ) );
- }
- else
- {
- assertFalse( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertTrue(filter.include(artifact));
+ } else {
+ assertFalse(filter.include(artifact));
}
}
@Test
- public void testShouldIncludeWhenWildcardMatchesInsideSequence()
- {
+ public void testShouldIncludeWhenWildcardMatchesInsideSequence() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "group:*:jar" );
+ patterns.add("group:*:jar");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testShouldIncludeWhenWildcardMatchesOutsideSequence()
- {
+ public void testShouldIncludeWhenWildcardMatchesOutsideSequence() {
final String groupId = "group";
final String artifactId = "artifact";
- Artifact artifact = mock( Artifact.class );
+ Artifact artifact = mock(Artifact.class);
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "*:artifact:*" );
+ patterns.add("*:artifact:*");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId()
- {
+ public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId() {
final String groupId = "group";
final String artifactId = "some-artifact-id";
- Artifact artifact = mock( Artifact.class );
+ Artifact artifact = mock(Artifact.class);
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "group:some-*-id" );
+ patterns.add("group:some-*-id");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse()
- {
+ public void testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse() {
final String groupId = "some.group.id";
final String artifactId = "some-artifact-id";
- Artifact artifact = mock( Artifact.class );
+ Artifact artifact = mock(Artifact.class);
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "some.group*" );
+ patterns.add("some.group*");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent()
- {
+ public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent() {
final String groupId = "group";
final String artifactId = "artifact";
@@ -464,143 +403,123 @@ public abstract class AbstractPatternArtifactFilterTest
final String otherArtifact = "otherArtifact";
final String otherType = "ejb";
- final List<String> patterns = Collections.singletonList( "*:jar:*" );
+ final List<String> patterns = Collections.singletonList("*:jar:*");
- Artifact artifact1 = mock( Artifact.class );
- when( artifact1.getGroupId() ).thenReturn( groupId );
- when( artifact1.getArtifactId() ).thenReturn( artifactId );
- when( artifact1.getType() ).thenReturn( "jar" );
- when( artifact1.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact1 = mock(Artifact.class);
+ when(artifact1.getGroupId()).thenReturn(groupId);
+ when(artifact1.getArtifactId()).thenReturn(artifactId);
+ when(artifact1.getType()).thenReturn("jar");
+ when(artifact1.getBaseVersion()).thenReturn("version");
- Artifact artifact2 = mock( Artifact.class );
- when( artifact2.getGroupId() ).thenReturn( otherGroup );
- when( artifact2.getArtifactId() ).thenReturn( otherArtifact );
- when( artifact2.getType() ).thenReturn( otherType );
- when( artifact2.getBaseVersion() ).thenReturn( "version" );
- when( artifact2.getDependencyTrail() ).thenReturn( Collections.emptyList() );
+ Artifact artifact2 = mock(Artifact.class);
+ when(artifact2.getGroupId()).thenReturn(otherGroup);
+ when(artifact2.getArtifactId()).thenReturn(otherArtifact);
+ when(artifact2.getType()).thenReturn(otherType);
+ when(artifact2.getBaseVersion()).thenReturn("version");
+ when(artifact2.getDependencyTrail()).thenReturn(Collections.emptyList());
- final ArtifactFilter filter = createFilter( patterns, true );
+ final ArtifactFilter filter = createFilter(patterns, true);
- if ( isInclusionNotExpected() )
- {
- assertTrue( filter.include( artifact2 ) );
- assertFalse( filter.include( artifact1 ) );
- }
- else
- {
- assertFalse( filter.include( artifact2 ) );
- assertTrue( filter.include( artifact1 ) );
+ if (isInclusionNotExpected()) {
+ assertTrue(filter.include(artifact2));
+ assertFalse(filter.include(artifact1));
+ } else {
+ assertFalse(filter.include(artifact2));
+ assertTrue(filter.include(artifact1));
}
}
-
+
@Test
- public void testShouldIncludeJarsWithAndWithoutClassifier()
- {
+ public void testShouldIncludeJarsWithAndWithoutClassifier() {
final String groupId = "com.mycompany.myproject";
final String artifactId = "some-artifact-id";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "version" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("version");
final List<String> patterns = new ArrayList<>();
- patterns.add( "com.mycompany.*:*:jar:*:*" );
+ patterns.add("com.mycompany.*:*:jar:*:*");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testWithVersionRange()
- {
+ public void testWithVersionRange() {
final String groupId = "com.mycompany.myproject";
final String artifactId = "some-artifact-id";
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( groupId );
- when( artifact.getArtifactId() ).thenReturn( artifactId );
- when( artifact.getType() ).thenReturn( "jar" );
- when( artifact.getBaseVersion() ).thenReturn( "1.1" );
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn(groupId);
+ when(artifact.getArtifactId()).thenReturn(artifactId);
+ when(artifact.getType()).thenReturn("jar");
+ when(artifact.getBaseVersion()).thenReturn("1.1");
final List<String> patterns = new ArrayList<>();
- patterns.add( "com.mycompany.myproject:some-artifact-id:jar:*:[1.0,2.0)" );
+ patterns.add("com.mycompany.myproject:some-artifact-id:jar:*:[1.0,2.0)");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact ) );
- }
- else
- {
- assertTrue( filter.include( artifact ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact));
+ } else {
+ assertTrue(filter.include(artifact));
}
}
@Test
- public void testmassembly955()
- {
- Artifact artifact1 = mock( Artifact.class );
- when( artifact1.getGroupId() ).thenReturn( "org.python" );
- when( artifact1.getArtifactId() ).thenReturn( "jython-standalone" );
- when( artifact1.getType() ).thenReturn( "jar" );
- when( artifact1.getBaseVersion() ).thenReturn( "1.0" );
-
- Artifact artifact2 = mock( Artifact.class );
- when( artifact2.getGroupId() ).thenReturn( "org.teiid" );
- when( artifact2.getArtifactId() ).thenReturn( "teiid" );
- when( artifact2.getType() ).thenReturn( "jar" );
- when( artifact2.hasClassifier() ).thenReturn( true );
- when( artifact2.getClassifier() ).thenReturn( "jdbc" );
- when( artifact2.getBaseVersion() ).thenReturn( "1.0" );
+ public void testmassembly955() {
+ Artifact artifact1 = mock(Artifact.class);
+ when(artifact1.getGroupId()).thenReturn("org.python");
+ when(artifact1.getArtifactId()).thenReturn("jython-standalone");
+ when(artifact1.getType()).thenReturn("jar");
+ when(artifact1.getBaseVersion()).thenReturn("1.0");
+
+ Artifact artifact2 = mock(Artifact.class);
+ when(artifact2.getGroupId()).thenReturn("org.teiid");
+ when(artifact2.getArtifactId()).thenReturn("teiid");
+ when(artifact2.getType()).thenReturn("jar");
+ when(artifact2.hasClassifier()).thenReturn(true);
+ when(artifact2.getClassifier()).thenReturn("jdbc");
+ when(artifact2.getBaseVersion()).thenReturn("1.0");
final List<String> patterns = new ArrayList<>();
- patterns.add( "org.teiid:teiid:*:jdbc:*" );
- patterns.add( "org.python:jython-standalone" );
+ patterns.add("org.teiid:teiid:*:jdbc:*");
+ patterns.add("org.python:jython-standalone");
- final ArtifactFilter filter = createFilter( patterns );
+ final ArtifactFilter filter = createFilter(patterns);
- if ( isInclusionNotExpected() )
- {
- assertFalse( filter.include( artifact1 ) );
- assertFalse( filter.include( artifact2 ) );
- }
- else
- {
- assertTrue( filter.include( artifact1 ) );
- assertTrue( filter.include( artifact2 ) );
+ if (isInclusionNotExpected()) {
+ assertFalse(filter.include(artifact1));
+ assertFalse(filter.include(artifact2));
+ } else {
+ assertTrue(filter.include(artifact1));
+ assertTrue(filter.include(artifact2));
}
}
@Test
- public void testPartialWildcardShouldNotMatchEmptyComponent()
- {
- Artifact artifact = mock( Artifact.class );
- when( artifact.getGroupId() ).thenReturn( "test-group" );
- when( artifact.getArtifactId() ).thenReturn( "test-artifact" );
- when( artifact.getVersion() ).thenReturn( "test-version" );
- when( artifact.hasClassifier() ).thenReturn( false );
-
- ArtifactFilter filter = createFilter(
- Collections.singletonList( "test-group:test-artifact:*:ERROR*" ) );
-
- if ( isInclusionNotExpected() )
- {
- assertTrue( filter.include( artifact ) );
- }
- else
- {
- assertFalse( filter.include( artifact ) );
+ public void testPartialWildcardShouldNotMatchEmptyComponent() {
+ Artifact artifact = mock(Artifact.class);
+ when(artifact.getGroupId()).thenReturn("test-group");
+ when(artifact.getArtifactId()).thenReturn("test-artifact");
+ when(artifact.getVersion()).thenReturn("test-version");
+ when(artifact.hasClassifier()).thenReturn(false);
+
+ ArtifactFilter filter = createFilter(Collections.singletonList("test-group:test-artifact:*:ERROR*"));
+
+ if (isInclusionNotExpected()) {
+ assertTrue(filter.include(artifact));
+ } else {
+ assertFalse(filter.include(artifact));
}
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
index 77bf57e..baca82f 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter;
* "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
+ * 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
@@ -18,17 +16,17 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.Collections;
import java.util.List;
+import junit.framework.AssertionFailedError;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;
-
-import junit.framework.AssertionFailedError;
import org.junit.Before;
import org.junit.Test;
@@ -36,365 +34,308 @@ import static org.junit.Assert.assertEquals;
/**
* Tests subclasses of <code>AbstractStrictPatternArtifactFilter</code>.
- *
+ *
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @see AbstractStrictPatternArtifactFilter
*/
-public abstract class AbstractStrictPatternArtifactFilterTest
-{
+public abstract class AbstractStrictPatternArtifactFilterTest {
protected Artifact artifact;
@Before
- public void setUp()
- {
- artifact = createArtifact( "groupId", "artifactId", "type", "version" );
+ public void setUp() {
+ artifact = createArtifact("groupId", "artifactId", "type", "version");
}
@Test
- public void testExactIncluded()
- {
- assertIncluded( "groupId:artifactId" );
+ public void testExactIncluded() {
+ assertIncluded("groupId:artifactId");
}
@Test
- public void testExactExcluded()
- {
- assertExcluded( "differentGroupId:differentArtifactId" );
+ public void testExactExcluded() {
+ assertExcluded("differentGroupId:differentArtifactId");
}
@Test
- public void testGroupIdIncluded()
- {
- assertIncluded( "groupId" );
+ public void testGroupIdIncluded() {
+ assertIncluded("groupId");
}
@Test
- public void testGroupIdExcluded()
- {
- assertExcluded( "differentGroupId" );
+ public void testGroupIdExcluded() {
+ assertExcluded("differentGroupId");
}
@Test
- public void testGroupIdWildcardIncluded()
- {
- assertIncluded( "*" );
+ public void testGroupIdWildcardIncluded() {
+ assertIncluded("*");
}
@Test
- public void testGroupIdImplicitWildcardIncluded()
- {
- assertIncluded( "" );
+ public void testGroupIdImplicitWildcardIncluded() {
+ assertIncluded("");
}
@Test
- public void testGroupIdStartsWithWildcardIncluded()
- {
- assertIncluded( "groupId*" );
+ public void testGroupIdStartsWithWildcardIncluded() {
+ assertIncluded("groupId*");
}
@Test
- public void testGroupIdStartsWithPartialWildcardIncluded()
- {
- assertIncluded( "group*" );
+ public void testGroupIdStartsWithPartialWildcardIncluded() {
+ assertIncluded("group*");
}
@Test
- public void testGroupIdStartsWithWildcardExcluded()
- {
- assertExcluded( "different*" );
+ public void testGroupIdStartsWithWildcardExcluded() {
+ assertExcluded("different*");
}
@Test
- public void testGroupIdEndsWithWildcardIncluded()
- {
- assertIncluded( "*groupId" );
+ public void testGroupIdEndsWithWildcardIncluded() {
+ assertIncluded("*groupId");
}
@Test
- public void testGroupIdEndsWithPartialWildcardIncluded()
- {
- assertIncluded( "*Id" );
+ public void testGroupIdEndsWithPartialWildcardIncluded() {
+ assertIncluded("*Id");
}
@Test
- public void testGroupIdEndsWithWildcardExcluded()
- {
- assertExcluded( "*different" );
+ public void testGroupIdEndsWithWildcardExcluded() {
+ assertExcluded("*different");
}
@Test
- public void testGroupIdContainsWildcardIncluded()
- {
- assertIncluded( "*oup*" );
+ public void testGroupIdContainsWildcardIncluded() {
+ assertIncluded("*oup*");
}
@Test
- public void testGroupIdContainsWildcardExcluded()
- {
- assertExcluded( "*different*" );
+ public void testGroupIdContainsWildcardExcluded() {
+ assertExcluded("*different*");
}
@Test
- public void testArtifactIdIncluded()
- {
- assertIncluded( ":artifactId" );
+ public void testArtifactIdIncluded() {
+ assertIncluded(":artifactId");
}
@Test
- public void testArtifactIdExcluded()
- {
- assertExcluded( ":differentArtifactId" );
+ public void testArtifactIdExcluded() {
+ assertExcluded(":differentArtifactId");
}
@Test
- public void testArtifactIdWildcardIncluded()
- {
- assertIncluded( ":*" );
+ public void testArtifactIdWildcardIncluded() {
+ assertIncluded(":*");
}
@Test
- public void testArtifactIdImplicitWildcardIncluded()
- {
- assertIncluded( ":" );
+ public void testArtifactIdImplicitWildcardIncluded() {
+ assertIncluded(":");
}
@Test
- public void testArtifactIdStartsWithWildcardIncluded()
- {
- assertIncluded( ":artifactId*" );
+ public void testArtifactIdStartsWithWildcardIncluded() {
+ assertIncluded(":artifactId*");
}
@Test
- public void testArtifactIdStartsWithPartialWildcardIncluded()
- {
- assertIncluded( ":artifact*" );
+ public void testArtifactIdStartsWithPartialWildcardIncluded() {
+ assertIncluded(":artifact*");
}
@Test
- public void testArtifactIdStartsWithWildcardExcluded()
- {
- assertExcluded( ":different*" );
+ public void testArtifactIdStartsWithWildcardExcluded() {
+ assertExcluded(":different*");
}
@Test
- public void testArtifactIdEndsWithWildcardIncluded()
- {
- assertIncluded( ":*artifactId" );
+ public void testArtifactIdEndsWithWildcardIncluded() {
+ assertIncluded(":*artifactId");
}
@Test
- public void testArtifactIdEndsWithPartialWildcardIncluded()
- {
- assertIncluded( ":*Id" );
+ public void testArtifactIdEndsWithPartialWildcardIncluded() {
+ assertIncluded(":*Id");
}
@Test
- public void testArtifactIdEndsWithWildcardExcluded()
- {
- assertExcluded( ":*different" );
+ public void testArtifactIdEndsWithWildcardExcluded() {
+ assertExcluded(":*different");
}
@Test
- public void testArtifactIdContainsWildcardIncluded()
- {
- assertIncluded( ":*fact*" );
+ public void testArtifactIdContainsWildcardIncluded() {
+ assertIncluded(":*fact*");
}
@Test
- public void testArtifactIdContainsWildcardExcluded()
- {
- assertExcluded( ":*different*" );
+ public void testArtifactIdContainsWildcardExcluded() {
+ assertExcluded(":*different*");
}
@Test
- public void testTypeIncluded()
- {
- assertIncluded( "::type" );
+ public void testTypeIncluded() {
+ assertIncluded("::type");
}
@Test
- public void testTypeExcluded()
- {
- assertExcluded( "::differentType" );
+ public void testTypeExcluded() {
+ assertExcluded("::differentType");
}
@Test
- public void testTypeWildcardIncluded()
- {
- assertIncluded( "::*" );
+ public void testTypeWildcardIncluded() {
+ assertIncluded("::*");
}
@Test
- public void testTypeImplicitWildcardIncluded()
- {
- assertIncluded( "::" );
+ public void testTypeImplicitWildcardIncluded() {
+ assertIncluded("::");
}
@Test
- public void testTypeStartsWithWildcardIncluded()
- {
- assertIncluded( "::type*" );
+ public void testTypeStartsWithWildcardIncluded() {
+ assertIncluded("::type*");
}
@Test
- public void testTypeStartsWithPartialWildcardIncluded()
- {
- assertIncluded( "::t*" );
+ public void testTypeStartsWithPartialWildcardIncluded() {
+ assertIncluded("::t*");
}
@Test
- public void testTypeStartsWithWildcardExcluded()
- {
- assertExcluded( "::different*" );
+ public void testTypeStartsWithWildcardExcluded() {
+ assertExcluded("::different*");
}
@Test
- public void testTypeEndsWithWildcardIncluded()
- {
- assertIncluded( "::*type" );
+ public void testTypeEndsWithWildcardIncluded() {
+ assertIncluded("::*type");
}
@Test
- public void testTypeEndsWithPartialWildcardIncluded()
- {
- assertIncluded( "::*e" );
+ public void testTypeEndsWithPartialWildcardIncluded() {
+ assertIncluded("::*e");
}
@Test
- public void testTypeEndsWithWildcardExcluded()
- {
- assertExcluded( "::*different" );
+ public void testTypeEndsWithWildcardExcluded() {
+ assertExcluded("::*different");
}
@Test
- public void testTypeContainsWildcardIncluded()
- {
- assertIncluded( "::*yp*" );
+ public void testTypeContainsWildcardIncluded() {
+ assertIncluded("::*yp*");
}
@Test
- public void testTypeContainsWildcardExcluded()
- {
- assertExcluded( "::*different*" );
+ public void testTypeContainsWildcardExcluded() {
+ assertExcluded("::*different*");
}
@Test
- public void testVersionIncluded()
- {
- assertIncluded( ":::version" );
+ public void testVersionIncluded() {
+ assertIncluded(":::version");
}
@Test
- public void testVersionExcluded()
- {
- assertExcluded( ":::differentVersion" );
+ public void testVersionExcluded() {
+ assertExcluded(":::differentVersion");
}
@Test
- public void testVersionWildcardIncluded()
- {
- assertIncluded( ":::*" );
+ public void testVersionWildcardIncluded() {
+ assertIncluded(":::*");
}
@Test
- public void testVersionImplicitWildcardIncluded()
- {
- assertIncluded( ":::" );
+ public void testVersionImplicitWildcardIncluded() {
+ assertIncluded(":::");
}
@Test
- public void testVersionStartsWithWildcardIncluded()
- {
- assertIncluded( ":::version*" );
+ public void testVersionStartsWithWildcardIncluded() {
+ assertIncluded(":::version*");
}
@Test
- public void testVersionStartsWithPartialWildcardIncluded()
- {
- assertIncluded( ":::ver*" );
+ public void testVersionStartsWithPartialWildcardIncluded() {
+ assertIncluded(":::ver*");
}
@Test
- public void testVersionStartsWithWildcardExcluded()
- {
- assertExcluded( ":::different*" );
+ public void testVersionStartsWithWildcardExcluded() {
+ assertExcluded(":::different*");
}
@Test
- public void testVersionEndsWithWildcardIncluded()
- {
- assertIncluded( ":::*version" );
+ public void testVersionEndsWithWildcardIncluded() {
+ assertIncluded(":::*version");
}
@Test
- public void testVersionEndsWithPartialWildcardIncluded()
- {
- assertIncluded( ":::*ion" );
+ public void testVersionEndsWithPartialWildcardIncluded() {
+ assertIncluded(":::*ion");
}
@Test
- public void testVersionEndsWithWildcardExcluded()
- {
- assertExcluded( ":::*different" );
+ public void testVersionEndsWithWildcardExcluded() {
+ assertExcluded(":::*different");
}
@Test
- public void testVersionContainsWildcardIncluded()
- {
- assertIncluded( ":::*si*" );
+ public void testVersionContainsWildcardIncluded() {
+ assertIncluded(":::*si*");
}
@Test
- public void testVersionContainsWildcardExcluded()
- {
- assertExcluded( ":::*different*" );
+ public void testVersionContainsWildcardExcluded() {
+ assertExcluded(":::*different*");
}
@Test
- public void testComplex()
- {
- assertIncluded( "group*:*Id:*:version" );
+ public void testComplex() {
+ assertIncluded("group*:*Id:*:version");
}
@Test
- public void testSnapshotVersion()
- {
- artifact = createArtifact( "groupId", "artifactId", "type", "version-12345678.123456-1" );
+ public void testSnapshotVersion() {
+ artifact = createArtifact("groupId", "artifactId", "type", "version-12345678.123456-1");
- assertIncluded( ":::*-SNAPSHOT" );
+ assertIncluded(":::*-SNAPSHOT");
}
-
+
@Test
- public void testRangeVersion()
- {
- artifact = createArtifact( "groupId", "artifactId", "type", "1.0.1" );
- assertIncluded( "groupId:artifactId:type:[1.0.1]");
- assertIncluded( "groupId:artifactId:type:[1.0,1.1)");
-
- assertExcluded( "groupId:artifactId:type:[1.5,)");
- assertExcluded( "groupId:artifactId:type:(,1.0],[1.2,)");
- assertExcluded( "groupId:artifactId:type:(,1.0],[1.2,)");
+ public void testRangeVersion() {
+ artifact = createArtifact("groupId", "artifactId", "type", "1.0.1");
+ assertIncluded("groupId:artifactId:type:[1.0.1]");
+ assertIncluded("groupId:artifactId:type:[1.0,1.1)");
+
+ assertExcluded("groupId:artifactId:type:[1.5,)");
+ assertExcluded("groupId:artifactId:type:(,1.0],[1.2,)");
+ assertExcluded("groupId:artifactId:type:(,1.0],[1.2,)");
}
@Test
- public void testWildcardsWithRangeVersion()
- {
- artifact = createArtifact( "groupId", "artifactId", "type", "1.0.1" );
- assertIncluded( ":::[1.0.1]");
- assertIncluded( ":artifact*:*:[1.0,1.1)");
-
- assertExcluded( "*group*:*:t*e:[1.5,)");
+ public void testWildcardsWithRangeVersion() {
+ artifact = createArtifact("groupId", "artifactId", "type", "1.0.1");
+ assertIncluded(":::[1.0.1]");
+ assertIncluded(":artifact*:*:[1.0,1.1)");
- artifact = createArtifact( "test", "uf", "jar", "0.2.0" );
- assertIncluded( "test:*:*:[0.0.2,)" );
-
+ assertExcluded("*group*:*:t*e:[1.5,)");
+
+ artifact = createArtifact("test", "uf", "jar", "0.2.0");
+ assertIncluded("test:*:*:[0.0.2,)");
}
-
+
// protected methods ------------------------------------------------------
/**
* Creates an artifact with the specified attributes.
- *
+ *
* @param groupId
* the group id for the new artifact
* @param artifactId
@@ -405,43 +346,40 @@ public abstract class AbstractStrictPatternArtifactFilterTest
* the version for the new artifact
* @return the artifact
*/
- protected Artifact createArtifact( String groupId, String artifactId, String type, String version )
- {
- VersionRange versionRange = VersionRange.createFromVersion( version );
+ protected Artifact createArtifact(String groupId, String artifactId, String type, String version) {
+ VersionRange versionRange = VersionRange.createFromVersion(version);
ArtifactHandler handler = new DefaultArtifactHandler();
- return new DefaultArtifact( groupId, artifactId, versionRange, null, type, null, handler );
+ return new DefaultArtifact(groupId, artifactId, versionRange, null, type, null, handler);
}
/**
* Asserts that the specified pattern is included by the filter being tested.
- *
+ *
* @param pattern
* the pattern to test for inclusion
* @throws AssertionFailedError
* if the assertion fails
*/
- protected void assertIncluded( String pattern )
- {
- assertFilter( true, pattern );
+ protected void assertIncluded(String pattern) {
+ assertFilter(true, pattern);
}
/**
* Asserts that the specified pattern is excluded by the filter being tested.
- *
+ *
* @param pattern
* the pattern to test for exclusion
* @throws AssertionFailedError
* if the assertion fails
*/
- protected void assertExcluded( String pattern )
- {
- assertFilter( false, pattern );
+ protected void assertExcluded(String pattern) {
+ assertFilter(false, pattern);
}
/**
* Asserts that the filter being tested returns the specified result for the specified pattern.
- *
+ *
* @param expected
* the result expected from the filter
* @param pattern
@@ -449,20 +387,19 @@ public abstract class AbstractStrictPatternArtifactFilterTest
* @throws AssertionFailedError
* if the assertion fails
*/
- protected void assertFilter( boolean expected, String pattern )
- {
- List<String> patterns = Collections.singletonList( pattern );
- AbstractStrictPatternArtifactFilter filter = createFilter( patterns );
+ protected void assertFilter(boolean expected, String pattern) {
+ List<String> patterns = Collections.singletonList(pattern);
+ AbstractStrictPatternArtifactFilter filter = createFilter(patterns);
- assertEquals( expected, filter.include( artifact ) );
+ assertEquals(expected, filter.include(artifact));
}
/**
* Creates the strict pattern artifact filter to test for the specified patterns.
- *
+ *
* @param patterns
* the list of artifact patterns that the filter should match
* @return the filter to test
*/
- protected abstract AbstractStrictPatternArtifactFilter createFilter( List<String> patterns );
+ protected abstract AbstractStrictPatternArtifactFilter createFilter(List<String> patterns);
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java
index 669a60a..dea56da 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -41,9 +40,7 @@ import org.slf4j.Logger;
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @see StrictPatternIncludesArtifactFilter
*/
-public class GNPatternIncludesArtifactFilter
- implements ArtifactFilter, StatisticsReportingArtifactFilter
-{
+public class GNPatternIncludesArtifactFilter implements ArtifactFilter, StatisticsReportingArtifactFilter {
/** Holds the set of compiled patterns */
private final Set<Pattern> patterns;
@@ -61,9 +58,8 @@ public class GNPatternIncludesArtifactFilter
*
* @param patterns The pattern to be used.
*/
- public GNPatternIncludesArtifactFilter( final Collection<String> patterns )
- {
- this( patterns, false );
+ public GNPatternIncludesArtifactFilter(final Collection<String> patterns) {
+ this(patterns, false);
}
/**
@@ -72,30 +68,25 @@ public class GNPatternIncludesArtifactFilter
* @param patterns The pattern to be used.
* @param actTransitively transitive yes/no.
*/
- public GNPatternIncludesArtifactFilter( final Collection<String> patterns, final boolean actTransitively )
- {
+ public GNPatternIncludesArtifactFilter(final Collection<String> patterns, final boolean actTransitively) {
this.actTransitively = actTransitively;
final Set<Pattern> pat = new LinkedHashSet<>();
- if ( patterns != null && !patterns.isEmpty() )
- {
- for ( String pattern : patterns )
- {
+ if (patterns != null && !patterns.isEmpty()) {
+ for (String pattern : patterns) {
- Pattern p = compile( pattern );
- pat.add( p );
+ Pattern p = compile(pattern);
+ pat.add(p);
}
}
this.patterns = pat;
}
/** {@inheritDoc} */
- public boolean include( final Artifact artifact )
- {
- final boolean shouldInclude = patternMatches( artifact );
+ public boolean include(final Artifact artifact) {
+ final boolean shouldInclude = patternMatches(artifact);
- if ( !shouldInclude )
- {
- addFilteredArtifact( artifact );
+ if (!shouldInclude) {
+ addFilteredArtifact(artifact);
}
return shouldInclude;
@@ -107,34 +98,28 @@ public class GNPatternIncludesArtifactFilter
* @param artifact to check for.
* @return true if the match is true false otherwise.
*/
- protected boolean patternMatches( final Artifact artifact )
- {
+ protected boolean patternMatches(final Artifact artifact) {
// Check if the main artifact matches
char[][] artifactGatvCharArray = new char[][] {
- emptyOrChars( artifact.getGroupId() ),
- emptyOrChars( artifact.getArtifactId() ),
- emptyOrChars( artifact.getType() ),
- emptyOrChars( artifact.getClassifier() ),
- emptyOrChars( artifact.getBaseVersion() )
- };
- Boolean match = match( artifactGatvCharArray );
- if ( match != null )
- {
+ emptyOrChars(artifact.getGroupId()),
+ emptyOrChars(artifact.getArtifactId()),
+ emptyOrChars(artifact.getType()),
+ emptyOrChars(artifact.getClassifier()),
+ emptyOrChars(artifact.getBaseVersion())
+ };
+ Boolean match = match(artifactGatvCharArray);
+ if (match != null) {
return match;
}
- if ( actTransitively )
- {
+ if (actTransitively) {
final List<String> depTrail = artifact.getDependencyTrail();
- if ( depTrail != null && depTrail.size() > 1 )
- {
- for ( String trailItem : depTrail )
- {
- char[][] depGatvCharArray = tokenizeAndSplit( trailItem );
- match = match( depGatvCharArray );
- if ( match != null )
- {
+ if (depTrail != null && depTrail.size() > 1) {
+ for (String trailItem : depTrail) {
+ char[][] depGatvCharArray = tokenizeAndSplit(trailItem);
+ match = match(depGatvCharArray);
+ if (match != null) {
return match;
}
}
@@ -144,14 +129,11 @@ public class GNPatternIncludesArtifactFilter
return false;
}
- private Boolean match( char[][] gatvCharArray )
- {
- for ( Pattern pattern : patterns )
- {
- if ( pattern.matches( gatvCharArray ) )
- {
- patternsTriggered.add( pattern );
- return !( pattern instanceof NegativePattern );
+ private Boolean match(char[][] gatvCharArray) {
+ for (Pattern pattern : patterns) {
+ if (pattern.matches(gatvCharArray)) {
+ patternsTriggered.add(pattern);
+ return !(pattern instanceof NegativePattern);
}
}
@@ -163,44 +145,38 @@ public class GNPatternIncludesArtifactFilter
*
* @param artifact add artifact to the filtered artifacts list.
*/
- protected void addFilteredArtifact( final Artifact artifact )
- {
- filteredArtifact.add( artifact );
+ protected void addFilteredArtifact(final Artifact artifact) {
+ filteredArtifact.add(artifact);
}
/** {@inheritDoc} */
- public void reportMissedCriteria( final Logger logger )
- {
+ public void reportMissedCriteria(final Logger logger) {
// if there are no patterns, there is nothing to report.
- if ( !patterns.isEmpty() )
- {
- final List<Pattern> missed = new ArrayList<>( patterns );
- missed.removeAll( patternsTriggered );
+ if (!patterns.isEmpty()) {
+ final List<Pattern> missed = new ArrayList<>(patterns);
+ missed.removeAll(patternsTriggered);
- if ( !missed.isEmpty() && logger.isWarnEnabled() )
- {
+ if (!missed.isEmpty() && logger.isWarnEnabled()) {
final StringBuilder buffer = new StringBuilder();
- buffer.append( "The following patterns were never triggered in this " );
- buffer.append( getFilterDescription() );
- buffer.append( ':' );
+ buffer.append("The following patterns were never triggered in this ");
+ buffer.append(getFilterDescription());
+ buffer.append(':');
- for ( Pattern pattern : missed )
- {
- buffer.append( "\no '" ).append( pattern ).append( "'" );
+ for (Pattern pattern : missed) {
+ buffer.append("\no '").append(pattern).append("'");
}
- buffer.append( "\n" );
+ buffer.append("\n");
- logger.warn( buffer.toString() );
+ logger.warn(buffer.toString());
}
}
}
/** {@inheritDoc} */
@Override
- public String toString()
- {
+ public String toString() {
return "Includes filter:" + getPatternsAsString();
}
@@ -209,12 +185,10 @@ public class GNPatternIncludesArtifactFilter
*
* @return pattern as a string.
*/
- protected String getPatternsAsString()
- {
+ protected String getPatternsAsString() {
final StringBuilder buffer = new StringBuilder();
- for ( Pattern pattern : patterns )
- {
- buffer.append( "\no '" ).append( pattern ).append( "'" );
+ for (Pattern pattern : patterns) {
+ buffer.append("\no '").append(pattern).append("'");
}
return buffer.toString();
@@ -225,25 +199,21 @@ public class GNPatternIncludesArtifactFilter
*
* @return description.
*/
- protected String getFilterDescription()
- {
+ protected String getFilterDescription() {
return "artifact inclusion filter";
}
/** {@inheritDoc} */
- public void reportFilteredArtifacts( final Logger logger )
- {
- if ( !filteredArtifact.isEmpty() && logger.isDebugEnabled() )
- {
+ public void reportFilteredArtifacts(final Logger logger) {
+ if (!filteredArtifact.isEmpty() && logger.isDebugEnabled()) {
final StringBuilder buffer =
- new StringBuilder( "The following artifacts were removed by this " + getFilterDescription() + ": " );
+ new StringBuilder("The following artifacts were removed by this " + getFilterDescription() + ": ");
- for ( Artifact artifactId : filteredArtifact )
- {
- buffer.append( '\n' ).append( artifactId.getId() );
+ for (Artifact artifactId : filteredArtifact) {
+ buffer.append('\n').append(artifactId.getId());
}
- logger.debug( buffer.toString() );
+ logger.debug(buffer.toString());
}
}
@@ -252,13 +222,11 @@ public class GNPatternIncludesArtifactFilter
*
* @return a boolean.
*/
- public boolean hasMissedCriteria()
- {
+ public boolean hasMissedCriteria() {
// if there are no patterns, there is nothing to report.
- if ( !patterns.isEmpty() )
- {
- final List<Pattern> missed = new ArrayList<>( patterns );
- missed.removeAll( patternsTriggered );
+ if (!patterns.isEmpty()) {
+ final List<Pattern> missed = new ArrayList<>(patterns);
+ missed.removeAll(patternsTriggered);
return !missed.isEmpty();
}
@@ -268,32 +236,27 @@ public class GNPatternIncludesArtifactFilter
private static final char[] EMPTY = new char[0];
- private static final char[] ANY = new char[] { '*' };
+ private static final char[] ANY = new char[] {'*'};
- static char[] emptyOrChars( String str )
- {
+ static char[] emptyOrChars(String str) {
return str != null && str.length() > 0 ? str.toCharArray() : EMPTY;
}
- static char[] anyOrChars( char[] str )
- {
- return str.length > 1 || ( str.length == 1 && str[0] != '*' ) ? str : ANY;
+ static char[] anyOrChars(char[] str) {
+ return str.length > 1 || (str.length == 1 && str[0] != '*') ? str : ANY;
}
- static char[][] tokenizeAndSplit( String pattern )
- {
- String[] stokens = pattern.split( ":" );
- char[][] tokens = new char[ stokens.length ][];
- for ( int i = 0; i < stokens.length; i++ )
- {
- tokens[i] = emptyOrChars( stokens[i] );
+ static char[][] tokenizeAndSplit(String pattern) {
+ String[] stokens = pattern.split(":");
+ char[][] tokens = new char[stokens.length][];
+ for (int i = 0; i < stokens.length; i++) {
+ tokens[i] = emptyOrChars(stokens[i]);
}
return tokens;
}
- @SuppressWarnings( "InnerAssignment" )
- static boolean match( char[] patArr, char[] strArr, boolean isVersion )
- {
+ @SuppressWarnings("InnerAssignment")
+ static boolean match(char[] patArr, char[] strArr, boolean isVersion) {
int patIdxStart = 0;
int patIdxEnd = patArr.length - 1;
int strIdxStart = 0;
@@ -301,60 +264,47 @@ public class GNPatternIncludesArtifactFilter
char ch;
boolean containsStar = false;
- for ( char aPatArr : patArr )
- {
- if ( aPatArr == '*' )
- {
+ for (char aPatArr : patArr) {
+ if (aPatArr == '*') {
containsStar = true;
break;
}
}
- if ( !containsStar )
- {
- if ( isVersion && ( patArr[0] == '[' || patArr[0] == '(' ) )
- {
- return isVersionIncludedInRange( String.valueOf( strArr ), String.valueOf( patArr ) );
+ if (!containsStar) {
+ if (isVersion && (patArr[0] == '[' || patArr[0] == '(')) {
+ return isVersionIncludedInRange(String.valueOf(strArr), String.valueOf(patArr));
}
// No '*'s, so we make a shortcut
- if ( patIdxEnd != strIdxEnd )
- {
+ if (patIdxEnd != strIdxEnd) {
return false; // Pattern and string do not have the same size
}
- for ( int i = 0; i <= patIdxEnd; i++ )
- {
+ for (int i = 0; i <= patIdxEnd; i++) {
ch = patArr[i];
- if ( ch != '?' && ch != strArr[i] )
- {
+ if (ch != '?' && ch != strArr[i]) {
return false; // Character mismatch
}
}
return true; // String matches against pattern
}
- if ( patIdxEnd == 0 )
- {
+ if (patIdxEnd == 0) {
return true; // Pattern contains only '*', which matches anything
}
// Process characters before first star
- while ( ( ch = patArr[patIdxStart] ) != '*' && strIdxStart <= strIdxEnd )
- {
- if ( ch != '?' && ch != strArr[strIdxStart] )
- {
+ while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) {
+ if (ch != '?' && ch != strArr[strIdxStart]) {
return false; // Character mismatch
}
patIdxStart++;
strIdxStart++;
}
- if ( strIdxStart > strIdxEnd )
- {
+ if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
- for ( int i = patIdxStart; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] != '*' )
- {
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {
+ if (patArr[i] != '*') {
return false;
}
}
@@ -362,23 +312,18 @@ public class GNPatternIncludesArtifactFilter
}
// Process characters after last star
- while ( ( ch = patArr[patIdxEnd] ) != '*' && strIdxStart <= strIdxEnd )
- {
- if ( ch != '?' && ch != strArr[strIdxEnd] )
- {
+ while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {
+ if (ch != '?' && ch != strArr[strIdxEnd]) {
return false; // Character mismatch
}
patIdxEnd--;
strIdxEnd--;
}
- if ( strIdxStart > strIdxEnd )
- {
+ if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
- for ( int i = patIdxStart; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] != '*' )
- {
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {
+ if (patArr[i] != '*') {
return false;
}
}
@@ -387,35 +332,29 @@ public class GNPatternIncludesArtifactFilter
// process pattern between stars. padIdxStart and patIdxEnd point
// always to a '*'.
- while ( patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd )
- {
+ while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
int patIdxTmp = -1;
- for ( int i = patIdxStart + 1; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] == '*' )
- {
+ for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
+ if (patArr[i] == '*') {
patIdxTmp = i;
break;
}
}
- if ( patIdxTmp == patIdxStart + 1 )
- {
+ if (patIdxTmp == patIdxStart + 1) {
// Two stars next to each other, skip the first one.
patIdxStart++;
continue;
}
// Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd
- int patLength = ( patIdxTmp - patIdxStart - 1 );
- int strLength = ( strIdxEnd - strIdxStart + 1 );
+ int patLength = (patIdxTmp - patIdxStart - 1);
+ int strLength = (strIdxEnd - strIdxStart + 1);
int foundIdx = -1;
- strLoop: for ( int i = 0; i <= strLength - patLength; i++ )
- {
- for ( int j = 0; j < patLength; j++ )
- {
+ strLoop:
+ for (int i = 0; i <= strLength - patLength; i++) {
+ for (int j = 0; j < patLength; j++) {
ch = patArr[patIdxStart + j + 1];
- if ( ch != '?' && ch != strArr[strIdxStart + i + j] )
- {
+ if (ch != '?' && ch != strArr[strIdxStart + i + j]) {
continue strLoop;
}
}
@@ -424,8 +363,7 @@ public class GNPatternIncludesArtifactFilter
break;
}
- if ( foundIdx == -1 )
- {
+ if (foundIdx == -1) {
return false;
}
@@ -435,287 +373,217 @@ public class GNPatternIncludesArtifactFilter
// All characters in the string are used. Check if only '*'s are left
// in the pattern. If so, we succeeded. Otherwise failure.
- for ( int i = patIdxStart; i <= patIdxEnd; i++ )
- {
- if ( patArr[i] != '*' )
- {
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {
+ if (patArr[i] != '*') {
return false;
}
}
return true;
}
- static boolean isVersionIncludedInRange( final String version, final String range )
- {
- try
- {
- return VersionRange.createFromVersionSpec( range ).containsVersion( new DefaultArtifactVersion( version ) );
- }
- catch ( final InvalidVersionSpecificationException e )
- {
+ static boolean isVersionIncludedInRange(final String version, final String range) {
+ try {
+ return VersionRange.createFromVersionSpec(range).containsVersion(new DefaultArtifactVersion(version));
+ } catch (final InvalidVersionSpecificationException e) {
return false;
}
}
- static Pattern compile( String pattern )
- {
- if ( pattern.startsWith( "!" ) )
- {
- return new NegativePattern( pattern, compile( pattern.substring( 1 ) ) );
- }
- else
- {
- char[][] stokens = tokenizeAndSplit( pattern );
- char[][] tokens = new char[ stokens.length ][];
- for ( int i = 0; i < stokens.length; i++ )
- {
- tokens[i] = anyOrChars( stokens[i] );
+ static Pattern compile(String pattern) {
+ if (pattern.startsWith("!")) {
+ return new NegativePattern(pattern, compile(pattern.substring(1)));
+ } else {
+ char[][] stokens = tokenizeAndSplit(pattern);
+ char[][] tokens = new char[stokens.length][];
+ for (int i = 0; i < stokens.length; i++) {
+ tokens[i] = anyOrChars(stokens[i]);
}
- if ( tokens.length > 5 )
- {
- throw new IllegalArgumentException( "Invalid pattern: " + pattern );
+ if (tokens.length > 5) {
+ throw new IllegalArgumentException("Invalid pattern: " + pattern);
}
//
// Check the tokens and build an appropriate Pattern
// Special care needs to be taken if the first or the last part is '*'
// because this allows the '*' to match multiple tokens
//
- if ( tokens.length == 1 )
- {
- if ( tokens[0] == ANY )
- {
+ if (tokens.length == 1) {
+ if (tokens[0] == ANY) {
// *
- return all( pattern );
- }
- else
- {
+ return all(pattern);
+ } else {
// [pat0]
- return match( pattern, tokens[0], 0 );
+ return match(pattern, tokens[0], 0);
}
}
- if ( tokens.length == 2 )
- {
- if ( tokens[0] == ANY )
- {
- if ( tokens[1] == ANY )
- {
+ if (tokens.length == 2) {
+ if (tokens[0] == ANY) {
+ if (tokens[1] == ANY) {
// *:*
- return all( pattern );
- }
- else
- {
+ return all(pattern);
+ } else {
// *:[pat1]
- return match( pattern, tokens[1], 0, 3 );
+ return match(pattern, tokens[1], 0, 3);
}
- }
- else
- {
- if ( tokens[1] == ANY )
- {
+ } else {
+ if (tokens[1] == ANY) {
// [pat0]:*
- return match( pattern, tokens[0], 0 );
- }
- else
- {
+ return match(pattern, tokens[0], 0);
+ } else {
// [pat0]:[pat1]
- Pattern m00 = match( tokens[0], 0 );
- Pattern m11 = match( tokens[1], 1 );
- return and( pattern, m00, m11 );
+ Pattern m00 = match(tokens[0], 0);
+ Pattern m11 = match(tokens[1], 1);
+ return and(pattern, m00, m11);
}
}
}
- if ( tokens.length == 3 )
- {
- if ( tokens[0] == ANY )
- {
- if ( tokens[1] == ANY )
- {
- if ( tokens[2] == ANY )
- {
+ if (tokens.length == 3) {
+ if (tokens[0] == ANY) {
+ if (tokens[1] == ANY) {
+ if (tokens[2] == ANY) {
// *:*:*
- return all( pattern );
- }
- else
- {
+ return all(pattern);
+ } else {
// *:*:[pat2]
- return match( pattern, tokens[2], 2, 3 );
+ return match(pattern, tokens[2], 2, 3);
}
- }
- else
- {
- if ( tokens[2] == ANY )
- {
+ } else {
+ if (tokens[2] == ANY) {
// *:[pat1]:*
- return match( pattern, tokens[1], 1, 2 );
- }
- else
- {
+ return match(pattern, tokens[1], 1, 2);
+ } else {
// *:[pat1]:[pat2]
- Pattern m11 = match( tokens[1], 1 );
- Pattern m12 = match( tokens[1], 2 );
- Pattern m22 = match( tokens[2], 2 );
- Pattern m23 = match( tokens[2], 3 );
- return or( pattern, and( m11, m22 ), and( m12, m23 ) );
+ Pattern m11 = match(tokens[1], 1);
+ Pattern m12 = match(tokens[1], 2);
+ Pattern m22 = match(tokens[2], 2);
+ Pattern m23 = match(tokens[2], 3);
+ return or(pattern, and(m11, m22), and(m12, m23));
}
}
- }
- else
- {
- if ( tokens[1] == ANY )
- {
- if ( tokens[2] == ANY )
- {
+ } else {
+ if (tokens[1] == ANY) {
+ if (tokens[2] == ANY) {
// [pat0]:*:*
- return match( pattern, tokens[0], 0, 1 );
- }
- else
- {
+ return match(pattern, tokens[0], 0, 1);
+ } else {
// [pat0]:*:[pat2]
- Pattern m00 = match( tokens[0], 0 );
- Pattern m223 = match( tokens[2], 2, 3 );
- return and( pattern, m00, m223 );
+ Pattern m00 = match(tokens[0], 0);
+ Pattern m223 = match(tokens[2], 2, 3);
+ return and(pattern, m00, m223);
}
- }
- else
- {
- if ( tokens[2] == ANY )
- {
+ } else {
+ if (tokens[2] == ANY) {
// [pat0]:[pat1]:*
- Pattern m00 = match( tokens[0], 0 );
- Pattern m11 = match( tokens[1], 1 );
- return and( pattern, m00, m11 );
- }
- else
- {
+ Pattern m00 = match(tokens[0], 0);
+ Pattern m11 = match(tokens[1], 1);
+ return and(pattern, m00, m11);
+ } else {
// [pat0]:[pat1]:[pat2]
- Pattern m00 = match( tokens[0], 0 );
- Pattern m11 = match( tokens[1], 1 );
- Pattern m22 = match( tokens[2], 2 );
- return and( pattern, m00, m11, m22 );
+ Pattern m00 = match(tokens[0], 0);
+ Pattern m11 = match(tokens[1], 1);
+ Pattern m22 = match(tokens[2], 2);
+ return and(pattern, m00, m11, m22);
}
}
}
}
- if ( tokens.length >= 4 )
- {
+ if (tokens.length >= 4) {
List<Pattern> patterns = new ArrayList<>();
- for ( int i = 0; i < tokens.length; i++ )
- {
- if ( tokens[i] != ANY )
- {
- patterns.add( match( tokens[i], i ) );
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i] != ANY) {
+ patterns.add(match(tokens[i], i));
}
}
- return and( pattern, patterns.toArray( new Pattern[0] ) );
+ return and(pattern, patterns.toArray(new Pattern[0]));
}
throw new IllegalStateException();
}
}
/** Creates a positional matching pattern */
- private static Pattern match( String pattern, char[] token, int posVal )
- {
- return match( pattern, token, posVal, posVal );
+ private static Pattern match(String pattern, char[] token, int posVal) {
+ return match(pattern, token, posVal, posVal);
}
/** Creates a positional matching pattern */
- private static Pattern match( char[] token, int posVal )
- {
- return match( "", token, posVal, posVal );
+ private static Pattern match(char[] token, int posVal) {
+ return match("", token, posVal, posVal);
}
/** Creates a positional matching pattern */
- private static Pattern match( String pattern, char[] token, int posMin, int posMax )
- {
+ private static Pattern match(String pattern, char[] token, int posMin, int posMax) {
boolean hasWildcard = false;
- for ( char ch : token )
- {
- if ( ch == '*' || ch == '?' )
- {
+ for (char ch : token) {
+ if (ch == '*' || ch == '?') {
hasWildcard = true;
break;
}
}
- if ( hasWildcard || posMax == 4 )
- {
- return new PosPattern( pattern, token, posMin, posMax );
- }
- else
- {
- return new EqPattern( pattern, token, posMin, posMax );
+ if (hasWildcard || posMax == 4) {
+ return new PosPattern(pattern, token, posMin, posMax);
+ } else {
+ return new EqPattern(pattern, token, posMin, posMax);
}
}
/** Creates a positional matching pattern */
- private static Pattern match( char[] token, int posMin, int posMax )
- {
- return new PosPattern( "", token, posMin, posMax );
+ private static Pattern match(char[] token, int posMin, int posMax) {
+ return new PosPattern("", token, posMin, posMax);
}
/** Creates an AND pattern */
- private static Pattern and( String pattern, Pattern... patterns )
- {
- return new AndPattern( pattern, patterns );
+ private static Pattern and(String pattern, Pattern... patterns) {
+ return new AndPattern(pattern, patterns);
}
/** Creates an AND pattern */
- private static Pattern and( Pattern... patterns )
- {
- return and( "", patterns );
+ private static Pattern and(Pattern... patterns) {
+ return and("", patterns);
}
/** Creates an OR pattern */
- private static Pattern or( String pattern, Pattern... patterns )
- {
- return new OrPattern( pattern, patterns );
+ private static Pattern or(String pattern, Pattern... patterns) {
+ return new OrPattern(pattern, patterns);
}
/** Creates an OR pattern */
- private static Pattern or( Pattern... patterns )
- {
- return or( "", patterns );
+ private static Pattern or(Pattern... patterns) {
+ return or("", patterns);
}
/** Creates a match-all pattern */
- private static Pattern all( String pattern )
- {
- return new MatchAllPattern( pattern );
+ private static Pattern all(String pattern) {
+ return new MatchAllPattern(pattern);
}
/**
* Abstract class for patterns
*/
- abstract static class Pattern
- {
+ abstract static class Pattern {
private final String pattern;
- Pattern( String pattern )
- {
- this.pattern = Objects.requireNonNull( pattern );
+ Pattern(String pattern) {
+ this.pattern = Objects.requireNonNull(pattern);
}
- public abstract boolean matches( char[][] parts );
+ public abstract boolean matches(char[][] parts);
/**
* Returns a string containing a fixed artifact gatv coordinates
* or null if the pattern can not be translated.
*/
- public String translateEquals()
- {
+ public String translateEquals() {
return null;
}
/**
* Check if the this pattern is a fixed pattern on the specified pos.
*/
- protected String translateEquals( int pos )
- {
+ protected String translateEquals(int pos) {
return null;
}
@Override
- public String toString()
- {
+ public String toString() {
return pattern;
}
}
@@ -723,23 +591,18 @@ public class GNPatternIncludesArtifactFilter
/**
* Simple pattern which performs a logical AND between one or more patterns.
*/
- static class AndPattern extends Pattern
- {
+ static class AndPattern extends Pattern {
private final Pattern[] patterns;
- AndPattern( String pattern, Pattern[] patterns )
- {
- super( pattern );
+ AndPattern(String pattern, Pattern[] patterns) {
+ super(pattern);
this.patterns = patterns;
}
@Override
- public boolean matches( char[][] parts )
- {
- for ( Pattern pattern : patterns )
- {
- if ( !pattern.matches( parts ) )
- {
+ public boolean matches(char[][] parts) {
+ for (Pattern pattern : patterns) {
+ if (!pattern.matches(parts)) {
return false;
}
}
@@ -747,25 +610,20 @@ public class GNPatternIncludesArtifactFilter
}
@Override
- public String translateEquals()
- {
- String[] strings = new String[ patterns.length ];
- for ( int i = 0; i < patterns.length; i++ )
- {
- strings[i] = patterns[i].translateEquals( i );
- if ( strings[i] == null )
- {
+ public String translateEquals() {
+ String[] strings = new String[patterns.length];
+ for (int i = 0; i < patterns.length; i++) {
+ strings[i] = patterns[i].translateEquals(i);
+ if (strings[i] == null) {
return null;
}
}
StringBuilder sb = new StringBuilder();
- for ( int i = 0; i < strings.length; i++ )
- {
- if ( i > 0 )
- {
- sb.append( ":" );
+ for (int i = 0; i < strings.length; i++) {
+ if (i > 0) {
+ sb.append(":");
}
- sb.append( strings[i] );
+ sb.append(strings[i]);
}
return sb.toString();
}
@@ -774,23 +632,18 @@ public class GNPatternIncludesArtifactFilter
/**
* Simple pattern which performs a logical OR between one or more patterns.
*/
- static class OrPattern extends Pattern
- {
+ static class OrPattern extends Pattern {
private final Pattern[] patterns;
- OrPattern( String pattern, Pattern[] patterns )
- {
- super( pattern );
+ OrPattern(String pattern, Pattern[] patterns) {
+ super(pattern);
this.patterns = patterns;
}
@Override
- public boolean matches( char[][] parts )
- {
- for ( Pattern pattern : patterns )
- {
- if ( pattern.matches( parts ) )
- {
+ public boolean matches(char[][] parts) {
+ for (Pattern pattern : patterns) {
+ if (pattern.matches(parts)) {
return true;
}
}
@@ -803,27 +656,22 @@ public class GNPatternIncludesArtifactFilter
* having a position between posMin and posMax (both inclusives) can match
* the pattern.
*/
- static class PosPattern extends Pattern
- {
+ static class PosPattern extends Pattern {
private final char[] patternCharArray;
private final int posMin;
private final int posMax;
- PosPattern( String pattern, char[] patternCharArray, int posMin, int posMax )
- {
- super( pattern );
+ PosPattern(String pattern, char[] patternCharArray, int posMin, int posMax) {
+ super(pattern);
this.patternCharArray = patternCharArray;
this.posMin = posMin;
this.posMax = posMax;
}
@Override
- public boolean matches( char[][] parts )
- {
- for ( int i = posMin; i <= posMax; i++ )
- {
- if ( match( patternCharArray, parts[i], i == 4 ) )
- {
+ public boolean matches(char[][] parts) {
+ for (int i = posMin; i <= posMax; i++) {
+ if (match(patternCharArray, parts[i], i == 4)) {
return true;
}
}
@@ -835,27 +683,22 @@ public class GNPatternIncludesArtifactFilter
* Looks for an exact match in the gatv coordinates between
* posMin and posMax (both inclusives)
*/
- static class EqPattern extends Pattern
- {
+ static class EqPattern extends Pattern {
private final char[] token;
private final int posMin;
private final int posMax;
- EqPattern( String pattern, char[] patternCharArray, int posMin, int posMax )
- {
- super( pattern );
+ EqPattern(String pattern, char[] patternCharArray, int posMin, int posMax) {
+ super(pattern);
this.token = patternCharArray;
this.posMin = posMin;
this.posMax = posMax;
}
@Override
- public boolean matches( char[][] parts )
- {
- for ( int i = posMin; i <= posMax; i++ )
- {
- if ( Arrays.equals( token, parts[i] ) )
- {
+ public boolean matches(char[][] parts) {
+ for (int i = posMin; i <= posMax; i++) {
+ if (Arrays.equals(token, parts[i])) {
return true;
}
}
@@ -863,33 +706,27 @@ public class GNPatternIncludesArtifactFilter
}
@Override
- public String translateEquals()
- {
- return translateEquals( 0 );
+ public String translateEquals() {
+ return translateEquals(0);
}
- public String translateEquals( int pos )
- {
- return posMin == pos && posMax == pos
- && ( pos < 3 || ( token[0] != '[' && token[0] != '(' ) )
- ? String.valueOf( token ) : null;
+ public String translateEquals(int pos) {
+ return posMin == pos && posMax == pos && (pos < 3 || (token[0] != '[' && token[0] != '('))
+ ? String.valueOf(token)
+ : null;
}
-
}
/**
* Matches all input
*/
- static class MatchAllPattern extends Pattern
- {
- MatchAllPattern( String pattern )
- {
- super( pattern );
+ static class MatchAllPattern extends Pattern {
+ MatchAllPattern(String pattern) {
+ super(pattern);
}
@Override
- public boolean matches( char[][] parts )
- {
+ public boolean matches(char[][] parts) {
return true;
}
}
@@ -897,21 +734,17 @@ public class GNPatternIncludesArtifactFilter
/**
* Negative pattern
*/
- static class NegativePattern extends Pattern
- {
+ static class NegativePattern extends Pattern {
private final Pattern inner;
- NegativePattern( String pattern, Pattern inner )
- {
- super( pattern );
+ NegativePattern(String pattern, Pattern inner) {
+ super(pattern);
this.inner = inner;
}
@Override
- public boolean matches( char[][] parts )
- {
- return inner.matches( parts );
+ public boolean matches(char[][] parts) {
+ return inner.matches(parts);
}
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java
index ffd1b53..3b67083 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.ArrayList;
import java.util.Collection;
@@ -39,9 +38,7 @@ import org.slf4j.Logger;
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @see StrictPatternIncludesArtifactFilter
*/
-public class OldPatternIncludesArtifactFilter
- implements ArtifactFilter, StatisticsReportingArtifactFilter
-{
+public class OldPatternIncludesArtifactFilter implements ArtifactFilter, StatisticsReportingArtifactFilter {
private final List<String> positivePatterns;
private final List<String> negativePatterns;
@@ -55,31 +52,24 @@ public class OldPatternIncludesArtifactFilter
/**
* @param patterns The pattern to be used.
*/
- public OldPatternIncludesArtifactFilter( final Collection<String> patterns )
- {
- this( patterns, false );
+ public OldPatternIncludesArtifactFilter(final Collection<String> patterns) {
+ this(patterns, false);
}
/**
* @param patterns The pattern to be used.
* @param actTransitively transitive yes/no.
*/
- public OldPatternIncludesArtifactFilter( final Collection<String> patterns, final boolean actTransitively )
- {
+ public OldPatternIncludesArtifactFilter(final Collection<String> patterns, final boolean actTransitively) {
this.actTransitively = actTransitively;
final List<String> pos = new ArrayList<>();
final List<String> neg = new ArrayList<>();
- if ( patterns != null && !patterns.isEmpty() )
- {
- for ( String pattern : patterns )
- {
- if ( pattern.startsWith( "!" ) )
- {
- neg.add( pattern.substring( 1 ) );
- }
- else
- {
- pos.add( pattern );
+ if (patterns != null && !patterns.isEmpty()) {
+ for (String pattern : patterns) {
+ if (pattern.startsWith("!")) {
+ neg.add(pattern.substring(1));
+ } else {
+ pos.add(pattern);
}
}
}
@@ -89,13 +79,11 @@ public class OldPatternIncludesArtifactFilter
}
/** {@inheritDoc} */
- public boolean include( final Artifact artifact )
- {
- final boolean shouldInclude = patternMatches( artifact );
+ public boolean include(final Artifact artifact) {
+ final boolean shouldInclude = patternMatches(artifact);
- if ( !shouldInclude )
- {
- addFilteredArtifactId( artifact.getId() );
+ if (!shouldInclude) {
+ addFilteredArtifactId(artifact.getId());
}
return shouldInclude;
@@ -105,28 +93,22 @@ public class OldPatternIncludesArtifactFilter
* @param artifact to check for.
* @return true if the match is true false otherwise.
*/
- protected boolean patternMatches( final Artifact artifact )
- {
- return positiveMatch( artifact ) == Boolean.TRUE || negativeMatch( artifact ) == Boolean.FALSE;
+ protected boolean patternMatches(final Artifact artifact) {
+ return positiveMatch(artifact) == Boolean.TRUE || negativeMatch(artifact) == Boolean.FALSE;
}
/**
* @param artifactId add artifact to the filtered artifacts list.
*/
- protected void addFilteredArtifactId( final String artifactId )
- {
- filteredArtifactIds.add( artifactId );
+ protected void addFilteredArtifactId(final String artifactId) {
+ filteredArtifactIds.add(artifactId);
}
- private Boolean negativeMatch( final Artifact artifact )
- {
- if ( negativePatterns == null || negativePatterns.isEmpty() )
- {
+ private Boolean negativeMatch(final Artifact artifact) {
+ if (negativePatterns == null || negativePatterns.isEmpty()) {
return null;
- }
- else
- {
- return match( artifact, negativePatterns );
+ } else {
+ return match(artifact, negativePatterns);
}
}
@@ -134,49 +116,37 @@ public class OldPatternIncludesArtifactFilter
* @param artifact check for positive match.
* @return true/false.
*/
- protected Boolean positiveMatch( final Artifact artifact )
- {
- if ( positivePatterns == null || positivePatterns.isEmpty() )
- {
+ protected Boolean positiveMatch(final Artifact artifact) {
+ if (positivePatterns == null || positivePatterns.isEmpty()) {
return null;
- }
- else
- {
- return match( artifact, positivePatterns );
+ } else {
+ return match(artifact, positivePatterns);
}
}
- private boolean match( final Artifact artifact, final List<String> patterns )
- {
- final String shortId = ArtifactUtils.versionlessKey( artifact );
+ private boolean match(final Artifact artifact, final List<String> patterns) {
+ final String shortId = ArtifactUtils.versionlessKey(artifact);
final String id = artifact.getDependencyConflictId();
final String wholeId = artifact.getId();
- if ( matchAgainst( wholeId, patterns, false ) )
- {
+ if (matchAgainst(wholeId, patterns, false)) {
return true;
}
- if ( matchAgainst( id, patterns, false ) )
- {
+ if (matchAgainst(id, patterns, false)) {
return true;
}
- if ( matchAgainst( shortId, patterns, false ) )
- {
+ if (matchAgainst(shortId, patterns, false)) {
return true;
}
- if ( actTransitively )
- {
+ if (actTransitively) {
final List<String> depTrail = artifact.getDependencyTrail();
- if ( depTrail != null && depTrail.size() > 1 )
- {
- for ( String trailItem : depTrail )
- {
- if ( matchAgainst( trailItem, patterns, true ) )
- {
+ if (depTrail != null && depTrail.size() > 1) {
+ for (String trailItem : depTrail) {
+ if (matchAgainst(trailItem, patterns, true)) {
return true;
}
}
@@ -186,64 +156,52 @@ public class OldPatternIncludesArtifactFilter
return false;
}
- private boolean matchAgainst( final String value, final List<String> patterns, final boolean regionMatch )
- {
- final String[] tokens = value.split( ":" );
- for ( String pattern : patterns )
- {
- String[] patternTokens = pattern.split( ":" );
+ private boolean matchAgainst(final String value, final List<String> patterns, final boolean regionMatch) {
+ final String[] tokens = value.split(":");
+ for (String pattern : patterns) {
+ String[] patternTokens = pattern.split(":");
- if ( patternTokens.length == 5 && tokens.length < 5 )
- {
+ if (patternTokens.length == 5 && tokens.length < 5) {
// 4th element is the classifier
- if ( !"*".equals( patternTokens[3] ) )
- {
+ if (!"*".equals(patternTokens[3])) {
// classifier required, cannot be a match
return false;
}
- patternTokens = new String[] { patternTokens[0], patternTokens[1], patternTokens[2], patternTokens[4] };
+ patternTokens = new String[] {patternTokens[0], patternTokens[1], patternTokens[2], patternTokens[4]};
}
// fail immediately if pattern tokens outnumber tokens to match
boolean matched = patternTokens.length <= tokens.length;
- for ( int i = 0; matched && i < patternTokens.length; i++ )
- {
- matched = matches( tokens[i], patternTokens[i] );
+ for (int i = 0; matched && i < patternTokens.length; i++) {
+ matched = matches(tokens[i], patternTokens[i]);
}
// case of starting '*' like '*:jar:*'
// This really only matches from the end instead.....
- if ( !matched && patternTokens.length < tokens.length && isFirstPatternWildcard( patternTokens ) )
- {
+ if (!matched && patternTokens.length < tokens.length && isFirstPatternWildcard(patternTokens)) {
matched = true;
int tokenOffset = tokens.length - patternTokens.length;
- for ( int i = 0; matched && i < patternTokens.length; i++ )
- {
- matched = matches( tokens[i + tokenOffset], patternTokens[i] );
+ for (int i = 0; matched && i < patternTokens.length; i++) {
+ matched = matches(tokens[i + tokenOffset], patternTokens[i]);
}
}
- if ( matched )
- {
- patternsTriggered.add( pattern );
+ if (matched) {
+ patternsTriggered.add(pattern);
return true;
}
- if ( regionMatch && value.contains( pattern ) )
- {
- patternsTriggered.add( pattern );
+ if (regionMatch && value.contains(pattern)) {
+ patternsTriggered.add(pattern);
return true;
}
-
}
return false;
-
}
- private boolean isFirstPatternWildcard( String[] patternTokens )
- {
- return patternTokens.length > 0 && "*".equals( patternTokens[0] );
+ private boolean isFirstPatternWildcard(String[] patternTokens) {
+ return patternTokens.length > 0 && "*".equals(patternTokens[0]);
}
/**
@@ -253,48 +211,40 @@ public class OldPatternIncludesArtifactFilter
* @param pattern the pattern segment to match, as defined above
* @return <code>true</code> if the specified token is matched by the specified pattern segment
*/
- private boolean matches( final String token, final String pattern )
- {
+ private boolean matches(final String token, final String pattern) {
boolean matches;
// support full wildcard and implied wildcard
- if ( "*".equals( pattern ) || pattern.length() == 0 )
- {
+ if ("*".equals(pattern) || pattern.length() == 0) {
matches = true;
}
// support contains wildcard
- else if ( pattern.startsWith( "*" ) && pattern.endsWith( "*" ) )
- {
- final String contains = pattern.substring( 1, pattern.length() - 1 );
+ else if (pattern.startsWith("*") && pattern.endsWith("*")) {
+ final String contains = pattern.substring(1, pattern.length() - 1);
- matches = token.contains( contains );
+ matches = token.contains(contains);
}
// support leading wildcard
- else if ( pattern.startsWith( "*" ) )
- {
- final String suffix = pattern.substring( 1 );
+ else if (pattern.startsWith("*")) {
+ final String suffix = pattern.substring(1);
- matches = token.endsWith( suffix );
+ matches = token.endsWith(suffix);
}
// support trailing wildcard
- else if ( pattern.endsWith( "*" ) )
- {
- final String prefix = pattern.substring( 0, pattern.length() - 1 );
+ else if (pattern.endsWith("*")) {
+ final String prefix = pattern.substring(0, pattern.length() - 1);
- matches = token.startsWith( prefix );
+ matches = token.startsWith(prefix);
}
// support wildcards in the middle of a pattern segment
- else if ( pattern.indexOf( '*' ) > -1 )
- {
- String[] parts = pattern.split( "\\*" );
+ else if (pattern.indexOf('*') > -1) {
+ String[] parts = pattern.split("\\*");
int lastPartEnd = -1;
boolean match = true;
- for ( String part : parts )
- {
- int idx = token.indexOf( part );
- if ( idx <= lastPartEnd )
- {
+ for (String part : parts) {
+ int idx = token.indexOf(part);
+ if (idx <= lastPartEnd) {
match = false;
break;
}
@@ -305,78 +255,65 @@ public class OldPatternIncludesArtifactFilter
matches = match;
}
// support versions range
- else if ( pattern.startsWith( "[" ) || pattern.startsWith( "(" ) )
- {
- matches = isVersionIncludedInRange( token, pattern );
+ else if (pattern.startsWith("[") || pattern.startsWith("(")) {
+ matches = isVersionIncludedInRange(token, pattern);
}
// support exact match
- else
- {
- matches = token.equals( pattern );
+ else {
+ matches = token.equals(pattern);
}
return matches;
}
- private boolean isVersionIncludedInRange( final String version, final String range )
- {
- try
- {
- return VersionRange.createFromVersionSpec( range ).containsVersion( new DefaultArtifactVersion( version ) );
- }
- catch ( final InvalidVersionSpecificationException e )
- {
+ private boolean isVersionIncludedInRange(final String version, final String range) {
+ try {
+ return VersionRange.createFromVersionSpec(range).containsVersion(new DefaultArtifactVersion(version));
+ } catch (final InvalidVersionSpecificationException e) {
return false;
}
}
/** {@inheritDoc} */
- public void reportMissedCriteria( final Logger logger )
- {
+ public void reportMissedCriteria(final Logger logger) {
// if there are no patterns, there is nothing to report.
- if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
- {
+ if (!positivePatterns.isEmpty() || !negativePatterns.isEmpty()) {
final List<String> missed = new ArrayList<>();
- missed.addAll( positivePatterns );
- missed.addAll( negativePatterns );
+ missed.addAll(positivePatterns);
+ missed.addAll(negativePatterns);
- missed.removeAll( patternsTriggered );
+ missed.removeAll(patternsTriggered);
- if ( !missed.isEmpty() && logger.isWarnEnabled() )
- {
+ if (!missed.isEmpty() && logger.isWarnEnabled()) {
final StringBuilder buffer = new StringBuilder();
- buffer.append( "The following patterns were never triggered in this " );
- buffer.append( getFilterDescription() );
- buffer.append( ':' );
+ buffer.append("The following patterns were never triggered in this ");
+ buffer.append(getFilterDescription());
+ buffer.append(':');
- for ( String pattern : missed )
- {
- buffer.append( "\no '" ).append( pattern ).append( "'" );
+ for (String pattern : missed) {
+ buffer.append("\no '").append(pattern).append("'");
}
- buffer.append( "\n" );
+ buffer.append("\n");
- logger.warn( buffer.toString() );
+ logger.warn(buffer.toString());
}
}
}
@Override
- public String toString()
- {
+ public String toString() {
return "Includes filter:" + getPatternsAsString();
}
/**
* @return pattern as a string.
*/
- protected String getPatternsAsString()
- {
+ protected String getPatternsAsString() {
final StringBuilder buffer = new StringBuilder();
- for ( String pattern : positivePatterns )
- {
- buffer.append( "\no '" ).append( pattern ).append( "'" );
+ for (String pattern : positivePatterns) {
+ buffer.append("\no '").append(pattern).append("'");
}
return buffer.toString();
@@ -385,44 +322,37 @@ public class OldPatternIncludesArtifactFilter
/**
* @return description.
*/
- protected String getFilterDescription()
- {
+ protected String getFilterDescription() {
return "artifact inclusion filter";
}
/** {@inheritDoc} */
- public void reportFilteredArtifacts( final Logger logger )
- {
- if ( !filteredArtifactIds.isEmpty() && logger.isDebugEnabled() )
- {
+ public void reportFilteredArtifacts(final Logger logger) {
+ if (!filteredArtifactIds.isEmpty() && logger.isDebugEnabled()) {
final StringBuilder buffer =
- new StringBuilder( "The following artifacts were removed by this " + getFilterDescription() + ": " );
+ new StringBuilder("The following artifacts were removed by this " + getFilterDescription() + ": ");
- for ( String artifactId : filteredArtifactIds )
- {
- buffer.append( '\n' ).append( artifactId );
+ for (String artifactId : filteredArtifactIds) {
+ buffer.append('\n').append(artifactId);
}
- logger.debug( buffer.toString() );
+ logger.debug(buffer.toString());
}
}
/** {@inheritDoc} */
- public boolean hasMissedCriteria()
- {
+ public boolean hasMissedCriteria() {
// if there are no patterns, there is nothing to report.
- if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
- {
+ if (!positivePatterns.isEmpty() || !negativePatterns.isEmpty()) {
final List<String> missed = new ArrayList<>();
- missed.addAll( positivePatterns );
- missed.addAll( negativePatterns );
+ missed.addAll(positivePatterns);
+ missed.addAll(negativePatterns);
- missed.removeAll( patternsTriggered );
+ missed.removeAll(patternsTriggered);
return !missed.isEmpty();
}
return false;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
index f800a4c..bed51f3 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,31 +16,26 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.List;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-public class PatternExcludesArtifactFilterTest
- extends AbstractPatternArtifactFilterTest
-{
+public class PatternExcludesArtifactFilterTest extends AbstractPatternArtifactFilterTest {
@Override
- protected ArtifactFilter createFilter( final List<String> patterns )
- {
- return new PatternExcludesArtifactFilter( patterns );
+ protected ArtifactFilter createFilter(final List<String> patterns) {
+ return new PatternExcludesArtifactFilter(patterns);
}
@Override
- protected ArtifactFilter createFilter( final List<String> patterns, final boolean actTransitively )
- {
- return new PatternExcludesArtifactFilter( patterns, actTransitively );
+ protected ArtifactFilter createFilter(final List<String> patterns, final boolean actTransitively) {
+ return new PatternExcludesArtifactFilter(patterns, actTransitively);
}
@Override
- protected boolean isInclusionNotExpected()
- {
+ protected boolean isInclusionNotExpected() {
return true;
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternFilterPerfTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternFilterPerfTest.java
index 8b5f26a..40cb1fb 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternFilterPerfTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternFilterPerfTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
@@ -43,20 +42,20 @@ import org.openjdk.jmh.runner.options.TimeValue;
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
-@Warmup(iterations = 3, time = 3 )
+@Warmup(iterations = 3, time = 3)
public class PatternFilterPerfTest {
@State(Scope.Benchmark)
- static public class OldPatternState {
+ public static class OldPatternState {
@Param({
- "groupId:artifact-00,groupId:artifact-01,groupId:artifact-02,groupId:artifact-03,groupId:artifact-04,groupId:artifact-05,groupId:artifact-06,groupId:artifact-07,groupId:artifact-08,groupId:artifact-09",
- "groupId:artifact-99",
- "groupId:artifact-*",
- "*:artifact-99",
- "*:artifact-*",
- "*:artifact-*:*",
- "*:artifact-99:*",
+ "groupId:artifact-00,groupId:artifact-01,groupId:artifact-02,groupId:artifact-03,groupId:artifact-04,groupId:artifact-05,groupId:artifact-06,groupId:artifact-07,groupId:artifact-08,groupId:artifact-09",
+ "groupId:artifact-99",
+ "groupId:artifact-*",
+ "*:artifact-99",
+ "*:artifact-*",
+ "*:artifact-*:*",
+ "*:artifact-99:*",
})
public String patterns;
@@ -64,28 +63,23 @@ public class PatternFilterPerfTest {
Artifact artifact;
@Setup(Level.Invocation)
- public void setup()
- {
- filter = new OldPatternIncludesArtifactFilter( Arrays.asList( patterns.split( "," ) ) );
- artifact = new DefaultArtifact(
- "groupId", "artifact-99", "1.0", "runtime",
- "jar", "", null
- );
+ public void setup() {
+ filter = new OldPatternIncludesArtifactFilter(Arrays.asList(patterns.split(",")));
+ artifact = new DefaultArtifact("groupId", "artifact-99", "1.0", "runtime", "jar", "", null);
}
-
}
@State(Scope.Benchmark)
- static public class GNPatternState {
+ public static class GNPatternState {
@Param({
- "groupId:artifact-00,groupId:artifact-01,groupId:artifact-02,groupId:artifact-03,groupId:artifact-04,groupId:artifact-05,groupId:artifact-06,groupId:artifact-07,groupId:artifact-08,groupId:artifact-09",
- "groupId:artifact-99",
- "groupId:artifact-*",
- "*:artifact-99",
- "*:artifact-*",
- "*:artifact-*:*",
- "*:artifact-99:*",
+ "groupId:artifact-00,groupId:artifact-01,groupId:artifact-02,groupId:artifact-03,groupId:artifact-04,groupId:artifact-05,groupId:artifact-06,groupId:artifact-07,groupId:artifact-08,groupId:artifact-09",
+ "groupId:artifact-99",
+ "groupId:artifact-*",
+ "*:artifact-99",
+ "*:artifact-*",
+ "*:artifact-*:*",
+ "*:artifact-99:*",
})
public String patterns;
@@ -93,28 +87,23 @@ public class PatternFilterPerfTest {
Artifact artifact;
@Setup(Level.Invocation)
- public void setup()
- {
- filter = new GNPatternIncludesArtifactFilter( Arrays.asList( patterns.split( "," ) ) );
- artifact = new DefaultArtifact(
- "groupId", "artifact-99", "1.0", "runtime",
- "jar", "", null
- );
+ public void setup() {
+ filter = new GNPatternIncludesArtifactFilter(Arrays.asList(patterns.split(",")));
+ artifact = new DefaultArtifact("groupId", "artifact-99", "1.0", "runtime", "jar", "", null);
}
-
}
@State(Scope.Benchmark)
- static public class NewPatternState {
+ public static class NewPatternState {
@Param({
- "groupId:artifact-00,groupId:artifact-01,groupId:artifact-02,groupId:artifact-03,groupId:artifact-04,groupId:artifact-05,groupId:artifact-06,groupId:artifact-07,groupId:artifact-08,groupId:artifact-09",
- "groupId:artifact-99",
- "groupId:artifact-*",
- "*:artifact-99",
- "*:artifact-*",
- "*:artifact-*:*",
- "*:artifact-99:*",
+ "groupId:artifact-00,groupId:artifact-01,groupId:artifact-02,groupId:artifact-03,groupId:artifact-04,groupId:artifact-05,groupId:artifact-06,groupId:artifact-07,groupId:artifact-08,groupId:artifact-09",
+ "groupId:artifact-99",
+ "groupId:artifact-*",
+ "*:artifact-99",
+ "*:artifact-*",
+ "*:artifact-*:*",
+ "*:artifact-99:*",
})
public String patterns;
@@ -122,45 +111,34 @@ public class PatternFilterPerfTest {
Artifact artifact;
@Setup(Level.Invocation)
- public void setup()
- {
- filter = new PatternIncludesArtifactFilter( Arrays.asList( patterns.split( "," ) ) );
- artifact = new DefaultArtifact(
- "groupId", "artifact-99", "1.0", "runtime",
- "jar", "", null
- );
+ public void setup() {
+ filter = new PatternIncludesArtifactFilter(Arrays.asList(patterns.split(",")));
+ artifact = new DefaultArtifact("groupId", "artifact-99", "1.0", "runtime", "jar", "", null);
}
-
}
-
@Benchmark
- public boolean newPatternTest(NewPatternState state )
- {
- return state.filter.include( state.artifact );
+ public boolean newPatternTest(NewPatternState state) {
+ return state.filter.include(state.artifact);
}
@Benchmark
- public boolean gnPatternTest(GNPatternState state )
- {
- return state.filter.include( state.artifact );
+ public boolean gnPatternTest(GNPatternState state) {
+ return state.filter.include(state.artifact);
}
@Benchmark
- public boolean oldPatternTest(OldPatternState state )
- {
- return state.filter.include( state.artifact );
+ public boolean oldPatternTest(OldPatternState state) {
+ return state.filter.include(state.artifact);
}
- public static void main( String... args )
- throws RunnerException
- {
+ public static void main(String... args) throws RunnerException {
Options opts = new OptionsBuilder()
- .measurementIterations( 3 )
- .measurementTime( TimeValue.milliseconds( 3000 ) )
- .forks( 1 )
- .include( "org.apache.maven.shared.artifact.filter.PatternFilterPerfTest" )
+ .measurementIterations(3)
+ .measurementTime(TimeValue.milliseconds(3000))
+ .forks(1)
+ .include("org.apache.maven.shared.artifact.filter.PatternFilterPerfTest")
.build();
- new Runner( opts ).run();
+ new Runner(opts).run();
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
index 0b576f8..0299b36 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,29 +16,25 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.List;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-public class PatternIncludesArtifactFilterTest
- extends AbstractPatternArtifactFilterTest
-{
+public class PatternIncludesArtifactFilterTest extends AbstractPatternArtifactFilterTest {
@Override
- protected ArtifactFilter createFilter( final List<String> patterns )
- {
- return new PatternIncludesArtifactFilter( patterns );
+ protected ArtifactFilter createFilter(final List<String> patterns) {
+ return new PatternIncludesArtifactFilter(patterns);
}
@Override
- protected ArtifactFilter createFilter( final List<String> patterns, final boolean actTransitively )
- {
- return new PatternIncludesArtifactFilter( patterns, actTransitively );
+ protected ArtifactFilter createFilter(final List<String> patterns, final boolean actTransitively) {
+ return new PatternIncludesArtifactFilter(patterns, actTransitively);
}
@Override
- protected boolean isInclusionNotExpected()
- {
+ protected boolean isInclusionNotExpected() {
return false;
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
index b00dae2..46f44b4 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,11 +16,7 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+package org.apache.maven.shared.artifact.filter;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
@@ -30,302 +24,290 @@ import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.junit.Test;
-public class ScopeArtifactFilterTest
-{
-
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ScopeArtifactFilterTest {
+
@Test
- public void testExcludedArtifactWithRangeShouldNotCauseNPE()
- throws Exception
- {
+ public void testExcludedArtifactWithRangeShouldNotCauseNPE() throws Exception {
ArtifactStubFactory factory = new ArtifactStubFactory();
-
- Artifact excluded = factory.createArtifact( "group", "artifact",
- VersionRange.createFromVersionSpec( "[1.2.3]" ), Artifact.SCOPE_PROVIDED, "jar", null, false );
-
- ArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME );
-
- assertFalse( filter.include( excluded ) );
+
+ Artifact excluded = factory.createArtifact(
+ "group",
+ "artifact",
+ VersionRange.createFromVersionSpec("[1.2.3]"),
+ Artifact.SCOPE_PROVIDED,
+ "jar",
+ null,
+ false);
+
+ ArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+
+ assertFalse(filter.include(excluded));
}
@Test
- public void testNullScopeDisabled()
- {
+ public void testNullScopeDisabled() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeNullScope( false );
-
- verifyExcluded( filter, null );
+ filter.setIncludeNullScope(false);
+
+ verifyExcluded(filter, null);
}
@Test
- public void testFineGrained_IncludeOnlyScopesThatWereEnabled_TestScope()
- {
+ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_TestScope() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeTestScope( true );
-
- verifyExcluded( filter, Artifact.SCOPE_COMPILE );
- verifyExcluded( filter, Artifact.SCOPE_PROVIDED );
- verifyExcluded( filter, Artifact.SCOPE_RUNTIME );
- verifyExcluded( filter, Artifact.SCOPE_SYSTEM );
- verifyIncluded( filter, Artifact.SCOPE_TEST );
- verifyIncluded( filter, null );
+ filter.setIncludeTestScope(true);
+
+ verifyExcluded(filter, Artifact.SCOPE_COMPILE);
+ verifyExcluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyExcluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyIncluded(filter, Artifact.SCOPE_TEST);
+ verifyIncluded(filter, null);
}
@Test
- public void testFineGrained_IncludeOnlyScopesThatWereEnabled_CompileScope()
- {
+ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_CompileScope() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeCompileScope( true );
-
- verifyIncluded( filter, Artifact.SCOPE_COMPILE );
- verifyExcluded( filter, Artifact.SCOPE_PROVIDED );
- verifyExcluded( filter, Artifact.SCOPE_RUNTIME );
- verifyExcluded( filter, Artifact.SCOPE_SYSTEM );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
- verifyIncluded( filter, null );
+ filter.setIncludeCompileScope(true);
+
+ verifyIncluded(filter, Artifact.SCOPE_COMPILE);
+ verifyExcluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyExcluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
+ verifyIncluded(filter, null);
}
@Test
- public void testFineGrained_IncludeOnlyScopesThatWereEnabled_RuntimeScope()
- {
+ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_RuntimeScope() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeRuntimeScope( true );
-
- verifyExcluded( filter, Artifact.SCOPE_COMPILE );
- verifyExcluded( filter, Artifact.SCOPE_PROVIDED );
- verifyIncluded( filter, Artifact.SCOPE_RUNTIME );
- verifyExcluded( filter, Artifact.SCOPE_SYSTEM );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
- verifyIncluded( filter, null );
+ filter.setIncludeRuntimeScope(true);
+
+ verifyExcluded(filter, Artifact.SCOPE_COMPILE);
+ verifyExcluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
+ verifyIncluded(filter, null);
}
@Test
- public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedScope()
- {
+ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedScope() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeProvidedScope( true );
-
- verifyExcluded( filter, Artifact.SCOPE_COMPILE );
- verifyIncluded( filter, Artifact.SCOPE_PROVIDED );
- verifyExcluded( filter, Artifact.SCOPE_RUNTIME );
- verifyExcluded( filter, Artifact.SCOPE_SYSTEM );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
- verifyIncluded( filter, null );
+ filter.setIncludeProvidedScope(true);
+
+ verifyExcluded(filter, Artifact.SCOPE_COMPILE);
+ verifyIncluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyExcluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
+ verifyIncluded(filter, null);
}
@Test
- public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemScope()
- {
+ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemScope() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeSystemScope( true );
-
- verifyExcluded( filter, Artifact.SCOPE_COMPILE );
- verifyExcluded( filter, Artifact.SCOPE_PROVIDED );
- verifyExcluded( filter, Artifact.SCOPE_RUNTIME );
- verifyIncluded( filter, Artifact.SCOPE_SYSTEM );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
- verifyIncluded( filter, null );
+ filter.setIncludeSystemScope(true);
+
+ verifyExcluded(filter, Artifact.SCOPE_COMPILE);
+ verifyExcluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyExcluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyIncluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
+ verifyIncluded(filter, null);
}
@Test
- public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedAndRuntimeScopes()
- {
+ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedAndRuntimeScopes() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeRuntimeScope( true );
- filter.setIncludeProvidedScope( true );
-
- verifyExcluded( filter, Artifact.SCOPE_COMPILE );
- verifyIncluded( filter, Artifact.SCOPE_PROVIDED );
- verifyIncluded( filter, Artifact.SCOPE_RUNTIME );
- verifyExcluded( filter, Artifact.SCOPE_SYSTEM );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
- verifyIncluded( filter, null );
+ filter.setIncludeRuntimeScope(true);
+ filter.setIncludeProvidedScope(true);
+
+ verifyExcluded(filter, Artifact.SCOPE_COMPILE);
+ verifyIncluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
+ verifyIncluded(filter, null);
}
@Test
- public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemAndRuntimeScopes()
- {
+ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemAndRuntimeScopes() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeRuntimeScope( true );
- filter.setIncludeSystemScope( true );
-
- verifyExcluded( filter, Artifact.SCOPE_COMPILE );
- verifyExcluded( filter, Artifact.SCOPE_PROVIDED );
- verifyIncluded( filter, Artifact.SCOPE_RUNTIME );
- verifyIncluded( filter, Artifact.SCOPE_SYSTEM );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
- verifyIncluded( filter, null );
+ filter.setIncludeRuntimeScope(true);
+ filter.setIncludeSystemScope(true);
+
+ verifyExcluded(filter, Artifact.SCOPE_COMPILE);
+ verifyExcluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyIncluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
+ verifyIncluded(filter, null);
}
@Test
- public void testFineGrainedWithImplications_CompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes()
- {
+ public void
+ testFineGrainedWithImplications_CompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeCompileScopeWithImplications( true );
+ filter.setIncludeCompileScopeWithImplications(true);
- verifyIncluded( filter, null );
- verifyIncluded( filter, Artifact.SCOPE_COMPILE );
- verifyIncluded( filter, Artifact.SCOPE_PROVIDED );
- verifyIncluded( filter, Artifact.SCOPE_SYSTEM );
+ verifyIncluded(filter, null);
+ verifyIncluded(filter, Artifact.SCOPE_COMPILE);
+ verifyIncluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(filter, Artifact.SCOPE_SYSTEM);
- verifyExcluded( filter, Artifact.SCOPE_RUNTIME );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
+ verifyExcluded(filter, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
}
@Test
- public void testFineGrainedWithImplications_RuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes()
- {
+ public void testFineGrainedWithImplications_RuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeRuntimeScopeWithImplications( true );
+ filter.setIncludeRuntimeScopeWithImplications(true);
- verifyIncluded( filter, null );
- verifyIncluded( filter, Artifact.SCOPE_COMPILE );
- verifyIncluded( filter, Artifact.SCOPE_RUNTIME );
+ verifyIncluded(filter, null);
+ verifyIncluded(filter, Artifact.SCOPE_COMPILE);
+ verifyIncluded(filter, Artifact.SCOPE_RUNTIME);
- verifyExcluded( filter, Artifact.SCOPE_PROVIDED );
- verifyExcluded( filter, Artifact.SCOPE_SYSTEM );
- verifyExcluded( filter, Artifact.SCOPE_TEST );
+ verifyExcluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyExcluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(filter, Artifact.SCOPE_TEST);
}
@Test
- public void testFineGrainedWithImplications_TestScopeShouldIncludeAllScopes()
- {
+ public void testFineGrainedWithImplications_TestScopeShouldIncludeAllScopes() {
ScopeArtifactFilter filter = new ScopeArtifactFilter();
- filter.setIncludeTestScopeWithImplications( true );
+ filter.setIncludeTestScopeWithImplications(true);
- verifyIncluded( filter, null );
- verifyIncluded( filter, Artifact.SCOPE_COMPILE );
- verifyIncluded( filter, Artifact.SCOPE_RUNTIME );
+ verifyIncluded(filter, null);
+ verifyIncluded(filter, Artifact.SCOPE_COMPILE);
+ verifyIncluded(filter, Artifact.SCOPE_RUNTIME);
- verifyIncluded( filter, Artifact.SCOPE_PROVIDED );
- verifyIncluded( filter, Artifact.SCOPE_SYSTEM );
- verifyIncluded( filter, Artifact.SCOPE_TEST );
+ verifyIncluded(filter, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(filter, Artifact.SCOPE_SYSTEM);
+ verifyIncluded(filter, Artifact.SCOPE_TEST);
}
-
+
@Test
- public void testScopesShouldIncludeArtifactWithSameScope()
- {
- verifyIncluded( Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE );
- verifyIncluded( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED );
- verifyIncluded( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME );
- verifyIncluded( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM );
- verifyIncluded( Artifact.SCOPE_TEST, Artifact.SCOPE_TEST );
- verifyIncluded( (String) null, null );
+ public void testScopesShouldIncludeArtifactWithSameScope() {
+ verifyIncluded(Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE);
+ verifyIncluded(Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME);
+ verifyIncluded(Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM);
+ verifyIncluded(Artifact.SCOPE_TEST, Artifact.SCOPE_TEST);
+ verifyIncluded((String) null, null);
}
@Test
- public void testCompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes()
- {
+ public void testCompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes() {
String scope = Artifact.SCOPE_COMPILE;
- verifyIncluded( scope, null );
- verifyIncluded( scope, Artifact.SCOPE_COMPILE );
- verifyIncluded( scope, Artifact.SCOPE_PROVIDED );
- verifyIncluded( scope, Artifact.SCOPE_SYSTEM );
+ verifyIncluded(scope, null);
+ verifyIncluded(scope, Artifact.SCOPE_COMPILE);
+ verifyIncluded(scope, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(scope, Artifact.SCOPE_SYSTEM);
- verifyExcluded( scope, Artifact.SCOPE_RUNTIME );
- verifyExcluded( scope, Artifact.SCOPE_TEST );
+ verifyExcluded(scope, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(scope, Artifact.SCOPE_TEST);
}
@Test
- public void testRuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes()
- {
+ public void testRuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes() {
String scope = Artifact.SCOPE_RUNTIME;
- verifyIncluded( scope, null );
- verifyIncluded( scope, Artifact.SCOPE_COMPILE );
- verifyIncluded( scope, Artifact.SCOPE_RUNTIME );
+ verifyIncluded(scope, null);
+ verifyIncluded(scope, Artifact.SCOPE_COMPILE);
+ verifyIncluded(scope, Artifact.SCOPE_RUNTIME);
- verifyExcluded( scope, Artifact.SCOPE_PROVIDED );
- verifyExcluded( scope, Artifact.SCOPE_SYSTEM );
- verifyExcluded( scope, Artifact.SCOPE_TEST );
+ verifyExcluded(scope, Artifact.SCOPE_PROVIDED);
+ verifyExcluded(scope, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(scope, Artifact.SCOPE_TEST);
}
@Test
- public void testTestScopeShouldIncludeAllScopes()
- {
+ public void testTestScopeShouldIncludeAllScopes() {
String scope = Artifact.SCOPE_TEST;
- verifyIncluded( scope, null );
- verifyIncluded( scope, Artifact.SCOPE_COMPILE );
- verifyIncluded( scope, Artifact.SCOPE_RUNTIME );
+ verifyIncluded(scope, null);
+ verifyIncluded(scope, Artifact.SCOPE_COMPILE);
+ verifyIncluded(scope, Artifact.SCOPE_RUNTIME);
- verifyIncluded( scope, Artifact.SCOPE_PROVIDED );
- verifyIncluded( scope, Artifact.SCOPE_SYSTEM );
- verifyIncluded( scope, Artifact.SCOPE_TEST );
+ verifyIncluded(scope, Artifact.SCOPE_PROVIDED);
+ verifyIncluded(scope, Artifact.SCOPE_SYSTEM);
+ verifyIncluded(scope, Artifact.SCOPE_TEST);
}
@Test
- public void testProvidedScopeShouldIncludeOnlyArtifactsWithNullOrProvidedScopes()
- {
+ public void testProvidedScopeShouldIncludeOnlyArtifactsWithNullOrProvidedScopes() {
String scope = Artifact.SCOPE_PROVIDED;
- verifyIncluded( scope, null );
- verifyExcluded( scope, Artifact.SCOPE_COMPILE );
- verifyExcluded( scope, Artifact.SCOPE_RUNTIME );
+ verifyIncluded(scope, null);
+ verifyExcluded(scope, Artifact.SCOPE_COMPILE);
+ verifyExcluded(scope, Artifact.SCOPE_RUNTIME);
- verifyIncluded( scope, Artifact.SCOPE_PROVIDED );
+ verifyIncluded(scope, Artifact.SCOPE_PROVIDED);
- verifyExcluded( scope, Artifact.SCOPE_SYSTEM );
- verifyExcluded( scope, Artifact.SCOPE_TEST );
+ verifyExcluded(scope, Artifact.SCOPE_SYSTEM);
+ verifyExcluded(scope, Artifact.SCOPE_TEST);
}
@Test
- public void testSystemScopeShouldIncludeOnlyArtifactsWithNullOrSystemScopes()
- {
+ public void testSystemScopeShouldIncludeOnlyArtifactsWithNullOrSystemScopes() {
String scope = Artifact.SCOPE_SYSTEM;
- verifyIncluded( scope, null );
- verifyExcluded( scope, Artifact.SCOPE_COMPILE );
- verifyExcluded( scope, Artifact.SCOPE_RUNTIME );
- verifyExcluded( scope, Artifact.SCOPE_PROVIDED );
+ verifyIncluded(scope, null);
+ verifyExcluded(scope, Artifact.SCOPE_COMPILE);
+ verifyExcluded(scope, Artifact.SCOPE_RUNTIME);
+ verifyExcluded(scope, Artifact.SCOPE_PROVIDED);
- verifyIncluded( scope, Artifact.SCOPE_SYSTEM );
+ verifyIncluded(scope, Artifact.SCOPE_SYSTEM);
- verifyExcluded( scope, Artifact.SCOPE_TEST );
+ verifyExcluded(scope, Artifact.SCOPE_TEST);
}
- private void verifyIncluded( String filterScope, String artifactScope )
- {
- Artifact artifact = createMockArtifact( artifactScope );
+ private void verifyIncluded(String filterScope, String artifactScope) {
+ Artifact artifact = createMockArtifact(artifactScope);
- ArtifactFilter filter = new ScopeArtifactFilter( filterScope );
+ ArtifactFilter filter = new ScopeArtifactFilter(filterScope);
- assertTrue( "Artifact scope: " + artifactScope + " NOT included using filter scope: " + filterScope, filter
- .include( artifact ) );
+ assertTrue(
+ "Artifact scope: " + artifactScope + " NOT included using filter scope: " + filterScope,
+ filter.include(artifact));
}
- private void verifyExcluded( String filterScope, String artifactScope )
- {
- Artifact artifact = createMockArtifact( artifactScope );
-
- ArtifactFilter filter = new ScopeArtifactFilter( filterScope );
+ private void verifyExcluded(String filterScope, String artifactScope) {
+ Artifact artifact = createMockArtifact(artifactScope);
- assertFalse( "Artifact scope: " + artifactScope + " NOT excluded using filter scope: " + filterScope, filter
- .include( artifact ) );
+ ArtifactFilter filter = new ScopeArtifactFilter(filterScope);
+
+ assertFalse(
+ "Artifact scope: " + artifactScope + " NOT excluded using filter scope: " + filterScope,
+ filter.include(artifact));
}
- private void verifyIncluded( ScopeArtifactFilter filter, String artifactScope )
- {
- Artifact artifact = createMockArtifact( artifactScope );
+ private void verifyIncluded(ScopeArtifactFilter filter, String artifactScope) {
+ Artifact artifact = createMockArtifact(artifactScope);
- assertTrue( "Artifact scope: " + artifactScope + " SHOULD BE included", filter.include( artifact ) );
+ assertTrue("Artifact scope: " + artifactScope + " SHOULD BE included", filter.include(artifact));
}
- private void verifyExcluded( ScopeArtifactFilter filter, String artifactScope )
- {
- Artifact artifact = createMockArtifact( artifactScope );
+ private void verifyExcluded(ScopeArtifactFilter filter, String artifactScope) {
+ Artifact artifact = createMockArtifact(artifactScope);
- assertFalse( "Artifact scope: " + artifactScope + " SHOULD BE excluded", filter.include( artifact ) );
+ assertFalse("Artifact scope: " + artifactScope + " SHOULD BE excluded", filter.include(artifact));
}
- private Artifact createMockArtifact( String scope )
- {
- Artifact artifact = mock( Artifact.class );
+ private Artifact createMockArtifact(String scope) {
+ Artifact artifact = mock(Artifact.class);
- when( artifact.getScope() ).thenReturn( scope );
- when( artifact.getId() ).thenReturn( "group:artifact:type:version" );
+ when(artifact.getScope()).thenReturn(scope);
+ when(artifact.getId()).thenReturn("group:artifact:type:version");
return artifact;
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
index 497ec61..49421f1 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter;
* "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
+ * 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
@@ -18,32 +16,29 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.List;
/**
* Tests <code>StrictPatternExcludesArtifactFilter</code>.
- *
+ *
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @see StrictPatternExcludesArtifactFilter
*/
-public class StrictPatternExcludesArtifactFilterTest
- extends AbstractStrictPatternArtifactFilterTest
-{
+public class StrictPatternExcludesArtifactFilterTest extends AbstractStrictPatternArtifactFilterTest {
/*
* @see org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#createFilter(java.util.List)
*/
- protected AbstractStrictPatternArtifactFilter createFilter( List<String> patterns )
- {
- return new StrictPatternExcludesArtifactFilter( patterns );
+ protected AbstractStrictPatternArtifactFilter createFilter(List<String> patterns) {
+ return new StrictPatternExcludesArtifactFilter(patterns);
}
/*
* @see org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#assertFilter(boolean,
* java.lang.String)
*/
- protected void assertFilter( boolean expected, String pattern )
- {
- super.assertFilter( !expected, pattern );
+ protected void assertFilter(boolean expected, String pattern) {
+ super.assertFilter(!expected, pattern);
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
index 242ff11..2cb69d6 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter;
* "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
+ * 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
@@ -18,23 +16,21 @@ package org.apache.maven.shared.artifact.filter;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.artifact.filter;
import java.util.List;
/**
* Tests <code>StrictPatternIncludesArtifactFilter</code>.
- *
+ *
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @see StrictPatternIncludesArtifactFilter
*/
-public class StrictPatternIncludesArtifactFilterTest
- extends AbstractStrictPatternArtifactFilterTest
-{
+public class StrictPatternIncludesArtifactFilterTest extends AbstractStrictPatternArtifactFilterTest {
/*
* @see org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#createFilter(java.util.List)
*/
- protected AbstractStrictPatternArtifactFilter createFilter( List<String> patterns )
- {
- return new StrictPatternIncludesArtifactFilter( patterns );
+ protected AbstractStrictPatternArtifactFilter createFilter(List<String> patterns) {
+ return new StrictPatternIncludesArtifactFilter(patterns);
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java
index 5ccca1b..e00e136 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,17 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
-
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -33,91 +32,80 @@ import static org.junit.Assert.assertEquals;
/**
* Abstract test case for subclasses of AbstractArtifactFeatureFilter
*/
-public abstract class AbstractArtifactFeatureFilterTest
-{
+public abstract class AbstractArtifactFeatureFilterTest {
protected Set<Artifact> artifacts = new HashSet<>();
protected Class<?> filterClass;
- private Object createObjectViaReflection( Class<?> clazz, Object[] conArgs )
- throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
- IllegalAccessException, InvocationTargetException
- {
+ private Object createObjectViaReflection(Class<?> clazz, Object[] conArgs)
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
+ IllegalAccessException, InvocationTargetException {
Class<?>[] argslist = new Class<?>[2];
argslist[0] = String.class;
argslist[1] = String.class;
- Constructor<?> ct = clazz.getConstructor( argslist );
- return ct.newInstance( conArgs );
+ Constructor<?> ct = clazz.getConstructor(argslist);
+ return ct.newInstance(conArgs);
}
@Test
- public abstract void testParsing()
- throws Exception;
+ public abstract void testParsing() throws Exception;
public void parsing()
- throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
- IllegalAccessException, InvocationTargetException
- {
- Object[] conArgs = new Object[] { "one,two", "three,four," };
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
+ IllegalAccessException, InvocationTargetException {
+ Object[] conArgs = new Object[] {"one,two", "three,four,"};
AbstractArtifactFeatureFilter filter =
- (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass, conArgs );
+ (AbstractArtifactFeatureFilter) createObjectViaReflection(filterClass, conArgs);
List<String> includes = filter.getIncludes();
List<String> excludes = filter.getExcludes();
- assertEquals( 2, includes.size() );
- assertEquals( 2, excludes.size() );
- assertEquals( "one", includes.get( 0 ) );
- assertEquals( "two", includes.get( 1 ) );
- assertEquals( "three", excludes.get( 0 ) );
- assertEquals( "four", excludes.get( 1 ) );
+ assertEquals(2, includes.size());
+ assertEquals(2, excludes.size());
+ assertEquals("one", includes.get(0));
+ assertEquals("two", includes.get(1));
+ assertEquals("three", excludes.get(0));
+ assertEquals("four", excludes.get(1));
}
@Test
- public abstract void testFiltering()
- throws Exception;
+ public abstract void testFiltering() throws Exception;
public Set<Artifact> filtering()
- throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
- IllegalAccessException, InvocationTargetException
- {
- Object[] conArgs = new Object[] { "one,two", "one,three," };
+ throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
+ IllegalAccessException, InvocationTargetException {
+ Object[] conArgs = new Object[] {"one,two", "one,three,"};
AbstractArtifactFeatureFilter filter =
- (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass, conArgs );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 1, result.size() );
+ (AbstractArtifactFeatureFilter) createObjectViaReflection(filterClass, conArgs);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(1, result.size());
return result;
}
@Test
- public abstract void testFiltering2()
- throws Exception;
+ public abstract void testFiltering2() throws Exception;
public Set<Artifact> filtering2()
- throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
- IllegalAccessException, InvocationTargetException
- {
- Object[] conArgs = new Object[] { null, "one,three," };
+ throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
+ IllegalAccessException, InvocationTargetException {
+ Object[] conArgs = new Object[] {null, "one,three,"};
AbstractArtifactFeatureFilter filter =
- (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass, conArgs );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 2, result.size() );
+ (AbstractArtifactFeatureFilter) createObjectViaReflection(filterClass, conArgs);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(2, result.size());
return result;
-
}
@Test
- public abstract void testFiltering3()
- throws Exception;
+ public abstract void testFiltering3() throws Exception;
public void filtering3()
- throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
- IllegalAccessException, InvocationTargetException
- {
- Object[] conArgs = new Object[] { null, null };
+ throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
+ IllegalAccessException, InvocationTargetException {
+ Object[] conArgs = new Object[] {null, null};
AbstractArtifactFeatureFilter filter =
- (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass, conArgs );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 4, result.size() );
+ (AbstractArtifactFeatureFilter) createObjectViaReflection(filterClass, conArgs);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(4, result.size());
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java
index 5c5aeaf..c80a187 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,17 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@@ -31,53 +31,39 @@ import static org.junit.Assert.assertTrue;
/**
* TestCases for ArtifactFilter
*/
-public class TestArtifactFilter
- extends AbstractArtifactFeatureFilterTest
-{
+public class TestArtifactFilter extends AbstractArtifactFeatureFilterTest {
@Before
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
filterClass = ArtifactIdFilter.class;
- ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
+ ArtifactStubFactory factory = new ArtifactStubFactory(null, false);
artifacts = factory.getArtifactArtifacts();
}
-
@Test
- public void testParsing()
- throws Exception
- {
+ public void testParsing() throws Exception {
parsing();
}
@Test
- public void testFiltering()
- throws Exception
- {
+ public void testFiltering() throws Exception {
Set<Artifact> result = filtering();
- for ( Artifact artifact : result )
- {
- assertEquals( "two", artifact.getArtifactId() );
+ for (Artifact artifact : result) {
+ assertEquals("two", artifact.getArtifactId());
}
}
@Test
- public void testFiltering2()
- throws Exception
- {
+ public void testFiltering2() throws Exception {
Set<Artifact> result = filtering2();
- for ( Artifact artifact : result )
- {
- assertTrue( artifact.getArtifactId().equals( "two" ) || artifact.getArtifactId().equals( "four" ) );
+ for (Artifact artifact : result) {
+ assertTrue(artifact.getArtifactId().equals("two")
+ || artifact.getArtifactId().equals("four"));
}
}
@Test
- public void testFiltering3()
- throws Exception
- {
+ public void testFiltering3() throws Exception {
filtering3();
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java
index 8d176b9..2577318 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,17 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@@ -30,54 +30,40 @@ import static org.junit.Assert.assertTrue;
/**
* Test case for ClassifierFilter
*/
-public class TestClassifierFilter
- extends AbstractArtifactFeatureFilterTest
-{
+public class TestClassifierFilter extends AbstractArtifactFeatureFilterTest {
@Before
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
filterClass = ClassifierFilter.class;
- ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
+ ArtifactStubFactory factory = new ArtifactStubFactory(null, false);
artifacts = factory.getClassifiedArtifacts();
-
}
@Test
- public void testParsing()
- throws Exception
- {
+ public void testParsing() throws Exception {
parsing();
-
}
@Test
- public void testFiltering()
- throws Exception
- {
+ public void testFiltering() throws Exception {
Set<Artifact> result = filtering();
- for ( Artifact artifact : result )
- {
- assertTrue( artifact.getClassifier().equals( "one" ) || artifact.getClassifier().equals( "two" ) );
+ for (Artifact artifact : result) {
+ assertTrue(artifact.getClassifier().equals("one")
+ || artifact.getClassifier().equals("two"));
}
}
@Test
- public void testFiltering2()
- throws Exception
- {
+ public void testFiltering2() throws Exception {
Set<Artifact> result = filtering2();
- for ( Artifact artifact : result )
- {
- assertTrue( artifact.getClassifier().equals( "two" ) || artifact.getClassifier().equals( "four" ) );
+ for (Artifact artifact : result) {
+ assertTrue(artifact.getClassifier().equals("two")
+ || artifact.getClassifier().equals("four"));
}
}
@Test
- public void testFiltering3()
- throws Exception
- {
+ public void testFiltering3() throws Exception {
filtering3();
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java
index ede9860..361741c 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,17 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -35,92 +35,85 @@ import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class TestFilterArtifacts
-{
+public class TestFilterArtifacts {
@Test
- public void testNullFilters()
- throws IOException, ArtifactFilterException
+ public void testNullFilters() throws IOException, ArtifactFilterException {
- {
// TODO: convert these old tests to use the abstract test case for dep
// plugin
- File outputFolder = new File( "target/filters/" );
+ File outputFolder = new File("target/filters/");
- FileUtils.deleteDirectory( outputFolder );
+ FileUtils.deleteDirectory(outputFolder);
- ArtifactStubFactory fact = new ArtifactStubFactory( outputFolder, false );
+ ArtifactStubFactory fact = new ArtifactStubFactory(outputFolder, false);
Set<Artifact> artifacts = fact.getReleaseAndSnapshotArtifacts();
FilterArtifacts fa = new FilterArtifacts();
- fa.filter( artifacts );
+ fa.filter(artifacts);
// make sure null filters don't hurt anything.
- fa.addFilter( null );
+ fa.addFilter(null);
- fa.filter( artifacts );
- assertEquals( 0, fa.getFilters().size() );
+ fa.filter(artifacts);
+ assertEquals(0, fa.getFilters().size());
ArrayList<ArtifactsFilter> filters = new ArrayList<>();
- filters.add( null );
- filters.add( null );
- fa.setFilters( filters );
+ filters.add(null);
+ filters.add(null);
+ fa.setFilters(filters);
- assertEquals( 2, fa.getFilters().size() );
+ assertEquals(2, fa.getFilters().size());
- fa.filter( artifacts );
+ fa.filter(artifacts);
}
@Test
- public void testArtifactFilter()
- {
+ public void testArtifactFilter() {
Set<Artifact> a = new HashSet<>();
FilterArtifacts fa = new FilterArtifacts();
- ArtifactsFilter scope = new ScopeFilter( "compile", "system" );
- ArtifactsFilter type = new TypeFilter( "jar", "war" );
- ArtifactsFilter trans = new ProjectTransitivityFilter( a, true );
-
- assertEquals( 0, fa.getFilters().size() );
- fa.addFilter( scope );
- assertEquals( 1, fa.getFilters().size() );
- fa.addFilter( type );
- assertEquals( 2, fa.getFilters().size() );
- assertTrue( fa.getFilters().get( 0 ) instanceof ScopeFilter );
- assertTrue( fa.getFilters().get( 1 ) instanceof TypeFilter );
- fa.addFilter( 1, trans );
- assertEquals( 3, fa.getFilters().size() );
- assertTrue( fa.getFilters().get( 0 ) instanceof ScopeFilter );
- assertTrue( fa.getFilters().get( 1 ) instanceof ProjectTransitivityFilter );
- assertTrue( fa.getFilters().get( 2 ) instanceof TypeFilter );
-
- ArrayList<ArtifactsFilter> list = new ArrayList<>( fa.getFilters() );
+ ArtifactsFilter scope = new ScopeFilter("compile", "system");
+ ArtifactsFilter type = new TypeFilter("jar", "war");
+ ArtifactsFilter trans = new ProjectTransitivityFilter(a, true);
+
+ assertEquals(0, fa.getFilters().size());
+ fa.addFilter(scope);
+ assertEquals(1, fa.getFilters().size());
+ fa.addFilter(type);
+ assertEquals(2, fa.getFilters().size());
+ assertTrue(fa.getFilters().get(0) instanceof ScopeFilter);
+ assertTrue(fa.getFilters().get(1) instanceof TypeFilter);
+ fa.addFilter(1, trans);
+ assertEquals(3, fa.getFilters().size());
+ assertTrue(fa.getFilters().get(0) instanceof ScopeFilter);
+ assertTrue(fa.getFilters().get(1) instanceof ProjectTransitivityFilter);
+ assertTrue(fa.getFilters().get(2) instanceof TypeFilter);
+
+ ArrayList<ArtifactsFilter> list = new ArrayList<>(fa.getFilters());
fa.clearFilters();
- assertEquals( 0, fa.getFilters().size() );
-
- fa.setFilters( list );
- assertEquals( 3, fa.getFilters().size() );
- assertTrue( fa.getFilters().get( 0 ) instanceof ScopeFilter );
- assertTrue( fa.getFilters().get( 1 ) instanceof ProjectTransitivityFilter );
- assertTrue( fa.getFilters().get( 2 ) instanceof TypeFilter );
+ assertEquals(0, fa.getFilters().size());
+ fa.setFilters(list);
+ assertEquals(3, fa.getFilters().size());
+ assertTrue(fa.getFilters().get(0) instanceof ScopeFilter);
+ assertTrue(fa.getFilters().get(1) instanceof ProjectTransitivityFilter);
+ assertTrue(fa.getFilters().get(2) instanceof TypeFilter);
}
-
+
@Test
- public void testArtifactFilterWithClassifier() throws IOException, ArtifactFilterException
- {
- File outputFolder = new File( "target/filters/" );
- FileUtils.deleteDirectory( outputFolder );
- ArtifactStubFactory fact = new ArtifactStubFactory( outputFolder, false );
+ public void testArtifactFilterWithClassifier() throws IOException, ArtifactFilterException {
+ File outputFolder = new File("target/filters/");
+ FileUtils.deleteDirectory(outputFolder);
+ ArtifactStubFactory fact = new ArtifactStubFactory(outputFolder, false);
Set<Artifact> artifacts = fact.getClassifiedArtifacts();
FilterArtifacts fa = new FilterArtifacts();
- fa.addFilter( new ClassifierFilter( "", "four" ) );
- Set<Artifact> results = fa.filter( artifacts );
- assertEquals( 3, results.size() );
- fa.addFilter( new ClassifierFilter( "two,three", "" ) );
- results = fa.filter( artifacts );
- assertEquals( 2, results.size() );
+ fa.addFilter(new ClassifierFilter("", "four"));
+ Set<Artifact> results = fa.filter(artifacts);
+ assertEquals(3, results.size());
+ fa.addFilter(new ClassifierFilter("two,three", ""));
+ results = fa.filter(artifacts);
+ assertEquals(2, results.size());
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java
index 167c12c..906c14f 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,17 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@@ -31,105 +31,83 @@ import static org.junit.Assert.assertTrue;
/**
* TestCases for GroupIdFilter
*/
-public class TestGroupIdFilter
- extends AbstractArtifactFeatureFilterTest
-{
+public class TestGroupIdFilter extends AbstractArtifactFeatureFilterTest {
@Before
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
filterClass = GroupIdFilter.class;
- ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
+ ArtifactStubFactory factory = new ArtifactStubFactory(null, false);
artifacts = factory.getGroupIdArtifacts();
}
@Test
- public void testParsing()
- throws Exception
- {
+ public void testParsing() throws Exception {
parsing();
}
@Test
- public void testFiltering()
- throws Exception
- {
+ public void testFiltering() throws Exception {
Set<Artifact> result = filtering();
- for ( Artifact artifact : result )
- {
- assertTrue( artifact.getGroupId().equals( "one" ) || artifact.getGroupId().equals( "two" ) );
+ for (Artifact artifact : result) {
+ assertTrue(
+ artifact.getGroupId().equals("one") || artifact.getGroupId().equals("two"));
}
}
@Test
- public void testFiltering2()
- throws Exception
- {
+ public void testFiltering2() throws Exception {
Set<Artifact> result = filtering2();
- for ( Artifact artifact : result )
- {
- assertTrue( artifact.getGroupId().equals( "two" ) || artifact.getGroupId().equals( "four" ) );
+ for (Artifact artifact : result) {
+ assertTrue(
+ artifact.getGroupId().equals("two") || artifact.getGroupId().equals("four"));
}
}
@Test
- public void testFiltering3()
- throws Exception
- {
+ public void testFiltering3() throws Exception {
filtering3();
}
@Test
- public void testFiltering4()
- throws Exception
- {
+ public void testFiltering4() throws Exception {
// include o* from groupIds one,two should leave one
Set<Artifact> result = filtering();
- assertEquals( 1, result.size() );
- GroupIdFilter filter = new GroupIdFilter( "o", null );
- result = filter.filter( result );
- for ( Artifact artifact : result )
- {
- assertEquals( "one", artifact.getGroupId() );
-
+ assertEquals(1, result.size());
+ GroupIdFilter filter = new GroupIdFilter("o", null);
+ result = filter.filter(result);
+ for (Artifact artifact : result) {
+ assertEquals("one", artifact.getGroupId());
}
// exclude on* from groupIds one,two should leave two
result = filtering();
- assertEquals( 1, result.size() );
- filter = new GroupIdFilter( null, "on" );
- result = filter.filter( result );
- for ( Artifact artifact : result )
- {
- assertEquals( "two", artifact.getGroupId() );
-
+ assertEquals(1, result.size());
+ filter = new GroupIdFilter(null, "on");
+ result = filter.filter(result);
+ for (Artifact artifact : result) {
+ assertEquals("two", artifact.getGroupId());
}
}
@Test
- public void testMultipleInclude()
- throws SecurityException, IllegalArgumentException, ArtifactFilterException
- {
- ArtifactsFilter filter = new GroupIdFilter( "one,two", null );
+ public void testMultipleInclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException {
+ ArtifactsFilter filter = new GroupIdFilter("one,two", null);
- assertEquals( 4, artifacts.size() );
+ assertEquals(4, artifacts.size());
- Set<Artifact> result = filter.filter( artifacts );
+ Set<Artifact> result = filter.filter(artifacts);
- assertEquals( 2, result.size() );
+ assertEquals(2, result.size());
}
@Test
- public void testMultipleExclude()
- throws SecurityException, IllegalArgumentException, ArtifactFilterException
- {
- ArtifactsFilter filter = new GroupIdFilter( null, "one,two" );
+ public void testMultipleExclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException {
+ ArtifactsFilter filter = new GroupIdFilter(null, "one,two");
- assertEquals( 4, artifacts.size() );
+ assertEquals(4, artifacts.size());
- Set<Artifact> result = filter.filter( artifacts );
+ Set<Artifact> result = filter.filter(artifacts);
- assertEquals( 2, result.size() );
+ assertEquals(2, result.size());
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java
index ea796c0..322c640 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,17 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@@ -30,57 +30,50 @@ import static org.junit.Assert.*;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class TestProjectTransitivityFilter
-{
+public class TestProjectTransitivityFilter {
Set<Artifact> artifacts;
Set<Artifact> directArtifacts;
-
+
Set<Artifact> classifiedArtifacts;
@Before
- public void setUp() throws Exception
- {
- ArtifactStubFactory fact = new ArtifactStubFactory( null, false );
+ public void setUp() throws Exception {
+ ArtifactStubFactory fact = new ArtifactStubFactory(null, false);
artifacts = fact.getScopedArtifacts();
directArtifacts = fact.getReleaseAndSnapshotArtifacts();
classifiedArtifacts = fact.getClassifiedArtifacts();
- artifacts.addAll( directArtifacts );
- artifacts.addAll( classifiedArtifacts );
+ artifacts.addAll(directArtifacts);
+ artifacts.addAll(classifiedArtifacts);
}
@Test
- public void testAll()
- {
- ProjectTransitivityFilter filter = new ProjectTransitivityFilter( directArtifacts, false );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 11, result.size() );
+ public void testAll() {
+ ProjectTransitivityFilter filter = new ProjectTransitivityFilter(directArtifacts, false);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(11, result.size());
}
@Test
- public void testExclude()
- {
- ProjectTransitivityFilter filter = new ProjectTransitivityFilter( directArtifacts, false );
- assertFalse( filter.isExcludeTransitive() );
- filter.setExcludeTransitive( true );
- assertTrue( filter.isExcludeTransitive() );
- Set<Artifact> result = filter.filter( artifacts );
+ public void testExclude() {
+ ProjectTransitivityFilter filter = new ProjectTransitivityFilter(directArtifacts, false);
+ assertFalse(filter.isExcludeTransitive());
+ filter.setExcludeTransitive(true);
+ assertTrue(filter.isExcludeTransitive());
+ Set<Artifact> result = filter.filter(artifacts);
- assertEquals( 2, result.size() );
+ assertEquals(2, result.size());
- for ( Artifact artifact : result )
- {
- assertTrue(
- artifact.getArtifactId().equals( "release" ) || artifact.getArtifactId().equals( "snapshot" ) );
+ for (Artifact artifact : result) {
+ assertTrue(artifact.getArtifactId().equals("release")
+ || artifact.getArtifactId().equals("snapshot"));
}
}
@Test
- public void testClassified()
- {
- ProjectTransitivityFilter filter = new ProjectTransitivityFilter( classifiedArtifacts, true );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 4, result.size() );
+ public void testClassified() {
+ ProjectTransitivityFilter filter = new ProjectTransitivityFilter(classifiedArtifacts, true);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(4, result.size());
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java
index c99a1c6..60231a6 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,15 +7,17 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@@ -31,176 +31,136 @@ import static org.junit.Assert.*;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class TestScopeFilter
-{
+public class TestScopeFilter {
Set<Artifact> artifacts;
@Before
- public void setUp()
- throws Exception
- {
- ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
+ public void setUp() throws Exception {
+ ArtifactStubFactory factory = new ArtifactStubFactory(null, false);
artifacts = factory.getScopedArtifacts();
}
@Test
- public void testScopeCompile()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_COMPILE, null );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 3, result.size() );
-
+ public void testScopeCompile() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_COMPILE, null);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(3, result.size());
}
@Test
- public void testScopeRuntime()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_RUNTIME, null );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 2, result.size() );
+ public void testScopeRuntime() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_RUNTIME, null);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(2, result.size());
}
@Test
- public void testScopeTest()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_TEST, null );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 5, result.size() );
+ public void testScopeTest() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_TEST, null);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(5, result.size());
}
@Test
- public void testScopeProvided()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_PROVIDED, null );
- Set<Artifact> result = filter.filter( artifacts );
- assertTrue( result.size() > 0 );
- for ( Artifact artifact : result )
- {
- assertEquals( Artifact.SCOPE_PROVIDED, artifact.getScope() );
+ public void testScopeProvided() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_PROVIDED, null);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertTrue(result.size() > 0);
+ for (Artifact artifact : result) {
+ assertEquals(Artifact.SCOPE_PROVIDED, artifact.getScope());
}
}
@Test
- public void testScopeSystem()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_SYSTEM, null );
- Set<Artifact> result = filter.filter( artifacts );
- assertTrue( result.size() > 0 );
- for ( Artifact artifact : result )
- {
- assertEquals( Artifact.SCOPE_SYSTEM, artifact.getScope() );
+ public void testScopeSystem() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_SYSTEM, null);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertTrue(result.size() > 0);
+ for (Artifact artifact : result) {
+ assertEquals(Artifact.SCOPE_SYSTEM, artifact.getScope());
}
}
@Test
- public void testScopeFilterNull()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( null, null );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 5, result.size() );
+ public void testScopeFilterNull() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter(null, null);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(5, result.size());
}
@Test
- public void testScopeFilterEmpty()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( "", "" );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 5, result.size() );
+ public void testScopeFilterEmpty() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter("", "");
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(5, result.size());
}
@Test
- public void testExcludeProvided()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_PROVIDED );
- Set<Artifact> result = filter.filter( artifacts );
- assertNotNull( result );
- assertTrue( result.size() > 0 );
- for ( Artifact artifact : result )
- {
- assertFalse( Artifact.SCOPE_PROVIDED.equalsIgnoreCase( artifact.getScope() ) );
+ public void testExcludeProvided() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_PROVIDED);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertNotNull(result);
+ assertTrue(result.size() > 0);
+ for (Artifact artifact : result) {
+ assertFalse(Artifact.SCOPE_PROVIDED.equalsIgnoreCase(artifact.getScope()));
}
}
@Test
- public void testExcludeSystem()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_SYSTEM );
- Set<Artifact> result = filter.filter( artifacts );
- assertNotNull( result );
- assertTrue( result.size() > 0 );
- for ( Artifact artifact : result )
- {
- assertFalse( Artifact.SCOPE_SYSTEM.equalsIgnoreCase( artifact.getScope() ) );
+ public void testExcludeSystem() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_SYSTEM);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertNotNull(result);
+ assertTrue(result.size() > 0);
+ for (Artifact artifact : result) {
+ assertFalse(Artifact.SCOPE_SYSTEM.equalsIgnoreCase(artifact.getScope()));
}
}
@Test
- public void testExcludeCompile()
- throws ArtifactFilterException
- {
- ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_COMPILE );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 2, result.size() );
+ public void testExcludeCompile() throws ArtifactFilterException {
+ ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_COMPILE);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(2, result.size());
}
@Test
- public void testExcludeTest()
- {
- try
- {
- ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_TEST );
- filter.filter( artifacts );
- Assert.fail( "Expected an Exception" );
- }
- catch ( ArtifactFilterException ignored )
- {
+ public void testExcludeTest() {
+ try {
+ ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_TEST);
+ filter.filter(artifacts);
+ Assert.fail("Expected an Exception");
+ } catch (ArtifactFilterException ignored) {
}
}
@Test
- public void testBadScope()
- {
- ScopeFilter filter = new ScopeFilter( "cOmpile", "" );
- try
- {
- filter.filter( artifacts );
- Assert.fail( "Expected an Exception" );
- }
- catch ( ArtifactFilterException ignored )
- {
+ public void testBadScope() {
+ ScopeFilter filter = new ScopeFilter("cOmpile", "");
+ try {
+ filter.filter(artifacts);
+ Assert.fail("Expected an Exception");
+ } catch (ArtifactFilterException ignored) {
}
- try
- {
- filter = new ScopeFilter( "", "coMpile" );
- filter.filter( artifacts );
- Assert.fail( "Expected an Exception" );
- }
- catch ( ArtifactFilterException ignored )
- {
+ try {
+ filter = new ScopeFilter("", "coMpile");
+ filter.filter(artifacts);
+ Assert.fail("Expected an Exception");
+ } catch (ArtifactFilterException ignored) {
}
}
@Test
- public void testSettersGetters()
- {
- ScopeFilter filter = new ScopeFilter( "include", "exclude" );
- assertEquals( "include", filter.getIncludeScope() );
- assertEquals( "exclude", filter.getExcludeScope() );
-
- filter.setExcludeScope( "a" );
- filter.setIncludeScope( "b" );
- assertEquals( "b", filter.getIncludeScope() );
- assertEquals( "a", filter.getExcludeScope() );
+ public void testSettersGetters() {
+ ScopeFilter filter = new ScopeFilter("include", "exclude");
+ assertEquals("include", filter.getIncludeScope());
+ assertEquals("exclude", filter.getExcludeScope());
+
+ filter.setExcludeScope("a");
+ filter.setIncludeScope("b");
+ assertEquals("b", filter.getIncludeScope());
+ assertEquals("a", filter.getExcludeScope());
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java
index 5da494c..7f84056 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java
@@ -1,6 +1,4 @@
-package org.apache.maven.shared.artifact.filter.collection;
-
-/*
+/*
* 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
@@ -9,22 +7,22 @@ package org.apache.maven.shared.artifact.filter.collection;
* "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
+ * 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.
+ * under the License.
*/
+package org.apache.maven.shared.artifact.filter.collection;
+
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
@@ -37,86 +35,75 @@ import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
-public class TestTypeFilter
-{
+public class TestTypeFilter {
Set<Artifact> artifacts;
@Before
- public void setUp()
- throws Exception
- {
- ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
+ public void setUp() throws Exception {
+ ArtifactStubFactory factory = new ArtifactStubFactory(null, false);
artifacts = factory.getTypedArtifacts();
}
@Test
- public void testTypeParsing()
- {
- TypeFilter filter = new TypeFilter( "war,jar", "sources,zip," );
+ public void testTypeParsing() {
+ TypeFilter filter = new TypeFilter("war,jar", "sources,zip,");
List<String> includes = filter.getIncludes();
List<String> excludes = filter.getExcludes();
- assertEquals( 2, includes.size() );
- assertEquals( 2, excludes.size() );
- assertEquals( "war", includes.get( 0 ) );
- assertEquals( "jar", includes.get( 1 ) );
- assertEquals( "sources", excludes.get( 0 ) );
- assertEquals( "zip", excludes.get( 1 ) );
+ assertEquals(2, includes.size());
+ assertEquals(2, excludes.size());
+ assertEquals("war", includes.get(0));
+ assertEquals("jar", includes.get(1));
+ assertEquals("sources", excludes.get(0));
+ assertEquals("zip", excludes.get(1));
}
@Test
- public void testFiltering()
- {
- TypeFilter filter = new TypeFilter( "war,jar", "war,zip," );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 1, result.size() );
-
- for ( Artifact artifact : result )
- {
- assertEquals( "jar", artifact.getType() );
+ public void testFiltering() {
+ TypeFilter filter = new TypeFilter("war,jar", "war,zip,");
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(1, result.size());
+
+ for (Artifact artifact : result) {
+ assertEquals("jar", artifact.getType());
}
}
@Test
- public void testFiltering2()
- {
- TypeFilter filter = new TypeFilter( null, "war,jar," );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 3, result.size() );
-
- for ( Artifact artifact : result )
- {
- assertTrue( !artifact.getType().equals( "war" ) && !artifact.getType().equals( "jar" ) );
+ public void testFiltering2() {
+ TypeFilter filter = new TypeFilter(null, "war,jar,");
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(3, result.size());
+
+ for (Artifact artifact : result) {
+ assertTrue(!artifact.getType().equals("war") && !artifact.getType().equals("jar"));
}
}
@Test
- public void testFiltering3()
- {
- TypeFilter filter = new TypeFilter( null, null );
- Set<Artifact> result = filter.filter( artifacts );
- assertEquals( 5, result.size() );
+ public void testFiltering3() {
+ TypeFilter filter = new TypeFilter(null, null);
+ Set<Artifact> result = filter.filter(artifacts);
+ assertEquals(5, result.size());
}
@Test
- public void testFilteringOrder()
- throws IOException
- {
- TypeFilter filter = new TypeFilter( "war,jar", "zip" );
+ public void testFilteringOrder() throws IOException {
+ TypeFilter filter = new TypeFilter("war,jar", "zip");
Set<Artifact> artifacts = new LinkedHashSet<>();
- ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
- artifacts.add( factory.createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) );
- artifacts.add( factory.createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "zip", null ) );
- artifacts.add( factory.createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "war", null ) );
+ ArtifactStubFactory factory = new ArtifactStubFactory(null, false);
+ artifacts.add(factory.createArtifact("g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", null));
+ artifacts.add(factory.createArtifact("g", "b", "1.0", Artifact.SCOPE_COMPILE, "zip", null));
+ artifacts.add(factory.createArtifact("g", "c", "1.0", Artifact.SCOPE_COMPILE, "war", null));
- Set<Artifact> result = filter.filter( artifacts );
+ Set<Artifact> result = filter.filter(artifacts);
- assertEquals( 2, result.size() );
+ assertEquals(2, result.size());
- List<Artifact> resultList = new ArrayList<>( result );
+ List<Artifact> resultList = new ArrayList<>(result);
- assertEquals( "a", resultList.get(0).getArtifactId() );
- assertEquals( "c", resultList.get(1).getArtifactId() );
+ assertEquals("a", resultList.get(0).getArtifactId());
+ assertEquals("c", resultList.get(1).getArtifactId());
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java
index 1cef9a7..b310498 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.artifact.filter.resolve.transform;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* "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
+ * 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
@@ -18,9 +16,7 @@ package org.apache.maven.shared.artifact.filter.resolve.transform;
* specific language governing permissions and limitations
* under the License.
*/
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+package org.apache.maven.shared.artifact.filter.resolve.transform;
import java.util.Arrays;
import java.util.Collections;
@@ -44,199 +40,173 @@ import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter;
import org.junit.Before;
import org.junit.Test;
-public class ArtifactIncludeFilterTransformerTest
-{
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ArtifactIncludeFilterTransformerTest {
private ArtifactIncludeFilterTransformer transformer;
private final ArtifactStubFactory artifactFactory = new ArtifactStubFactory();
@Before
- public void setUp()
- {
+ public void setUp() {
transformer = new ArtifactIncludeFilterTransformer();
}
-
+
@Test
- public void testTransformAndFilter()
- throws Exception
- {
- AndFilter filter =
- new AndFilter(
- Arrays.asList( ScopeFilter.including( "compile" ),
- new ExclusionsFilter( Collections.singletonList( "x:a" ) ) ) );
+ public void testTransformAndFilter() throws Exception {
+ AndFilter filter = new AndFilter(Arrays.asList(
+ ScopeFilter.including("compile"), new ExclusionsFilter(Collections.singletonList("x:a"))));
- AndArtifactFilter dependencyFilter = (AndArtifactFilter) filter.transform( transformer );
+ AndArtifactFilter dependencyFilter = (AndArtifactFilter) filter.transform(transformer);
- assertTrue( dependencyFilter.include( newArtifact( "g:a:v", "compile" ) ) );
+ assertTrue(dependencyFilter.include(newArtifact("g:a:v", "compile")));
- assertFalse( dependencyFilter.include( newArtifact( "x:a:v", "compile" ) ) );
+ assertFalse(dependencyFilter.include(newArtifact("x:a:v", "compile")));
- assertFalse( dependencyFilter.include( newArtifact( "g:a:v", "test" ) ) );
+ assertFalse(dependencyFilter.include(newArtifact("g:a:v", "test")));
... 926 lines suppressed ...
(maven-common-artifact-filters) 02/02: Ignore blame revs
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch parent-42-maven-3.6.3
in repository https://gitbox.apache.org/repos/asf/maven-common-artifact-filters.git
commit 960fd03e4f87c86c2e9d7d856e0a45eb09c6fa96
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Jun 4 21:19:25 2024 +0200
Ignore blame revs
---
.git-blame-ignore-revs | 1 +
1 file changed, 1 insertion(+)
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000..767c5dd
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1 @@
+3aa202665cc24b8ddb8e36029436ad6e3ec5529a
\ No newline at end of file