Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom Gradle installation to be used #18

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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