Skip to content

Commit 65c2885

Browse files
committed
MPLUGINTESTING-44 enforce maven 3.2.4 as minimal supported version
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
1 parent 81f2998 commit 65c2885

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
import java.util.HashMap;
3535
import java.util.List;
3636
import java.util.Map;
37+
import java.util.Properties;
3738

3839
import org.apache.commons.io.input.XmlStreamReader;
3940
import org.apache.maven.artifact.Artifact;
41+
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
4042
import org.apache.maven.execution.DefaultMavenExecutionRequest;
4143
import org.apache.maven.execution.DefaultMavenExecutionResult;
4244
import org.apache.maven.execution.MavenExecutionRequest;
@@ -71,6 +73,7 @@
7173
import org.codehaus.plexus.configuration.PlexusConfiguration;
7274
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
7375
import org.codehaus.plexus.logging.LoggerManager;
76+
import org.codehaus.plexus.util.IOUtil;
7477
import org.codehaus.plexus.util.InterpolationFilterReader;
7578
import org.codehaus.plexus.util.ReaderFactory;
7679
import org.codehaus.plexus.util.ReflectionUtils;
@@ -96,6 +99,37 @@
9699
public abstract class AbstractMojoTestCase
97100
extends PlexusTestCase
98101
{
102+
private static final DefaultArtifactVersion MAVEN_VERSION;
103+
104+
static
105+
{
106+
DefaultArtifactVersion version = null;
107+
String path = "/META-INF/maven/org.apache.maven/maven-core/pom.properties";
108+
InputStream is = AbstractMojoTestCase.class.getResourceAsStream( path );
109+
try
110+
{
111+
Properties properties = new Properties();
112+
if ( is != null )
113+
{
114+
properties.load( is );
115+
}
116+
String property = properties.getProperty( "version" );
117+
if ( property != null )
118+
{
119+
version = new DefaultArtifactVersion( property );
120+
}
121+
}
122+
catch ( IOException e )
123+
{
124+
// odd, where did this come from
125+
}
126+
finally
127+
{
128+
IOUtil.close( is );
129+
}
130+
MAVEN_VERSION = version;
131+
}
132+
99133
private ComponentConfigurator configurator;
100134

101135
private PlexusContainer container;
@@ -112,6 +146,9 @@ public abstract class AbstractMojoTestCase
112146
protected void setUp()
113147
throws Exception
114148
{
149+
assertTrue( "Maven 3.2.4 or better is required",
150+
MAVEN_VERSION == null || new DefaultArtifactVersion( "3.2.3" ).compareTo( MAVEN_VERSION ) < 0 );
151+
115152
configurator = getContainer().lookup( ComponentConfigurator.class, "basic" );
116153

117154
InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );

0 commit comments

Comments
 (0)