diff --git a/CHANGELOG.md b/CHANGELOG.md index 07167c4..fb115dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - `affected-paths-core`, `tooling-support-*`: Add in support for composite builds being analyzed - `affected-paths-core`: Remove filter of root project - `affected-paths-core`: Fix improper project mapping for file changes in nested projects +- `affected-paths-core`: Allow a custom Gradle installation path to be passed in to the Gradle Tooling API ## v0.1.1 - `tooling-support`: Fix crash from `SquareProjectModelBuilder` when used on a non-Java/Android project diff --git a/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/options/BaseConfigurationOptions.kt b/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/options/BaseConfigurationOptions.kt index efbfb4d..a48ed79 100644 --- a/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/options/BaseConfigurationOptions.kt +++ b/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/options/BaseConfigurationOptions.kt @@ -112,4 +112,18 @@ internal class BaseConfigurationOptions { ) var autoInject: Boolean = false internal set + + @Option( + names = ["--changed-files"], + description = ["List of changed files to use instead of the Git diff"] + ) + var changedFiles: List = emptyList() + internal set + + @Option( + names = ["--gradle-installation-path"], + description = ["Use a custom Gradle installation"] + ) + var gradleInstallationPath: Path? = null + internal set } diff --git a/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/utils/CoreOptionsUtils.kt b/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/utils/CoreOptionsUtils.kt index b0eb080..1a725f2 100644 --- a/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/utils/CoreOptionsUtils.kt +++ b/affected-paths/app/src/main/kotlin/com/squareup/affected/paths/app/utils/CoreOptionsUtils.kt @@ -31,6 +31,8 @@ internal fun BaseConfigurationOptions.toCoreOptions(): CoreOptions { maxGradleMemory = maxGradleMemory, customJvmFlags = listOf("-XX:-MaxFDLimit"), customGradleFlags = listOf("--stacktrace"), - autoInjectPlugin = autoInject + autoInjectPlugin = autoInject, + changedFiles = changedFiles, + useCustomGradleInstallation = gradleInstallationPath, ) } diff --git a/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreAnalyzer.kt b/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreAnalyzer.kt index 84f32d4..ad4620c 100644 --- a/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreAnalyzer.kt +++ b/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreAnalyzer.kt @@ -77,10 +77,15 @@ public class CoreAnalyzer @JvmOverloads constructor(private val coreOptions: Cor val projectsDeferred = projects?.let { CompletableDeferred(it) } ?: async(Dispatchers.IO) { ensureActive() // In case this is cancelled before start - val projectConnector = affectedPathsApplication.koin.get() - .forProjectDirectory(rootDir.toFile()) - .useBuildDistribution() - .connect() + val projectConnector = with(affectedPathsApplication.koin.get()) { + forProjectDirectory(rootDir.toFile()) + if (coreOptions.useCustomGradleInstallation != null) { + useInstallation(coreOptions.useCustomGradleInstallation.toFile()) + } else { + useBuildDistribution() + } + return@with connect() + } ensureActive() diff --git a/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreOptions.kt b/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreOptions.kt index 19eb00b..5e049ee 100644 --- a/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreOptions.kt +++ b/affected-paths/core/src/main/kotlin/com/squareup/affected/paths/core/CoreOptions.kt @@ -69,6 +69,9 @@ public data class CoreOptions @JvmOverloads constructor( /** Include any "includeBuild" builds from the current build */ val useIncludeBuild: Boolean = true, + + /** Pass in a custom Gradle installation, instead of using the build distribution */ + val useCustomGradleInstallation: Path? = null, ) { init {