Skip to content

Commit

Permalink
Fix for older versions of Gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Feb 13, 2024
1 parent 338d7c5 commit a005617
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ abstract class AbstractDependencyExtractorPlugin : Plugin<Gradle> {
extractorServiceProvider: Provider<out DependencyExtractor>
) {
gradle.buildFinished {
extractorServiceProvider.get().close()
gradle.buildOperationListenerManager
.removeListener(extractorServiceProvider.get())
val extractorService = extractorServiceProvider.get()
extractorService.handleBuildCompletion(it.failure)
extractorService.close()
gradle.buildOperationListenerManager.removeListener(extractorService)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ abstract class DependencyExtractor :
private val pluginParameters = PluginParameters()

private var settingsEvaluated = false
private var buildWorkCompleted = false
private var buildWorkFailure = false
private var buildCompleted = false
private var buildFailed = false

private val resolvedConfigurations = Collections.synchronizedList(mutableListOf<ResolvedConfiguration>())

Expand Down Expand Up @@ -88,7 +88,7 @@ abstract class DependencyExtractor :
EvaluateSettingsBuildOperationType.Result>(buildOperation, finishEvent) { details, _ -> extractSettings(details) }

if (buildOperation.metadata == BuildOperationCategory.RUN_WORK) {
handleRunWorkCompleted(finishEvent)
handleBuildCompletion(finishEvent.failure)
}
}

Expand Down Expand Up @@ -349,10 +349,10 @@ abstract class DependencyExtractor :
)
}

private fun handleRunWorkCompleted(finishEvent: OperationFinishEvent) {
buildWorkCompleted = true
if (finishEvent.failure != null) {
buildWorkFailure = true
fun handleBuildCompletion(failure: Throwable?) {
buildCompleted = true
if (failure != null) {
buildFailed = true
}
}

Expand All @@ -373,8 +373,8 @@ abstract class DependencyExtractor :
)
return
}
// We use the absence of Settings Evaluated to determine if the build was loaded from the configuration-cache
if (!buildWorkCompleted || buildWorkFailure) {
// Do not write an incomplete graph when build didn't complete successfully
if (!buildCompleted || buildFailed) {
LOGGER.lifecycle(
"Gradle Build did not complete successfully: Dependency Graph file will not be generated."
)
Expand Down

0 comments on commit a005617

Please sign in to comment.