From 4004370ded85f4e875346298ccae12951a1b27a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 7 Sep 2023 16:31:44 +0200 Subject: [PATCH] Support -PfromMavenLocal without any value Close gh-21 --- README.adoc | 13 +++++++++++-- .../cr/gradle/CrSmokeTestPlugin.java | 13 +++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.adoc b/README.adoc index c153440..04f294c 100644 --- a/README.adoc +++ b/README.adoc @@ -85,14 +85,23 @@ _Hint: You can use `--include-build` multiple times._ ==== Your project uses Maven or --include-build does not work First, install the snapshots into your local Maven cache. -You can now consume those snapshots using `-PfromMavenLocal` which takes a comma-separated list of group IDs: +You can now consume those snapshots using `-PfromMavenLocal` which takes an +optional comma-separated list of group IDs: [source,] ---- ./gradlew :framework:webmvc-tomcat:build -PfromMavenLocal=org.springframework ---- -The preceding example will run the `rest-template` smoke test, resolving Spring Framework from your local Maven cache. +The preceding example will run the `webmvc-tomcat` smoke test, resolving Spring Framework from your local Maven cache. + +You can also just specify: +[source,] +---- +./gradlew :framework:webmvc-tomcat:build -PfromMavenLocal +---- + +Here all the dependencies will be resolved from your local Maven cache. === Override a dependency version diff --git a/gradle/plugins/cr-smoke-test-plugin/src/main/java/org/springframework/cr/gradle/CrSmokeTestPlugin.java b/gradle/plugins/cr-smoke-test-plugin/src/main/java/org/springframework/cr/gradle/CrSmokeTestPlugin.java index 695f171..a1e29b7 100644 --- a/gradle/plugins/cr-smoke-test-plugin/src/main/java/org/springframework/cr/gradle/CrSmokeTestPlugin.java +++ b/gradle/plugins/cr-smoke-test-plugin/src/main/java/org/springframework/cr/gradle/CrSmokeTestPlugin.java @@ -79,10 +79,15 @@ public class CrSmokeTestPlugin implements Plugin { javaExtension.setTargetCompatibility(JavaVersion.VERSION_17); if (project.hasProperty("fromMavenLocal")) { String fromMavenLocal = project.property("fromMavenLocal").toString(); - Stream includedGroups = Stream.of(fromMavenLocal.split(",")); - project.getRepositories() - .mavenLocal( - (mavenLocal) -> mavenLocal.content((content) -> includedGroups.forEach(content::includeGroup))); + if (fromMavenLocal.isEmpty()) { + project.getRepositories().mavenLocal(); + } + else { + Stream includedGroups = Stream.of(fromMavenLocal.split(",")); + project.getRepositories() + .mavenLocal( + (mavenLocal) -> mavenLocal.content((content) -> includedGroups.forEach(content::includeGroup))); + } } project.getRepositories().mavenCentral(); project.getRepositories().maven((repo) -> {