Skip to content

Commit

Permalink
[MSHARED-1301] Upgrade to Parent 42 and Maven 3.6.3
Browse files Browse the repository at this point in the history
This closes #36
  • Loading branch information
michael-o committed Jun 4, 2024
1 parent 1742cb1 commit 888d69a
Show file tree
Hide file tree
Showing 57 changed files with 2,520 additions and 3,640 deletions.
25 changes: 12 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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>

Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -72,38 +72,37 @@
<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>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.13.0</version>
<version>2.16.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,7 +7,7 @@
* "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
Expand All @@ -18,15 +16,16 @@
* 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;
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:
*
Expand All @@ -44,8 +43,7 @@
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
*/
public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFilter
{
public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFilter {
// fields -----------------------------------------------------------------

/**
Expand All @@ -70,23 +68,19 @@ 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;
}

// 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;
}
Expand All @@ -99,96 +93,79 @@ public boolean include( Artifact artifact )

/**
* 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;
}

/**
* 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;
}
}

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.shared.artifact.filter;

import java.util.Collection;

Expand All @@ -29,17 +28,14 @@
* @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);
}

/**
Expand All @@ -48,34 +44,28 @@ public PatternExcludesArtifactFilter( Collection<String> patterns )
* @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();
}

}
Loading

0 comments on commit 888d69a

Please sign in to comment.