Author: stephenc
Date: Fri Jan 8 16:03:18 2010
New Revision: 897240
URL: http://svn.apache.org/viewvc?rev=897240&view=rev
Log:
[SUREFIRE-555]
o There was an issue with this patch when the junit dependency is inherited
from a parent project
in such cases we need to fall back to the base version. There is probably a
more correct way
to fix this.
Modified:
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Modified:
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=897240&r1=897239&r2=897240&view=diff
==============================================================================
---
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
(original)
+++
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
Fri Jan 8 16:03:18 2010
@@ -772,13 +772,25 @@
{
return false;
}
- try {
- VersionRange range = VersionRange.createFromVersionSpec(
versionSpec);
- return range.containsVersion( artifact.getSelectedVersion());
- } catch (InvalidVersionSpecificationException e) {
- throw new MojoExecutionException("Bug in junit 4.7 plugin. Please
report with stacktrace");
- } catch (OverConstrainedVersionException e) {
- throw new MojoExecutionException("Bug in junit 4.7 plugin. Please
report with stacktrace");
+ try
+ {
+ VersionRange range = VersionRange.createFromVersionSpec(
versionSpec );
+ try
+ {
+ return range.containsVersion( artifact.getSelectedVersion() );
+ }
+ catch ( NullPointerException e )
+ {
+ return range.containsVersion( new DefaultArtifactVersion(
artifact.getBaseVersion() ) );
+ }
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ throw new MojoExecutionException( "Bug in junit 4.7 plugin. Please
report with stacktrace" );
+ }
+ catch ( OverConstrainedVersionException e )
+ {
+ throw new MojoExecutionException( "Bug in junit 4.7 plugin. Please
report with stacktrace" );
}
}
@@ -835,12 +847,12 @@
// different one since its based on the source level, not the
JVM. Prune using the filter.
addProvider( surefireBooter, "surefire-testng",
surefireArtifact.getBaseVersion(), testNgArtifact );
}
- else if ( isJunit47Compatible( junitArtifact))
+ else if ( junitArtifact != null && isJunit47Compatible(
junitArtifact ) )
{
- convertJunitCoreParameters();
+ convertJunitCoreParameters();
addProvider( surefireBooter, "surefire-junit47",
surefireArtifact.getBaseVersion(), null );
}
- else if ( isJunit40to46( junitArtifact ))
+ else if ( junitArtifact != null && isJunit40to46( junitArtifact ) )
{
addProvider( surefireBooter, "surefire-junit4",
surefireArtifact.getBaseVersion(), null );
}
Modified:
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=897240&r1=897239&r2=897240&view=diff
==============================================================================
---
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
(original)
+++
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Fri Jan 8 16:03:18 2010
@@ -39,6 +39,7 @@
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
@@ -726,13 +727,25 @@
{
return false;
}
- try {
- VersionRange range = VersionRange.createFromVersionSpec(
versionSpec);
- return range.containsVersion( artifact.getSelectedVersion());
- } catch (InvalidVersionSpecificationException e) {
- throw new MojoExecutionException("Bug in junit 4.7 plugin. Please
report with stacktrace");
- } catch (OverConstrainedVersionException e) {
- throw new MojoExecutionException("Bug in junit 4.7 plugin. Please
report with stacktrace");
+ try
+ {
+ VersionRange range = VersionRange.createFromVersionSpec(
versionSpec );
+ try
+ {
+ return range.containsVersion( artifact.getSelectedVersion() );
+ }
+ catch ( NullPointerException e )
+ {
+ return range.containsVersion( new DefaultArtifactVersion(
artifact.getBaseVersion() ) );
+ }
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ throw new MojoExecutionException( "Bug in junit 4.7 plugin. Please
report with stacktrace" );
+ }
+ catch ( OverConstrainedVersionException e )
+ {
+ throw new MojoExecutionException( "Bug in junit 4.7 plugin. Please
report with stacktrace" );
}
}
@@ -789,12 +802,12 @@
// different one since its based on the source level, not the
JVM. Prune using the filter.
addProvider( surefireBooter, "surefire-testng",
surefireArtifact.getBaseVersion(), testNgArtifact );
}
- else if ( isJunit47Compatible( junitArtifact))
+ else if ( junitArtifact != null && isJunit47Compatible(
junitArtifact ) )
{
- convertJunitCoreParameters();
+ convertJunitCoreParameters();
addProvider( surefireBooter, "surefire-junit47",
surefireArtifact.getBaseVersion(), null );
}
- else if ( isJunit40to46( junitArtifact ))
+ else if ( junitArtifact != null && isJunit40to46( junitArtifact ) )
{
addProvider( surefireBooter, "surefire-junit4",
surefireArtifact.getBaseVersion(), null );
}