Skip to content

Commit 8a81285

Browse files
committed
Move and extract the source generation Gradle script code into a function in "gradle-common" and apply it
In the meantime, kotlin-common-gradle-plugins is bumped to 0.1.8-kotlin-1.6.10. The corresponding commit: huanshankeji/gradle-common@096a232
1 parent 7baf37f commit 8a81285

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val projectVersion = "0.1.0-compose-1.1.1-SNAPSHOT"
1+
const val projectVersion = "0.1.0-compose-1.1.1-SNAPSHOT"
22

33
object DependencyVersions {
44
val webcomponents = "2.6.0"

gradle-plugins/build.gradle.kts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import com.huanshankeji.SourceFile
2+
import com.huanshankeji.generateKotlinSources
3+
14
plugins {
25
`kotlin-dsl`
36
id("com.gradle.plugin-publish") version "1.0.0-rc-2"
@@ -12,20 +15,14 @@ dependencies {
1215
}
1316

1417

15-
val generateVersion = "generateVersion"
16-
val generatedSourcesDir = buildDir.resolve("gen/main/kotlin")
17-
18-
tasks.register(generateVersion) {
19-
generatedSourcesDir.mkdirs()
20-
val generatedVersionsSourceFile = generatedSourcesDir.resolve("GeneratedVersions.kt")
21-
generatedVersionsSourceFile.writeText("const val projectVersion = \"$projectVersion\"\n")
22-
}
23-
24-
tasks.compileKotlin {
25-
dependsOn(generateVersion)
26-
}
27-
28-
kotlin.sourceSets["main"].kotlin.srcDir(generatedSourcesDir)
18+
generateKotlinSources(
19+
sourceFiles = listOf(
20+
SourceFile(
21+
"GeneratedVersions.kt",
22+
"const val projectVersion = \"$projectVersion\"\n"
23+
)
24+
)
25+
)
2926

3027

3128
group = "com.huanshankeji"

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ buildscript {
1010
gradlePluginPortal()
1111
}
1212
dependencies {
13-
classpath("com.huanshankeji:kotlin-common-gradle-plugins:0.1.5-kotlin-1.6.10")
13+
classpath("com.huanshankeji:kotlin-common-gradle-plugins:0.1.8-kotlin-1.6.10")
1414
}
1515
}

0 commit comments

Comments
 (0)