diff --git a/build.gradle b/build.gradle index 386d3b0276..d23e6eb949 100644 --- a/build.gradle +++ b/build.gradle @@ -189,6 +189,7 @@ tasks.register('checkSamples') { includeCheckRemote { repository = 'spring-projects/spring-security-samples' ref = samplesBranch + buildScan = true if (project.hasProperty("samplesInitScript")) { initScripts = [samplesInitScript] projectProperties = ["localRepositoryPath": localRepositoryPath, "springSecurityVersion": project.version] diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/IncludeCheckRemotePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/IncludeCheckRemotePlugin.groovy index 929338cc6f..d145955b5e 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/IncludeCheckRemotePlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/IncludeCheckRemotePlugin.groovy @@ -39,6 +39,7 @@ class IncludeCheckRemotePlugin implements Plugin { it.dependsOn 'includeRepo' it.dir = includeRepoTask.get().outputDirectory it.tasks = extension.getTasks() + it.startParameter.buildScan = extension.getBuildScan() extension.getInitScripts().forEach {script -> it.startParameter.addInitScript(new File(script)) } @@ -75,6 +76,11 @@ class IncludeCheckRemotePlugin implements Plugin { */ Map projectProperties = [:] + /** + * Whether the Build Scan should be published + */ + boolean buildScan = false + } } diff --git a/buildSrc/src/test/java/io/spring/gradle/convention/IncludeCheckRemotePluginTest.java b/buildSrc/src/test/java/io/spring/gradle/convention/IncludeCheckRemotePluginTest.java index dff022f369..9b0ae298b1 100644 --- a/buildSrc/src/test/java/io/spring/gradle/convention/IncludeCheckRemotePluginTest.java +++ b/buildSrc/src/test/java/io/spring/gradle/convention/IncludeCheckRemotePluginTest.java @@ -145,4 +145,35 @@ class IncludeCheckRemotePluginTest { assertThat(checkRemote).isNotNull(); } + @Test + void applyWhenNoBuildScanSpecifiedThenRegisterCheckRemoteTaskWithBuildScanFalse() { + this.rootProject = ProjectBuilder.builder().build(); + this.rootProject.getPluginManager().apply(IncludeCheckRemotePlugin.class); + this.rootProject.getExtensions().configure(IncludeCheckRemotePlugin.IncludeCheckRemoteExtension.class, + (includeCheckRemoteExtension) -> { + includeCheckRemoteExtension.setProperty("repository", "my-project/my-repository"); + includeCheckRemoteExtension.setProperty("ref", "main"); + }); + + GradleBuild checkRemote = (GradleBuild) this.rootProject.getTasks().named("checkRemote").get(); + assertThat(checkRemote).isNotNull(); + assertThat(checkRemote.getStartParameter().isBuildScan()).isFalse(); + } + + @Test + void applyWhenBuildScanTrueThenRegisterCheckRemoteTaskWithBuildScanTrue() { + this.rootProject = ProjectBuilder.builder().build(); + this.rootProject.getPluginManager().apply(IncludeCheckRemotePlugin.class); + this.rootProject.getExtensions().configure(IncludeCheckRemotePlugin.IncludeCheckRemoteExtension.class, + (includeCheckRemoteExtension) -> { + includeCheckRemoteExtension.setProperty("repository", "my-project/my-repository"); + includeCheckRemoteExtension.setProperty("ref", "main"); + includeCheckRemoteExtension.setProperty("buildScan", true); + }); + + GradleBuild checkRemote = (GradleBuild) this.rootProject.getTasks().named("checkRemote").get(); + assertThat(checkRemote).isNotNull(); + assertThat(checkRemote.getStartParameter().isBuildScan()).isTrue(); + } + }