Author: bentmann
Date: Tue Jan 5 15:44:35 2010
New Revision: 896102
URL: http://svn.apache.org/viewvc?rev=896102&view=rev
Log:
[MNG-4518] Profile activation based on JRE version misbehaves if java.version
has build number
Modified:
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java
Modified:
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java?rev=896102&r1=896101&r2=896102&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
(original)
+++
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
Tue Jan 5 15:44:35 2010
@@ -108,20 +108,10 @@
List<String> valueTokens = new ArrayList<String>( Arrays.asList(
value.split( "[\\.\\-\\_]" ) ) );
List<String> rangeValueTokens = new ArrayList<String>( Arrays.asList(
rangeValue.value.split( "\\." ) ) );
- int max = Math.max( valueTokens.size(), rangeValueTokens.size() );
- addZeroTokens( valueTokens, max );
- addZeroTokens( rangeValueTokens, max );
+ addZeroTokens( valueTokens, 3 );
+ addZeroTokens( rangeValueTokens, 3 );
- if ( value.equals( rangeValue.getValue() ) )
- {
- if ( !rangeValue.isClosed() )
- {
- return isLeft ? -1 : 1;
- }
- return 0;
- }
-
- for ( int i = 0; i < valueTokens.size() && i <
rangeValueTokens.size(); i++ )
+ for ( int i = 0; i < 3; i++ )
{
int x = Integer.parseInt( valueTokens.get( i ) );
int y = Integer.parseInt( rangeValueTokens.get( i ) );
@@ -143,12 +133,9 @@
private static void addZeroTokens( List<String> tokens, int max )
{
- if ( tokens.size() < max )
+ while ( tokens.size() < max )
{
- for ( int i = 0; i < ( max - tokens.size() ); i++ )
- {
- tokens.add( "0" );
- }
+ tokens.add( "0" );
}
}
Modified:
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java?rev=896102&r1=896101&r2=896102&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java
(original)
+++
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java
Tue Jan 5 15:44:35 2010
@@ -116,9 +116,8 @@
assertActivation( true, profile, newContext( null, newProperties(
"1.6" ) ) );
assertActivation( true, profile, newContext( null, newProperties(
"1.6.0" ) ) );
- // TODO: controversial, needs discussion
- // assertActivation( true, profile, newContext( null, newProperties(
"1.6.0_09" ) ) );
- // assertActivation( true, profile, newContext( null, newProperties(
"1.6.0_09-b03" ) ) );
+ assertActivation( true, profile, newContext( null, newProperties(
"1.6.0_09" ) ) );
+ assertActivation( true, profile, newContext( null, newProperties(
"1.6.0_09-b03" ) ) );
}
public void testVersionRangeExclusiveBounds()
@@ -127,11 +126,13 @@
Profile profile = newProfile( "(1.3,1.6)" );
assertActivation( false, profile, newContext( null, newProperties(
"1.3" ) ) );
-
- // TODO: controversial, needs discussion
- // assertActivation( true, profile, newContext( null, newProperties(
"1.3.1" ) ) );
- // assertActivation( true, profile, newContext( null, newProperties(
"1.3.1_09" ) ) );
- // assertActivation( true, profile, newContext( null, newProperties(
"1.3.1_09-b03" ) ) );
+ assertActivation( false, profile, newContext( null, newProperties(
"1.3.0" ) ) );
+ assertActivation( false, profile, newContext( null, newProperties(
"1.3.0_09" ) ) );
+ assertActivation( false, profile, newContext( null, newProperties(
"1.3.0_09-b03" ) ) );
+
+ assertActivation( true, profile, newContext( null, newProperties(
"1.3.1" ) ) );
+ assertActivation( true, profile, newContext( null, newProperties(
"1.3.1_09" ) ) );
+ assertActivation( true, profile, newContext( null, newProperties(
"1.3.1_09-b03" ) ) );
assertActivation( true, profile, newContext( null, newProperties(
"1.5" ) ) );
assertActivation( true, profile, newContext( null, newProperties(
"1.5.0" ) ) );