Skip to content

Commit

Permalink
Fix project services has been closed crash with Gradle 8.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierSegoviaCordoba committed Sep 9, 2024
1 parent 3269cc8 commit 3abe9a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Fixed

- `project services has been closed` crash with Gradle 8.10.1

### Removed

### Updated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.javiersc.hubdle.project

import com.javiersc.hubdle.project.extensions.HubdleExtension
import com.javiersc.hubdle.project.extensions._internal.HubdleState
import com.javiersc.hubdle.project.extensions._internal.hubdleState
import com.javiersc.hubdle.project.extensions.config._internal.createHubdleConfigExtensions
import com.javiersc.hubdle.project.extensions.java._internal.createHubdleJavaExtensions
Expand All @@ -11,10 +12,12 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.BasePlugin
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.create

public abstract class HubdleProjectPlugin : Plugin<Project> {

override fun apply(target: Project) {
target.extensions.create<HubdleState>("_InternalHubdleState", target)
target.pluginManager.apply(BasePlugin::class)
target.registerHubdleLifecycleTasks()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@ import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.create

internal val hubdleStateCache: MutableMap<Project, HubdleState> = mutableMapOf()
import org.gradle.kotlin.dsl.findByType

internal val Project.hubdleState: HubdleState
get() {
if (hubdleStateCache[this] == null) hubdleStateCache[this] = HubdleState(this)
return checkNotNull(hubdleStateCache[this]) {
"HubdleState for `$displayName` doesn't exist"
}
}
get() = extensions.findByType<HubdleState>()!!

internal class HubdleState(private val project: Project) {
internal open class HubdleState(private val project: Project) {

val name: String = project.displayName

Expand Down

0 comments on commit 3abe9a7

Please sign in to comment.