diff --git a/src/it/projects/get-classpath/verify.groovy b/src/it/projects/get-classpath/verify.groovy index 822846a06..02b02986a 100644 --- a/src/it/projects/get-classpath/verify.groovy +++ b/src/it/projects/get-classpath/verify.groovy @@ -41,9 +41,18 @@ String mavenVersion = new File( basedir, "build.log" ).readLines().find { it.sta assert mavenVersion != null : "No Maven version in build.log"; String leafVersion = mavenVersion.startsWith( "Apache Maven 4" ) ? "2.0" : "1.0"; +// Maven 3.9 and earlier (Resolver 1.x) place a transitive dependency reached through another dependency +// before that dependency's own siblings; Maven 3.10+ and 4 (Resolver 2.x) place it after. The IT's project +// reaches the leaf only through the dep, so its position relative to runtime depends on the resolver line. +def version = ( mavenVersion =~ /Apache Maven (\d+)\.(\d+)/ ); +assert version.find() : "Could not parse a Maven version from: " + mavenVersion; +boolean leafBeforeRuntime = ( version.group( 1 ) as int ) == 3 && ( version.group( 2 ) as int ) < 10; + String leaf = new File( localRepositoryPath, "org/apache/maven/its/dependency/get-classpath-lib-leaf/" + leafVersion + "/get-classpath-lib-leaf-" + leafVersion + ".jar" ).getPath(); -String expected = [ jar( "get-classpath-lib" ), jar( "get-classpath-lib-dep" ), jar( "get-classpath-lib-runtime" ), leaf ] +String runtime = jar( "get-classpath-lib-runtime" ); +String expected = [ jar( "get-classpath-lib" ), jar( "get-classpath-lib-dep" ) ] + .plus( leafBeforeRuntime ? [ leaf, runtime ] : [ runtime, leaf ] ) .join( File.pathSeparator ); String actual = read( "classpath.txt" ); assert actual.equals( expected ) : "Unexpected classpath: " + actual + ", expected: " + expected + " for " + mavenVersion;