@@ -21,7 +21,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2121import org.apache.tools.ant.filters.ReplaceTokens
2222import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2323import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
24- import java.io.ByteArrayOutputStream
2524import kotlin.math.min
2625
2726plugins {
@@ -85,47 +84,9 @@ val clean: Task by tasks
8584val build: Task by tasks
8685val jar: Jar by tasks
8786
88- val getGitHashTask = tasks.register<Exec >(" getGitHash" ) {
89- val envHash = System .getenv(" GIT_HASH" )
90-
91- if (envHash != null ) {
92- val getter: () -> String = {
93- envHash.substring(0 , min(8 , envHash.length))
94- }
95-
96- ext.set(" gitVersionOut" , getter)
97-
98- commandLine(" echo" , " 'hi'" )
99- } else {
100- val stdout = ByteArrayOutputStream ()
101-
102- commandLine(" git" , " rev-parse" , " --short" , " HEAD" )
103- standardOutput = stdout
104- isIgnoreExitValue = true
105-
106- val getter: () -> String = {
107- val item = standardOutput.toString().trim()
108-
109- item.ifBlank {
110- " DEV"
111- }
112- }
113-
114- ext.set(" gitVersionOut" , getter)
115- }
116- }
117-
11887val printVersion = tasks.register<Task >(" printVersion" ) {
119- dependsOn(getGitHashTask)
120-
121- doLast {
122- @Suppress(" UNCHECKED_CAST" ) val versionGetter = project.ext.get(" gitVersionOut" ) as () -> String
123-
124- project.version = " ${numberVersion} _${versionGetter()} "
125-
126- println (" CI: ${System .getenv(" CI" )} " )
127- println (project.version)
128- }
88+ println (" CI: ${System .getenv(" CI" )} " )
89+ println (project.version)
12990}
13091
13192tasks.register<Exec >(" botVersion" ) {
@@ -236,20 +197,20 @@ pmd {
236197
237198tasks.register<Task >(" lintAll" ) {
238199// dependsOn(tasks.lintKotlin)
239- dependsOn(tasks.pmdMain)
200+ dependsOn(" lintKotlin " , tasks.pmdMain)
240201}
241202
242203githubRelease {
243204 token(System .getenv(" GITHUB_TOKEN" ))
244- owner(" DuncteBot" )
245- repo(" SkyBot" )
246- tagName(" v$numberVersion " )
247- targetCommitish(" main" )
205+ owner.set (" DuncteBot" )
206+ repo.set (" SkyBot" )
207+ tagName.set (" v$numberVersion " )
208+ targetCommitish.set (" main" )
248209 releaseAssets(shadowJar.outputs.files.toList())
249- overwrite(false )
250- prerelease(false )
251- dryRun(false )
252- body( changelog())
210+ overwrite.set (false )
211+ prerelease.set (false )
212+ dryRun.set (false )
213+ body.set(provider( changelog() ))
253214}
254215
255216fun getGitHash (): String {
0 commit comments