Skip to content

Commit 620ecf5

Browse files
committed
Try buildconfig plugin
1 parent c4c4927 commit 620ecf5

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

build.gradle.kts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77
id("kotlinx-serialization") version "1.3.31"
88
id("maven-publish")
99
id("com.jfrog.bintray") version "1.8.4"
10+
id("com.github.kukuhyoniatmoko.buildconfigkotlin") version "1.0.5"
1011
}
1112

1213
version = Library.version
@@ -19,6 +20,12 @@ repositories {
1920
maven { url = URI("https://kotlin.bintray.com/kotlinx") }
2021
}
2122

23+
buildConfigKotlin {
24+
sourceSet("metadata") {
25+
buildConfig(name = "version", value = Library.version)
26+
}
27+
}
28+
2229
kotlin {
2330
jvm {
2431
compilations.all {
@@ -142,24 +149,7 @@ bintray {
142149
}
143150
}
144151

145-
val generate by tasks.registering {
146-
val directory = File("build/generated").apply {
147-
if (!exists()) mkdir()
148-
}
149-
val file = File("${directory.path}/Library.kt").apply {
150-
if (!exists()) createNewFile()
151-
}
152-
153-
file.bufferedWriter().use {
154-
it.write("package com.algolia.search.build\n\n")
155-
it.write("object Library {\n\n")
156-
it.write("\tval version: String = \"${Library.version}\"\n")
157-
it.write("}")
158-
}
159-
}
160-
161152
tasks {
162-
this["assemble"].dependsOn(generate)
163153
val bintrayUpload by getting(BintrayUploadTask::class) {
164154
dependsOn(publishToMavenLocal)
165155
doFirst {

src/commonMain/kotlin/com/algolia/search/configuration/HttpClient.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.algolia.search.configuration
22

3-
import com.algolia.search.build.Library
3+
import BuildConfig
44
import com.algolia.search.model.response.ResponseABTest
55
import com.algolia.search.model.response.ResponseBatches
66
import com.algolia.search.model.response.creation.CreationAPIKey
@@ -42,7 +42,7 @@ internal fun HttpClientConfig<*>.configure(configuration: Configuration) {
4242
logger = Logger.SIMPLE
4343
}
4444
install(UserAgent) {
45-
this.agent = "Algolia for Kotlin (${Library.version})"
45+
this.agent = "Algolia for Kotlin (${BuildConfig.version})"
4646
}
4747
configuration.defaultHeaders?.let {
4848
install(DefaultRequest) {

0 commit comments

Comments
 (0)