Skip to content

Commit acfa8bf

Browse files
committed
Fix Json eager initialization
1 parent eac04a2 commit acfa8bf

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

  • src/main/kotlin/xyz/srnyx/gradlegalaxy/utility

src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Scripts.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ import kotlin.apply
3535
import kotlin.text.replace
3636

3737

38+
private val json by lazy { Json {
39+
prettyPrint = true
40+
prettyPrintIndent = " "
41+
ignoreUnknownKeys = true
42+
} }
43+
3844
/**
3945
* @return Whether the project is running in a GitHub Actions workflow
4046
*/
@@ -59,7 +65,7 @@ val inGitHubPreRelease: Boolean by lazy {
5965
/**
6066
* @return Whether the project is running in a GitHub Actions release workflow
6167
*/
62-
val inGitHubRelease: Boolean = !inGitHubPreRelease
68+
val inGitHubRelease: Boolean by lazy { !inGitHubPreRelease }
6369

6470
/**
6571
* Makes the given package path safe to use
@@ -279,12 +285,6 @@ fun Project.relocate(
279285
tasks.named<ShadowJar>("shadowJar") { relocate(from, to, action) }
280286
}
281287

282-
private val json = Json {
283-
prettyPrint = true
284-
prettyPrintIndent = " "
285-
ignoreUnknownKeys = true
286-
}
287-
288288
fun Project.addPlatformsResourceFileTask(platforms: Map<PluginPlatform, String>): TaskProvider<Task> {
289289
val platformsFile = project.layout.buildDirectory.file("resources/main/platforms.json").get().asFile
290290
val platformsProvider = project.provider { json.encodeToString(mapOf("platforms" to platforms)) }

0 commit comments

Comments
 (0)