Skip to content

Commit

Permalink
[Oztechan/CCC#3555] Replace executions with provider based methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan committed Jun 19, 2024
1 parent 484c3ec commit ff53961
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions buildSrc/src/main/kotlin/ProjectSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) 2020 Mustafa Ozhan. All rights reserved.
*/
import org.gradle.api.Project
import java.io.ByteArrayOutputStream

object ProjectSettings {
private const val MAYOR_VERSION = 2
Expand All @@ -15,12 +14,8 @@ object ProjectSettings {
project: Project
) = "$MAYOR_VERSION.$MINOR_VERSION.${gitCommitCount(project).toInt() - VERSION_DIF}"

private fun gitCommitCount(project: Project): String {
val os = ByteArrayOutputStream()
project.exec {
commandLine = "git rev-list --first-parent --count HEAD".split(" ")
standardOutput = os
}
return String(os.toByteArray()).trim()
}
@Suppress("UnstableApiUsage")
private fun gitCommitCount(project: Project): String = project.providers.exec {
commandLine("git rev-list --first-parent --count HEAD".split(" "))
}.standardOutput.asText.get().trim()
}

0 comments on commit ff53961

Please sign in to comment.