@@ -127,27 +127,41 @@ val moveJDBCJNIFiles by tasks.registering(Copy::class) {
127
127
into(jniLibsFolder) // Move everything into the base jniLibs folder
128
128
}
129
129
130
- kotlin {
131
- powersyncTargets()
130
+ val generateVersionConstant by tasks.registering {
131
+ val target = project.layout.buildDirectory.dir(" generated/constants" )
132
+ val packageName = " com.powersync.build"
132
133
133
- targets.configureEach {
134
- compilations.configureEach {
135
- compileTaskProvider.configure {
136
- dependsOn(generateVersionConstant)
137
- }
138
- }
134
+ outputs.dir(target)
135
+ val currentVersion = version.toString()
139
136
140
- if (this is KotlinNativeTarget ) {
141
- compilations.named(" main" ) {
142
- compileTaskProvider.configure {
143
- compilerOptions.freeCompilerArgs.add(" -Xexport-kdoc" )
144
- }
145
- }
146
- }
137
+ doLast {
138
+ val dir = target.get().asFile
139
+ dir.mkdir()
140
+ val rootPath = dir.toPath()
141
+
142
+ val source = """
143
+ package $packageName
144
+
145
+ internal const val LIBRARY_VERSION: String = "$currentVersion "
146
+
147
+ """ .trimIndent()
148
+
149
+ val packageRoot = packageName.split(' .' ).fold(rootPath, Path ::resolve)
150
+ packageRoot.createDirectories()
151
+
152
+ packageRoot.resolve(" BuildConstants.kt" ).writeText(source)
147
153
}
154
+ }
148
155
149
- targets.withType<KotlinNativeTarget > {
156
+ kotlin {
157
+ powersyncTargets()
150
158
159
+ targets.withType<KotlinNativeTarget > {
160
+ compilations.named(" main" ) {
161
+ compileTaskProvider {
162
+ compilerOptions.freeCompilerArgs.add(" -Xexport-kdoc" )
163
+ }
164
+ }
151
165
}
152
166
153
167
explicitApi()
@@ -173,7 +187,7 @@ kotlin {
173
187
174
188
commonMain.configure {
175
189
kotlin {
176
- srcDir(layout.buildDirectory.dir( " generated/constants " ) )
190
+ srcDir(generateVersionConstant )
177
191
}
178
192
179
193
dependencies {
@@ -311,29 +325,3 @@ setupGithubRepository()
311
325
dokka {
312
326
moduleName.set(" PowerSync Core" )
313
327
}
314
-
315
- val generateVersionConstant by tasks.registering {
316
- val target = project.layout.buildDirectory.dir(" generated/constants" )
317
- val packageName = " com.powersync.build"
318
-
319
- outputs.dir(target)
320
- val currentVersion = version.toString()
321
-
322
- doLast {
323
- val dir = target.get().asFile
324
- dir.mkdir()
325
- val rootPath = dir.toPath()
326
-
327
- val source = """
328
- package $packageName
329
-
330
- internal const val LIBRARY_VERSION: String = "$currentVersion "
331
-
332
- """ .trimIndent()
333
-
334
- val packageRoot = packageName.split(' .' ).fold(rootPath, Path ::resolve)
335
- packageRoot.createDirectories()
336
-
337
- packageRoot.resolve(" BuildConstants.kt" ).writeText(source)
338
- }
339
- }
0 commit comments