Skip to content
Commits on Source (7)
......@@ -32,7 +32,7 @@ Getting Started
+ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
+ Make sure you have a [GitHub account](https://github.com/signup/free).
+ If you're planning to implement a new feature, it makes sense to discuss your changes
on the [dev list](https://maven.apache.org/mail-lists.html) first.
on the [dev list](https://maven.apache.org/mailing-lists.html) first.
This way you can make sure you're not wasting your time on something that isn't
considered to be in Apache Maven's scope.
+ Submit a ticket for your issue, assuming one does not already exist.
......@@ -85,7 +85,7 @@ Additional Resources
+ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject)
+ #Maven IRC channel on freenode.org
[dev-ml-list]: https://maven.apache.org/mail-lists.html
[dev-ml-list]: https://maven.apache.org/mailing-lists.html
[code-style]: https://maven.apache.org/developers/conventions/code.html
[cla]: https://www.apache.org/licenses/#clas
[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index
......
......@@ -17,14 +17,14 @@
* under the License.
*/
properties([buildDiscarder(logRotator(artifactNumToKeepStr: '5', numToKeepStr: env.BRANCH_NAME=='master'?'10':'5'))])
properties([buildDiscarder(logRotator(artifactNumToKeepStr: '5', numToKeepStr: env.BRANCH_NAME=='master'?'5':'1'))])
def buildOs = 'linux'
def buildJdk = '8'
def buildMvn = '3.5.4'
def buildMvn = '3.6.0'
def runITsOses = ['linux', 'windows']
def runITsJdks = ['7', '8', '9']
def runITsMvn = '3.5.4'
def runITsJdks = ['7', '8', '11']
def runITsMvn = '3.6.0'
def runITscommand = "mvn clean install -Prun-its,embedded -B -U -V" // -DmavenDistro=... -Dmaven.test.failure.ignore=true
def tests
......@@ -117,6 +117,7 @@ parallel(runITsTasks)
// JENKINS-34376 seems to make it hard to detect the aborted builds
} catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
echo "[FAILURE-002] FlowInterruptedException ${e}"
// this ambiguous condition means a user probably aborted
if (e.causes.size() == 0) {
currentBuild.result = "ABORTED"
......@@ -125,6 +126,7 @@ parallel(runITsTasks)
}
throw e
} catch (hudson.AbortException e) {
echo "[FAILURE-003] AbortException ${e}"
// this ambiguous condition means during a shell step, user probably aborted
if (e.getMessage().contains('script returned exit code 143')) {
currentBuild.result = "ABORTED"
......@@ -133,9 +135,11 @@ parallel(runITsTasks)
}
throw e
} catch (InterruptedException e) {
echo "[FAILURE-004] ${e}"
currentBuild.result = "ABORTED"
throw e
} catch (Throwable e) {
echo "[FAILURE-001] ${e}"
currentBuild.result = "FAILURE"
throw e
} finally {
......
......@@ -71,7 +71,7 @@ If you want to bootstrap Maven, you'll need:
- Maven 3.0.5 or later
- Run Maven, specifying a location into which the completed Maven distro should be installed:
```
mvn -DdistributionTargetDir="$HOME/app/maven/apache-maven-3.5.x-SNAPSHOT" clean package
mvn -DdistributionTargetDir="$HOME/app/maven/apache-maven-3.6.x-SNAPSHOT" clean package
```
......@@ -83,7 +83,7 @@ mvn -DdistributionTargetDir="$HOME/app/maven/apache-maven-3.5.x-SNAPSHOT" clean
[build-tests]: https://img.shields.io/jenkins/t/https/builds.apache.org/job/maven-box/job/maven/job/master.svg?style=flat-square
[maven-home]: https://maven.apache.org/
[maven-download]: https://maven.apache.org/download.cgi
[users-list]: https://maven.apache.org/mail-lists.html
[users-list]: https://maven.apache.org/mailing-lists.html
[dev-ml-list]: https://www.mail-archive.com/dev@maven.apache.org/
[code-style]: http://maven.apache.org/developers/conventions/code.html
[core-it]: https://maven.apache.org/core-its/core-it-suite/
......
......@@ -72,7 +72,7 @@
Home Page: https://maven.apache.org/
Downloads: https://maven.apache.org/download.html
Release Notes: https://maven.apache.org/docs/history.html
Mailing Lists: https://maven.apache.org/mail-lists.html
Mailing Lists: https://maven.apache.org/mailing-lists.html
Source Code: https://gitbox.apache.org/repos/asf/maven.git
Issue Tracking: https://issues.apache.org/jira/browse/MNG
Wiki: https://cwiki.apache.org/confluence/display/MAVEN/
......
......@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
</parent>
<artifactId>apache-maven</artifactId>
......
......@@ -115,7 +115,7 @@ if "%FILE_ARG%" == "" (
goto findBaseDir
)
if not exist "%FILE_ARG%" (
echo POM file %FILE_ARG% specified the -f/--file command-line argument does not exist >&2
echo POM file "%FILE_ARG%" specified the -f/--file command-line argument does not exist >&2
goto error
)
if exist "%FILE_ARG%\*" (
......@@ -124,7 +124,7 @@ if exist "%FILE_ARG%\*" (
call :get_directory_from_file "%FILE_ARG%"
)
if not exist "%POM_DIR%" (
echo Directory %POM_DIR% extracted from the -f/--file command-line argument %FILE_ARG% does not exist >&2
echo Directory "%POM_DIR%" extracted from the -f/--file command-line argument "%FILE_ARG%" does not exist >&2
goto error
)
set "WDIR=%POM_DIR%"
......
......@@ -21,7 +21,7 @@
Apache Maven includes a number of components and libraries with separate
copyright notices and license terms. Your use of those components are
subject to the terms and conditions of the following licenses:
#
##
#set ( $apacheLicenseNames = [ "Apache License, Version 2.0", "The Apache Software License, Version 2.0",
"ASLv2", "Apache Public License 2.0", "Apache 2.0" ] )
#set ( $MITLicenseNames = [ "MIT License", "MIT license", "The MIT License" ] )
......
......@@ -17,8 +17,8 @@ specific language governing permissions and limitations
under the License.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>zip</format>
......
......@@ -16,8 +16,8 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<component xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3 http://maven.apache.org/xsd/component-1.1.3.xsd">
<component xmlns="http://maven.apache.org/ASSEMBLY-COMPONENT/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY-COMPONENT/2.0.0 http://maven.apache.org/xsd/assembly-component-2.0.0.xsd">
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
......
......@@ -17,8 +17,8 @@ specific language governing permissions and limitations
under the License.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>dir</id>
<formats>
<format>dir</format>
......
......@@ -17,8 +17,8 @@ specific language governing permissions and limitations
under the License.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>src</id>
<formats>
<format>zip</format>
......
maven (3.6.1-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Refreshed the patches
- Depend on libplexus-utils2-java (>= 3.2)
- Depend on libmodello-maven-plugin-java (>= 1.10)
* Standards-Version updated to 4.4.0
-- Emmanuel Bourg <ebourg@apache.org> Sat, 20 Jul 2019 10:37:07 +0200
maven (3.6.0-1) unstable; urgency=medium
* Team upload.
......
......@@ -22,12 +22,12 @@ Build-Depends:
libmaven-shade-plugin-java,
libmaven-shared-utils-java (>= 3.2.1),
libmockito-java,
libmodello-maven-plugin-java (>= 1.9.1),
libmodello-maven-plugin-java (>= 1.10),
libplexus-classworlds-java (>= 2.5.2),
libplexus-component-annotations-java (>= 1.7.1-6~),
libplexus-component-metadata-java (>= 1.7),
libplexus-interpolation-java (>= 1.24),
libplexus-utils2-java (>= 3.0.24),
libplexus-utils2-java (>= 3.2),
libsisu-maven-plugin-java,
libsisu-plexus-java (>= 0.3.3),
libslf4j-java (>= 1.7.25),
......@@ -38,7 +38,7 @@ Build-Depends:
libwagon-provider-api-java,
libxmlunit-java,
maven-debian-helper
Standards-Version: 4.2.1
Standards-Version: 4.4.0
Vcs-Git: https://salsa.debian.org/java-team/maven.git
Vcs-Browser: https://salsa.debian.org/java-team/maven
Homepage: http://maven.apache.org
......
......@@ -84,7 +84,7 @@ Bug: https://github.com/apache/maven/pull/118
</executions>
--- a/pom.xml
+++ b/pom.xml
@@ -591,6 +591,7 @@
@@ -594,6 +594,7 @@
<exclude>bootstrap/**</exclude>
<exclude>README.bootstrap.txt</exclude>
<exclude>README.md</exclude>
......
......@@ -33,6 +33,17 @@ under the License.
<release>
<Version>
<name>Latest stable release</name>
<created>2018-10-23</created>
<revision>3.6.0</revision>
<file-release>http://archive.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.zip</file-release>
<file-release>http://archive.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz</file-release>
<file-release>http://archive.apache.org/dist/maven/maven-3/3.6.0/source/apache-maven-3.6.0-src.zip</file-release>
<file-release>http://archive.apache.org/dist/maven/maven-3/3.6.0/source/apache-maven-3.6.0-src.tar.gz</file-release>
</Version>
</release>
<release>
<Version>
<name>Apache Maven 3.5.4</name>
<created>2018-06-21</created>
<revision>3.5.4</revision>
<file-release>http://archive.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip</file-release>
......
......@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
</parent>
<artifactId>maven-artifact</artifactId>
......
......@@ -138,7 +138,7 @@ public static Artifact copyArtifact( Artifact artifact )
range = VersionRange.createFromVersion( artifact.getVersion() );
}
DefaultArtifact clone = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), range.cloneOf(),
DefaultArtifact clone = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), range,
artifact.getScope(), artifact.getType(), artifact.getClassifier(),
artifact.getArtifactHandler(), artifact.isOptional() );
clone.setRelease( artifact.isRelease() );
......
......@@ -20,13 +20,16 @@
*/
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Stack;
import org.apache.commons.lang3.StringUtils;
/**
* <p>
......@@ -62,6 +65,10 @@
public class ComparableVersion
implements Comparable<ComparableVersion>
{
private static final int MAX_INTITEM_LENGTH = 9;
private static final int MAX_LONGITEM_LENGTH = 18;
private String value;
private String canonical;
......@@ -70,7 +77,9 @@ public class ComparableVersion
private interface Item
{
int INTEGER_ITEM = 0;
int INT_ITEM = 3;
int LONG_ITEM = 4;
int BIGINTEGER_ITEM = 0;
int STRING_ITEM = 1;
int LIST_ITEM = 2;
......@@ -82,48 +91,174 @@ private interface Item
}
/**
* Represents a numeric item in the version item list.
* Represents a numeric item in the version item list that can be represented with an int.
*/
private static class IntegerItem
private static class IntItem
implements Item
{
private static final BigInteger BIG_INTEGER_ZERO = new BigInteger( "0" );
private final int value;
private final BigInteger value;
public static final IntItem ZERO = new IntItem();
private IntItem()
{
this.value = 0;
}
IntItem( String str )
{
this.value = Integer.parseInt( str );
}
@Override
public int getType()
{
return INT_ITEM;
}
@Override
public boolean isNull()
{
return value == 0;
}
@Override
public int compareTo( Item item )
{
if ( item == null )
{
return ( value == 0 ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
}
public static final IntegerItem ZERO = new IntegerItem();
switch ( item.getType() )
{
case INT_ITEM:
int itemValue = ( (IntItem) item ).value;
return ( value < itemValue ) ? -1 : ( ( value == itemValue ) ? 0 : 1 );
case LONG_ITEM:
case BIGINTEGER_ITEM:
return -1;
private IntegerItem()
case STRING_ITEM:
return 1; // 1.1 > 1-sp
case LIST_ITEM:
return 1; // 1.1 > 1-1
default:
throw new IllegalStateException( "invalid item: " + item.getClass() );
}
}
@Override
public String toString()
{
this.value = BIG_INTEGER_ZERO;
return Integer.toString( value );
}
}
/**
* Represents a numeric item in the version item list that can be represented with a long.
*/
private static class LongItem
implements Item
{
private final long value;
IntegerItem( String str )
LongItem( String str )
{
this.value = Long.parseLong( str );
}
@Override
public int getType()
{
return LONG_ITEM;
}
@Override
public boolean isNull()
{
return value == 0;
}
@Override
public int compareTo( Item item )
{
if ( item == null )
{
return ( value == 0 ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
}
switch ( item.getType() )
{
case INT_ITEM:
return 1;
case LONG_ITEM:
long itemValue = ( (LongItem) item ).value;
return ( value < itemValue ) ? -1 : ( ( value == itemValue ) ? 0 : 1 );
case BIGINTEGER_ITEM:
return -1;
case STRING_ITEM:
return 1; // 1.1 > 1-sp
case LIST_ITEM:
return 1; // 1.1 > 1-1
default:
throw new IllegalStateException( "invalid item: " + item.getClass() );
}
}
@Override
public String toString()
{
return Long.toString( value );
}
}
/**
* Represents a numeric item in the version item list.
*/
private static class BigIntegerItem
implements Item
{
private final BigInteger value;
BigIntegerItem( String str )
{
this.value = new BigInteger( str );
}
@Override
public int getType()
{
return INTEGER_ITEM;
return BIGINTEGER_ITEM;
}
@Override
public boolean isNull()
{
return BIG_INTEGER_ZERO.equals( value );
return BigInteger.ZERO.equals( value );
}
@Override
public int compareTo( Item item )
{
if ( item == null )
{
return BIG_INTEGER_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
return BigInteger.ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
}
switch ( item.getType() )
{
case INTEGER_ITEM:
return value.compareTo( ( (IntegerItem) item ).value );
case INT_ITEM:
case LONG_ITEM:
return 1;
case BIGINTEGER_ITEM:
return value.compareTo( ( (BigIntegerItem) item ).value );
case STRING_ITEM:
return 1; // 1.1 > 1-sp
......@@ -132,10 +267,11 @@ public int compareTo( Item item )
return 1; // 1.1 > 1-1
default:
throw new RuntimeException( "invalid item: " + item.getClass() );
throw new IllegalStateException( "invalid item: " + item.getClass() );
}
}
@Override
public String toString()
{
return value.toString();
......@@ -165,7 +301,7 @@ private static class StringItem
*/
private static final String RELEASE_VERSION_INDEX = String.valueOf( QUALIFIERS.indexOf( "" ) );
private String value;
private final String value;
StringItem( String value, boolean followedByDigit )
{
......@@ -189,11 +325,13 @@ private static class StringItem
this.value = ALIASES.getProperty( value , value );
}
@Override
public int getType()
{
return STRING_ITEM;
}
@Override
public boolean isNull()
{
return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 );
......@@ -219,6 +357,7 @@ public static String comparableQualifier( String qualifier )
return i == -1 ? ( QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i );
}
@Override
public int compareTo( Item item )
{
if ( item == null )
......@@ -228,7 +367,9 @@ public int compareTo( Item item )
}
switch ( item.getType() )
{
case INTEGER_ITEM:
case INT_ITEM:
case LONG_ITEM:
case BIGINTEGER_ITEM:
return -1; // 1.any < 1.1 ?
case STRING_ITEM:
......@@ -238,10 +379,11 @@ public int compareTo( Item item )
return -1; // 1.any < 1-1
default:
throw new RuntimeException( "invalid item: " + item.getClass() );
throw new IllegalStateException( "invalid item: " + item.getClass() );
}
}
@Override
public String toString()
{
return value;
......@@ -256,11 +398,13 @@ private static class ListItem
extends ArrayList<Item>
implements Item
{
@Override
public int getType()
{
return LIST_ITEM;
}
@Override
public boolean isNull()
{
return ( size() == 0 );
......@@ -284,6 +428,7 @@ else if ( !( lastItem instanceof ListItem ) )
}
}
@Override
public int compareTo( Item item )
{
if ( item == null )
......@@ -297,7 +442,9 @@ public int compareTo( Item item )
}
switch ( item.getType() )
{
case INTEGER_ITEM:
case INT_ITEM:
case LONG_ITEM:
case BIGINTEGER_ITEM:
return -1; // 1-1 < 1.0.x
case STRING_ITEM:
......@@ -324,10 +471,11 @@ public int compareTo( Item item )
return 0;
default:
throw new RuntimeException( "invalid item: " + item.getClass() );
throw new IllegalStateException( "invalid item: " + item.getClass() );
}
}
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder();
......@@ -359,7 +507,7 @@ public final void parseVersion( String version )
ListItem list = items;
Stack<Item> stack = new Stack<>();
Deque<Item> stack = new ArrayDeque<>();
stack.push( list );
boolean isDigit = false;
......@@ -374,7 +522,7 @@ public final void parseVersion( String version )
{
if ( i == startIndex )
{
list.add( IntegerItem.ZERO );
list.add( IntItem.ZERO );
}
else
{
......@@ -386,7 +534,7 @@ else if ( c == '-' )
{
if ( i == startIndex )
{
list.add( IntegerItem.ZERO );
list.add( IntItem.ZERO );
}
else
{
......@@ -441,14 +589,41 @@ else if ( Character.isDigit( c ) )
private static Item parseItem( boolean isDigit, String buf )
{
return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false );
if ( isDigit )
{
buf = stripLeadingZeroes( buf );
if ( buf.length() <= MAX_INTITEM_LENGTH )
{
// lower than 2^31
return new IntItem( buf );
}
else if ( buf.length() <= MAX_LONGITEM_LENGTH )
{
// lower than 2^63
return new LongItem( buf );
}
return new BigIntegerItem( buf );
}
return new StringItem( buf, false );
}
private static String stripLeadingZeroes( String buf )
{
String strippedBuf = StringUtils.stripStart( buf, "0" );
if ( strippedBuf.isEmpty() )
{
return "0";
}
return strippedBuf;
}
@Override
public int compareTo( ComparableVersion o )
{
return items.compareTo( o.items );
}
@Override
public String toString()
{
return value;
......@@ -459,11 +634,13 @@ public String getCanonical()
return canonical;
}
@Override
public boolean equals( Object o )
{
return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical );
}
@Override
public int hashCode()
{
return canonical.hashCode();
......
......@@ -23,6 +23,8 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import org.apache.maven.artifact.Artifact;
......@@ -33,6 +35,12 @@
*/
public class VersionRange
{
private static final Map<String, VersionRange> CACHE_SPEC =
Collections.<String, VersionRange>synchronizedMap( new WeakHashMap<String, VersionRange>() );
private static final Map<String, VersionRange> CACHE_VERSION =
Collections.<String, VersionRange>synchronizedMap( new WeakHashMap<String, VersionRange>() );
private final ArtifactVersion recommendedVersion;
private final List<Restriction> restrictions;
......@@ -54,6 +62,11 @@ public List<Restriction> getRestrictions()
return restrictions;
}
/**
* @deprecated VersionRange is immutable, cloning is not useful and even more an issue against the cache
* @return a clone
*/
@Deprecated
public VersionRange cloneOf()
{
List<Restriction> copiedRestrictions = null;
......@@ -97,6 +110,12 @@ public static VersionRange createFromVersionSpec( String spec )
return null;
}
VersionRange cached = CACHE_SPEC.get( spec );
if ( cached != null )
{
return cached;
}
List<Restriction> restrictions = new ArrayList<>();
String process = spec;
ArtifactVersion version = null;
......@@ -159,7 +178,9 @@ public static VersionRange createFromVersionSpec( String spec )
}
}
return new VersionRange( version, restrictions );
cached = new VersionRange( version, restrictions );
CACHE_SPEC.put( spec, cached );
return cached;
}
private static Restriction parseRestriction( String spec )
......@@ -217,9 +238,15 @@ private static Restriction parseRestriction( String spec )
}
public static VersionRange createFromVersion( String version )
{
VersionRange cached = CACHE_VERSION.get( version );
if ( cached == null )
{
List<Restriction> restrictions = Collections.emptyList();
return new VersionRange( new DefaultArtifactVersion( version ), restrictions );
cached = new VersionRange( new DefaultArtifactVersion( version ), restrictions );
CACHE_VERSION.put( version, cached );
}
return cached;
}
/**
......
......@@ -85,6 +85,14 @@ private void checkVersionsEqual( String v1, String v2 )
assertTrue( "expected " + v2 + ".equals( " + v1 + " )", c2.equals( c1 ) );
}
private void checkVersionsArrayEqual( String[] array )
{
// compare against each other (including itself)
for ( int i = 0; i < array.length; ++i )
for ( int j = i; j < array.length; ++j )
checkVersionsEqual( array[i], array[j] );
}
private void checkVersionsOrder( String v1, String v2 )
{
Comparable c1 = newComparable( v1 );
......@@ -201,6 +209,88 @@ public void testMng5568()
checkVersionsOrder( a, c );
}
/**
* Test <a href="https://jira.apache.org/jira/browse/MNG-6572">MNG-6572</a> optimization.
*/
public void testMng6572()
{
String a = "20190126.230843"; // resembles a SNAPSHOT
String b = "1234567890.12345"; // 10 digit number
String c = "123456789012345.1H.5-beta"; // 15 digit number
String d = "12345678901234567890.1H.5-beta"; // 20 digit number
checkVersionsOrder( a, b );
checkVersionsOrder( b, c );
checkVersionsOrder( a, c );
checkVersionsOrder( c, d );
checkVersionsOrder( b, d );
checkVersionsOrder( a, d );
}
/**
* Test all versions are equal when starting with many leading zeroes regardless of string length
* (related to MNG-6572 optimization)
*/
public void testVersionEqualWithLeadingZeroes()
{
// versions with string lengths from 1 to 19
String[] arr = new String[] {
"0000000000000000001",
"000000000000000001",
"00000000000000001",
"0000000000000001",
"000000000000001",
"00000000000001",
"0000000000001",
"000000000001",
"00000000001",
"0000000001",
"000000001",
"00000001",
"0000001",
"000001",
"00001",
"0001",
"001",
"01",
"1"
};
checkVersionsArrayEqual( arr );
}
/**
* Test all "0" versions are equal when starting with many leading zeroes regardless of string length
* (related to MNG-6572 optimization)
*/
public void testVersionZeroEqualWithLeadingZeroes()
{
// versions with string lengths from 1 to 19
String[] arr = new String[] {
"0000000000000000000",
"000000000000000000",
"00000000000000000",
"0000000000000000",
"000000000000000",
"00000000000000",
"0000000000000",
"000000000000",
"00000000000",
"0000000000",
"000000000",
"00000000",
"0000000",
"000000",
"00000",
"0000",
"000",
"00",
"0"
};
checkVersionsArrayEqual( arr );
}
public void testLocaleIndependent()
{
Locale orig = Locale.getDefault();
......