Support -PfromMavenLocal without any value

Close gh-21
This commit is contained in:
Sébastien Deleuze
2023-09-07 16:31:44 +02:00
parent 1fcd9c2148
commit 4004370ded
2 changed files with 20 additions and 6 deletions

View File

@@ -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

View File

@@ -79,10 +79,15 @@ public class CrSmokeTestPlugin implements Plugin<Project> {
javaExtension.setTargetCompatibility(JavaVersion.VERSION_17);
if (project.hasProperty("fromMavenLocal")) {
String fromMavenLocal = project.property("fromMavenLocal").toString();
Stream<String> includedGroups = Stream.of(fromMavenLocal.split(","));
project.getRepositories()
.mavenLocal(
(mavenLocal) -> mavenLocal.content((content) -> includedGroups.forEach(content::includeGroup)));
if (fromMavenLocal.isEmpty()) {
project.getRepositories().mavenLocal();
}
else {
Stream<String> includedGroups = Stream.of(fromMavenLocal.split(","));
project.getRepositories()
.mavenLocal(
(mavenLocal) -> mavenLocal.content((content) -> includedGroups.forEach(content::includeGroup)));
}
}
project.getRepositories().mavenCentral();
project.getRepositories().maven((repo) -> {