From 830da18971c82a3329c5b1bd49ad4b8dc958f395 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 15 Aug 2010 13:50:41 +0000 Subject: [PATCH] o Added detection of Maven version to ease execution of individual ITs via -Dtest= git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@985676 13f79535-47bb-0310-9956-ffa450edef68 --- .../it/AbstractMavenIntegrationTestCase.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java index 79c8898377..2e02786f0f 100644 --- a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java +++ b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java @@ -133,11 +133,33 @@ private ArtifactVersion getMavenVersion() { if ( mavenVersion == null ) { - String v = System.getProperty( "maven.version" ); - // NOTE: If the version looks like "${...}" it has been configured from an undefined expression - if ( v != null && v.length() > 0 && !v.startsWith( "${" ) ) + String version = System.getProperty( "maven.version", "" ); + + if ( version.length() <= 0 || version.startsWith( "${" ) ) { - mavenVersion = new DefaultArtifactVersion( v ); + try + { + Verifier verifier = new Verifier( "" ); + try + { + version = verifier.getMavenVersion(); + System.setProperty( "maven.version", version ); + } + finally + { + verifier.resetStreams(); + } + } + catch ( VerificationException e ) + { + e.printStackTrace(); + } + } + + // NOTE: If the version looks like "${...}" it has been configured from an undefined expression + if ( version != null && version.length() > 0 && !version.startsWith( "${" ) ) + { + mavenVersion = new DefaultArtifactVersion( version ); } } return mavenVersion;