You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by so...@apache.org on 2018/10/24 09:38:36 UTC

[maven-surefire] branch SUREFIRE-1585 updated (0b7a1c1 -> 3aa28b6)

This is an automated email from the ASF dual-hosted git repository.

sor pushed a change to branch SUREFIRE-1585
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


 discard 0b7a1c1  Resolve missing 'org.junit.jupiter:junit-jupiter-engine' artifact
     new 3aa28b6  Resolve missing 'org.junit.jupiter:junit-jupiter-engine' artifact

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (0b7a1c1)
            \
             N -- N -- N   refs/heads/SUREFIRE-1585 (3aa28b6)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 maven-surefire-common/pom.xml | 6 ------
 1 file changed, 6 deletions(-)


[maven-surefire] 01/01: Resolve missing 'org.junit.jupiter:junit-jupiter-engine' artifact

Posted by so...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sor pushed a commit to branch SUREFIRE-1585
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 3aa28b617ef14af46350f14fea260fbc3450ae2b
Author: Christian Stein <so...@gmail.com>
AuthorDate: Wed Oct 24 11:35:23 2018 +0200

    Resolve missing 'org.junit.jupiter:junit-jupiter-engine' artifact
---
 .../plugin/surefire/AbstractSurefireMojo.java      |  4 +-
 .../maven/plugin/surefire/TestClassPath.java       | 60 ++++++++++++++++------
 2 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index c976a23..0cf5f62 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -2487,7 +2487,7 @@ public abstract class AbstractSurefireMojo
         }
 
         return new TestClassPath( classpathArtifacts, getClassesDirectory(),
-                getTestClassesDirectory(), getAdditionalClasspathElements(), logger );
+                getTestClassesDirectory(), getAdditionalClasspathElements(), this );
     }
 
     /**
@@ -2523,7 +2523,7 @@ public abstract class AbstractSurefireMojo
     }
 
 
-    private ArtifactResolutionResult resolveArtifact( Artifact filteredArtifact, Artifact providerArtifact )
+    ArtifactResolutionResult resolveArtifact( Artifact filteredArtifact, Artifact providerArtifact )
     {
         ArtifactFilter filter = null;
         if ( filteredArtifact != null )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
index b9b39b5..928cc91 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
@@ -20,13 +20,14 @@ package org.apache.maven.plugin.surefire;
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.surefire.booter.Classpath;
-import org.codehaus.plexus.logging.Logger;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import static java.util.Collections.addAll;
@@ -35,22 +36,26 @@ import static org.apache.maven.shared.utils.StringUtils.split;
 final class TestClassPath
 {
     private final Iterable<Artifact> artifacts;
+
     private final File classesDirectory;
+
     private final File testClassesDirectory;
+
     private final String[] additionalClasspathElements;
-    private final Logger logger;
+
+    private final AbstractSurefireMojo mojo;
 
     TestClassPath( Iterable<Artifact> artifacts,
                    File classesDirectory,
                    File testClassesDirectory,
                    String[] additionalClasspathElements,
-                   Logger logger )
+                   AbstractSurefireMojo mojo )
     {
         this.artifacts = artifacts;
         this.classesDirectory = classesDirectory;
         this.testClassesDirectory = testClassesDirectory;
         this.additionalClasspathElements = additionalClasspathElements;
-        this.logger = logger;
+        this.mojo = mojo;
     }
 
     void avoidArtifactDuplicates( Set<Artifact> providerArtifacts )
@@ -69,9 +74,9 @@ final class TestClassPath
                         && ( classifier1 == null ? classifier2 == null : classifier1.equals( classifier2 ) ) )
                 {
                     it.remove();
-                    if ( logger.isDebugEnabled() )
+                    if ( mojo != null && mojo.getLog().isDebugEnabled() )
                     {
-                        logger.debug( "Removed artifact " + providerArtifact + " from provider. "
+                        mojo.getLog().debug( "Removed artifact " + providerArtifact + " from provider. "
                                 + "Already appears in test classpath." );
                     }
                 }
@@ -87,15 +92,40 @@ final class TestClassPath
         // TODO Check for actual SurefireProvider -- the following only applies for when
         //      'org.apache.maven.surefire.junitplatform.JUnitPlatformProvider' is active.
 
-        // TODO Add missing 'junit-jupiter-engine' to test runtime
-        // Artifact junitJupiterApi = findArtifact( "org.junit.jupiter:junit-jupiter-api", artifacts );
-        // Artifact junitJupiterEngine =
-        //   findArtifact( "org.junit.jupiter:junit-jupiter-engine", artifacts, providerArtifacts );
-        // if ( junitJupiterApi != null && junitJupiterEngine == null )
-        // {
-        //     [artifacts | providerArtifacts]
-        //     .add( "org.junit.jupiter:junit-jupiter-engine:" + junitJupiterApi.getVersion() );
-        // }
+        if ( mojo == null )
+        {
+            // mojo.getLog().warn( "Can't resolve missing artifacts when mojo is not set." );
+            return;
+        }
+
+        // Add missing 'junit-jupiter-engine' to test runtime
+        Map<String, Artifact> artifactMap = mojo.getProjectArtifactMap();
+        Artifact junitJupiterApi = artifactMap.get( "org.junit.jupiter:junit-jupiter-api" );
+        Artifact junitJupiterEngine = artifactMap.get( "org.junit.jupiter:junit-jupiter-engine" );
+        if ( junitJupiterApi != null && junitJupiterEngine == null )
+        {
+            junitJupiterEngine = new DefaultArtifact(
+                            "org.junit.jupiter",
+                            "junit-jupiter-engine",
+                            junitJupiterApi.getVersionRange(),
+                            "test",
+                            "jar",
+                            "",
+                            junitJupiterApi.getArtifactHandler()
+            );
+            @SuppressWarnings( "unchecked" )
+            Set<Artifact> resolvedArtifacts = mojo.resolveArtifact( null, junitJupiterEngine ).getArtifacts();
+            providerArtifacts.addAll( resolvedArtifacts );
+
+            if ( mojo.getLog().isDebugEnabled() )
+            {
+                mojo.getLog().debug( "Resolved missing artifact: " + junitJupiterEngine );
+                for ( Artifact resolvedArtifact : resolvedArtifacts )
+                {
+                    mojo.getLog().debug( "  -> " + resolvedArtifact );
+                }
+            }
+        }
 
         // TODO Add missing 'junit-vintage-engine' to test runtime
         // Artifact junit4 = findArtifact( "junit:junit", artifacts );