Skip to content

Commit

Permalink
Allow custom Gradle installation to be used (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobaxter committed Nov 29, 2023
1 parent 480dfa2 commit 0b6ce5e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = emptyList()
internal set

@Option(
names = ["--gradle-installation-path"],
description = ["Use a custom Gradle installation"]
)
var gradleInstallationPath: Path? = null
internal set
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ internal fun BaseConfigurationOptions.toCoreOptions(): CoreOptions {
maxGradleMemory = maxGradleMemory,
customJvmFlags = listOf("-XX:-MaxFDLimit"),
customGradleFlags = listOf("--stacktrace"),
autoInjectPlugin = autoInject
autoInjectPlugin = autoInject,
changedFiles = changedFiles,
gradleInstallationPath = gradleInstallationPath,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<GradleConnector>()
.forProjectDirectory(rootDir.toFile())
.useBuildDistribution()
.connect()
val projectConnector = with(affectedPathsApplication.koin.get<GradleConnector>()) {
forProjectDirectory(rootDir.toFile())
if (coreOptions.gradleInstallationPath != null) {
useInstallation(coreOptions.gradleInstallationPath.toFile())
} else {
useBuildDistribution()
}
return@with connect()
}

ensureActive()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 gradleInstallationPath: Path? = null,
) {

init {
Expand Down

0 comments on commit 0b6ce5e

Please sign in to comment.