From b36e4a0b42d9fb1dfaeb54b8b00045a36978e1e6 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 13 Jul 2023 14:10:36 +0100 Subject: [PATCH] Test refined exclusion handling with dependency that uses GMM This is a follow-on to cf49bef and adds a test that verifies the behavior when a dependency has Gradle module metadata and in this metadata that is a dependency upon a platform. See gh-360 --- ...dencyManagementPluginIntegrationTests.java | 8 +++++++ ...ConstraintsFromPlatformDependencies.gradle | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/test/resources/io/spring/gradle/dependencymanagement/DMPIT/resolutionSucceedsWhenDependencyReliesOnConstraintsFromPlatformDependencies.gradle diff --git a/src/test/java/io/spring/gradle/dependencymanagement/DependencyManagementPluginIntegrationTests.java b/src/test/java/io/spring/gradle/dependencymanagement/DependencyManagementPluginIntegrationTests.java index 40526cd..a757deb 100644 --- a/src/test/java/io/spring/gradle/dependencymanagement/DependencyManagementPluginIntegrationTests.java +++ b/src/test/java/io/spring/gradle/dependencymanagement/DependencyManagementPluginIntegrationTests.java @@ -495,6 +495,14 @@ void resolutionSucceedsWhenDependencyReliesOnDependencyManagementFromItsAncestor "spring-core-5.3.27.jar", "spring-jcl-5.3.27.jar"); } + @Test + void resolutionSucceedsWhenDependencyReliesOnConstraintsFromPlatformDependencies() { + this.gradleBuild.runner().withArguments("resolve").build(); + assertThat(readLines("resolved.txt")).containsExactly("guava-32.1.1-jre.jar", "failureaccess-1.0.1.jar", + "jsr305-3.0.2.jar", "checker-qual-3.33.0.jar", "error_prone_annotations-2.18.0.jar", + "j2objc-annotations-2.8.jar"); + } + private void writeLines(Path path, String... lines) { try { Path resolvedPath = this.gradleBuild.runner().getProjectDir().toPath().resolve(path); diff --git a/src/test/resources/io/spring/gradle/dependencymanagement/DMPIT/resolutionSucceedsWhenDependencyReliesOnConstraintsFromPlatformDependencies.gradle b/src/test/resources/io/spring/gradle/dependencymanagement/DMPIT/resolutionSucceedsWhenDependencyReliesOnConstraintsFromPlatformDependencies.gradle new file mode 100644 index 0000000..440608f --- /dev/null +++ b/src/test/resources/io/spring/gradle/dependencymanagement/DMPIT/resolutionSucceedsWhenDependencyReliesOnConstraintsFromPlatformDependencies.gradle @@ -0,0 +1,21 @@ +plugins { + id "java" + id "io.spring.dependency-management" +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("com.google.guava:guava:32.1.1-jre"); +} + +tasks.register("resolve") { + doFirst { + def files = project.configurations.compileClasspath.resolve() + def output = new File("${buildDir}/resolved.txt") + output.parentFile.mkdirs() + files.collect { it.name }.each { output << "${it}\n" } + } +}