Skip to content

Commit

Permalink
Use Kotlin setters
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Oct 25, 2023
1 parent 0aac1a2 commit 1ba2132
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
@file:Suppress("UnstableApiUsage")

import com.squareup.kotlinpoet.ClassName
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.jetbrains.jewel.buildlogic.demodata.AndroidStudioReleasesGeneratorTask
import org.jetbrains.jewel.buildlogic.demodata.STUDIO_RELEASES_OUTPUT_CLASS_NAME
import org.jetbrains.jewel.buildlogic.demodata.StudioVersionsGenerationExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.BaseKotlinCompile

val extension = extensions.findByType(StudioVersionsGenerationExtension::class.java)
?: extensions.create("androidStudioReleasesGenerator", StudioVersionsGenerationExtension::class.java)
val extension: StudioVersionsGenerationExtension =
extensions.findByType(StudioVersionsGenerationExtension::class.java)
?: extensions.create("androidStudioReleasesGenerator", StudioVersionsGenerationExtension::class.java)

val task =
tasks.register<AndroidStudioReleasesGeneratorTask>("generateAndroidStudioReleasesList") {
val className = ClassName.bestGuess(STUDIO_RELEASES_OUTPUT_CLASS_NAME)
outputFile.set(
extension.targetDir.file(
className.packageName.replace(".", "/")
.plus("/${className.simpleName}.kt")
)
outputFile = extension.targetDir.file(
className.packageName.replace(".", "/")
.plus("/${className.simpleName}.kt")
)
dataUrl.set(extension.dataUrl)
resourcesDirs.set(extension.resourcesDirs)
dataUrl = extension.dataUrl
resourcesDirs = extension.resourcesDirs
}

tasks {
withType<BaseKotlinCompile> {
dependsOn(task)
}

withType<Detekt> {
dependsOn(task)
}
tasks.withType<BaseKotlinCompile> {
dependsOn(task)
}
tasks.withType<Detekt> {
dependsOn(task)
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
extensions.getByType<KotlinJvmProjectExtension>().apply {
sourceSets["main"].kotlin.srcDir(extension.targetDir)
Expand Down
32 changes: 17 additions & 15 deletions buildSrc/src/main/kotlin/intellij-theme-generator.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
@file:Suppress("UnstableApiUsage")

import com.squareup.kotlinpoet.ClassName
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.kotlin.dsl.container
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.gradle.util.internal.GUtil
import org.jetbrains.jewel.buildlogic.theme.IntelliJThemeGeneratorTask
import org.jetbrains.jewel.buildlogic.theme.ThemeGeneration
Expand All @@ -17,21 +14,26 @@ extensions.add("intelliJThemeGenerator", extension)

extension.all {
val task = tasks.register<IntelliJThemeGeneratorTask>("generate${GUtil.toCamelCase(name)}Theme") {
outputFile.set(targetDir.file(this@all.themeClassName.map {
outputFile = targetDir.file(this@all.themeClassName.map {
val className = ClassName.bestGuess(it)
className.packageName.replace(".", "/")
.plus("/${className.simpleName}.kt")
}))
themeClassName.set(this@all.themeClassName)
ideaVersion.set(this@all.ideaVersion)
themeFile.set(this@all.themeFile)
}
tasks.withType<BaseKotlinCompile> {
dependsOn(task)
})
themeClassName = this@all.themeClassName
ideaVersion = this@all.ideaVersion
themeFile = this@all.themeFile
}
tasks.withType<Detekt> {
dependsOn(task)

tasks {
withType<BaseKotlinCompile> {
dependsOn(task)
}

withType<Detekt> {
dependsOn(task)
}
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
extensions.getByType<KotlinJvmProjectExtension>().apply {
sourceSets["main"].kotlin.srcDir(targetDir)
Expand Down
4 changes: 3 additions & 1 deletion buildSrc/src/main/kotlin/jewel-check-public-api.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UnstableApiUsage")

plugins {
id("org.jetbrains.kotlinx.binary-compatibility-validator")
id("dev.drewhamilton.poko")
Expand All @@ -13,7 +15,7 @@ apiValidation {
}

poko {
pokoAnnotation.set("org.jetbrains.jewel.foundation.GenerateDataFunctions")
pokoAnnotation = "org.jetbrains.jewel.foundation.GenerateDataFunctions"
}

tasks {
Expand Down

0 comments on commit 1ba2132

Please sign in to comment.