MPLUGINTESTING-44 enforce maven 3.2.4 as minimal supported version Signed-off-by: Igor Fedorenko <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/commit/65c28851 Tree: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/tree/65c28851 Diff: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/diff/65c28851 Branch: refs/heads/master Commit: 65c28851c702a295cdb0cd4014ad65fd530b9d30 Parents: 81f2998 Author: Igor Fedorenko <[email protected]> Authored: Mon Nov 17 10:20:10 2014 -0500 Committer: Igor Fedorenko <[email protected]> Committed: Mon Nov 17 10:51:14 2014 -0500 ---------------------------------------------------------------------- .../plugin/testing/AbstractMojoTestCase.java | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/65c28851/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java ---------------------------------------------------------------------- diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java index 9b49e71..8b047a7 100644 --- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java +++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java @@ -34,9 +34,11 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Properties; import org.apache.commons.io.input.XmlStreamReader; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenExecutionRequest; @@ -71,6 +73,7 @@ import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.logging.LoggerManager; +import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.InterpolationFilterReader; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.ReflectionUtils; @@ -96,6 +99,37 @@ import com.google.inject.Module; public abstract class AbstractMojoTestCase extends PlexusTestCase { + private static final DefaultArtifactVersion MAVEN_VERSION; + + static + { + DefaultArtifactVersion version = null; + String path = "/META-INF/maven/org.apache.maven/maven-core/pom.properties"; + InputStream is = AbstractMojoTestCase.class.getResourceAsStream( path ); + try + { + Properties properties = new Properties(); + if ( is != null ) + { + properties.load( is ); + } + String property = properties.getProperty( "version" ); + if ( property != null ) + { + version = new DefaultArtifactVersion( property ); + } + } + catch ( IOException e ) + { + // odd, where did this come from + } + finally + { + IOUtil.close( is ); + } + MAVEN_VERSION = version; + } + private ComponentConfigurator configurator; private PlexusContainer container; @@ -112,6 +146,9 @@ public abstract class AbstractMojoTestCase protected void setUp() throws Exception { + assertTrue( "Maven 3.2.4 or better is required", + MAVEN_VERSION == null || new DefaultArtifactVersion( "3.2.3" ).compareTo( MAVEN_VERSION ) < 0 ); + configurator = getContainer().lookup( ComponentConfigurator.class, "basic" ); InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );
