From issues-return-140247-archive-asf-public=cust-asf.ponee.io@maven.apache.org Sun Nov 11 00:49:55 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id EBE04180668 for ; Sun, 11 Nov 2018 00:49:54 +0100 (CET) Received: (qmail 94662 invoked by uid 500); 10 Nov 2018 23:49:54 -0000 Mailing-List: contact issues-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list issues@maven.apache.org Received: (qmail 94651 invoked by uid 99); 10 Nov 2018 23:49:53 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Nov 2018 23:49:53 +0000 From: GitBox To: issues@maven.apache.org Subject: [GitHub] sormuras commented on a change in pull request #196: [SUREFIRE-1585] [WIP] Resolve missing and align "JUnit 5" artifacts Message-ID: <154189379336.6506.1047289872698292548.gitbox@gitbox.apache.org> Date: Sat, 10 Nov 2018 23:49:53 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit sormuras commented on a change in pull request #196: [SUREFIRE-1585] [WIP] Resolve missing and align "JUnit 5" artifacts URL: https://github.com/apache/maven-surefire/pull/196#discussion_r232469829 ########## File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java ########## @@ -2846,8 +2849,92 @@ public void addProviderProperties() @Nonnull public Set getProviderClasspath() { + String provider = "surefire-junit-platform"; String version = surefireBooterArtifact.getBaseVersion(); - return dependencyResolver.getProviderClasspath( "surefire-junit-platform", version ); + Set providerArtifacts = dependencyResolver.getProviderClasspath( provider, version ); + alignJUnitPlatformVersion( providerArtifacts ); + resolveJUnitJupiterEngine( providerArtifacts ); + resolveJUnitVintageEngine( providerArtifacts ); + return providerArtifacts; + } + + private void resolveJUnitJupiterEngine( Set providerArtifacts ) + { + Artifact junitJupiterApi = getProjectArtifactMap().get( "org.junit.jupiter:junit-jupiter-api" ); + if ( junitJupiterApi == null ) // no api, no engine + { + return; + } + Artifact junitJupiterEngine = getProjectArtifactMap().get( "org.junit.jupiter:junit-jupiter-engine" ); + if ( junitJupiterEngine != null ) // engine already resolved by project + { + return; + } + // resolve "junit-jupiter-engine" and its transitive dependencies + String version = junitJupiterApi.getBaseVersion(); + resolve( providerArtifacts, "org.junit.jupiter", "junit-jupiter-engine", version ); + } + + private void resolveJUnitVintageEngine( Set providerArtifacts ) + { + Artifact junit = getProjectArtifactMap().get( "junit:junit" ); + if ( junit == null || !junit.getBaseVersion().equals( "4.12" ) ) // no or wrong "junit", no engine + { + return; + } + Artifact junitVintageEngine = getProjectArtifactMap().get( "org.junit.vintage:junit-vintage-engine" ); + if ( junitVintageEngine != null ) // engine already resolved by project + { + return; + } + // resolve "junit-vintage-engine" and its transitive dependencies + // heuristic: from Platform "x.y.z" to Vintage "5" + ".y.z" + String junitVintageVersion = "5" + junitPlatformArtifact.getBaseVersion().substring( 1 ); + resolve( providerArtifacts, "org.junit.vintage", "junit-vintage-engine", junitVintageVersion ); + } + + private void alignJUnitPlatformVersion( Set providerArtifacts ) + { + Map providerArtifactMap = new HashMap(); + for ( Artifact artifact : providerArtifacts ) + { + String key = artifact.getGroupId() + ":" + artifact.getArtifactId(); + providerArtifactMap.put( key, artifact ); + } + Artifact defaultLauncher = providerArtifactMap.get( "org.junit.platform:junit-platform-launcher" ); + logDebugOrCliShowErrors( "JUnit Platform Artifact: " + junitPlatformArtifact ); + logDebugOrCliShowErrors( "JUnit Platform Launcher: " + defaultLauncher ); + if ( junitPlatformArtifact.getVersion().equals( defaultLauncher.getVersion() ) ) + { + logDebugOrCliShowErrors( "JUnit Platform versions are equal - proceeding anyway... " ); Review comment: Here should be a `return;` statement -- but then resulting classpath order is not matching in the integration tests. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services