Skip to content

Commit

Permalink
Merge pull request #29 from square/pb/allow-build-scan
Browse files Browse the repository at this point in the history
Allow build scans to run on affected-paths runs with Gradle.
  • Loading branch information
pablobaxter authored Jul 18, 2024
2 parents 253c22f + c8b7609 commit 4bf9614
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Unreleased
- `affected-paths-core`: Add in flag for enabling build scans on affected-paths runs

## v0.1.3
- `affected-paths-core`: Fix custom Gradle flags not being properly set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,11 @@ internal class BaseConfigurationOptions {
)
var gradleInstallationPath: Path? = null
internal set

@Option(
names = ["--build-scan"],
description = ["Capture the Gradle build scan"]
)
var gradleBuildScan: Boolean = false
internal set
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ internal fun BaseConfigurationOptions.toCoreOptions(): CoreOptions {
autoInjectPlugin = autoInject,
changedFiles = changedFiles,
gradleInstallationPath = gradleInstallationPath,
useBuildScan = gradleBuildScan
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public class CoreAnalyzer @JvmOverloads constructor(private val coreOptions: Cor
)
)
actionExecutor.withCancellationToken(cancellationTokenSource.token())
if (coreOptions.useBuildScan) {
actionExecutor.forTasks(emptyList())
}
actionExecutor.addArguments(coreOptions.gradleArgs)
actionExecutor.addJvmArguments(coreOptions.jvmArgs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ public data class CoreOptions @JvmOverloads constructor(

/** Pass in a custom Gradle installation, instead of using the build distribution */
val gradleInstallationPath: Path? = null,

/**
* Add the build scan flag to the tooling.
*
* **Note**: This will cause the default tasks of a build to run.
*/

val useBuildScan: Boolean = false,
) {

init {
Expand Down Expand Up @@ -123,5 +131,8 @@ public data class CoreOptions @JvmOverloads constructor(
}.absolutePath
)
}
if (useBuildScan) {
add("--scan")
}
}
}

0 comments on commit 4bf9614

Please sign in to comment.