Browse Source

Fix Todo example Deps (#1607)

task `gradlew jsBrowserDevelopmentRun` didn't work
pull/1614/head
Igor Demin 3 years ago committed by GitHub
parent
commit
b2213e3132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      examples/todoapp/buildSrc/build.gradle.kts
  2. 27
      examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt
  3. 1
      examples/todoapp/buildSrc/gradle.properties
  4. 2
      examples/todoapp/buildSrc/src/main/kotlin/android-setup.gradle.kts
  5. 2
      examples/todoapp/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts
  6. 12
      examples/todoapp/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts
  7. 3
      examples/todoapp/gradle.properties

6
examples/todoapp/buildSrc/build.gradle.kts

@ -2,6 +2,8 @@ plugins {
`kotlin-dsl` `kotlin-dsl`
} }
initDeps(project)
repositories { repositories {
mavenLocal() mavenLocal()
google() google()
@ -10,8 +12,8 @@ repositories {
} }
dependencies { dependencies {
implementation(Deps.JetBrains.Compose(project).gradlePlugin) implementation(Deps.JetBrains.Compose.gradlePlugin)
implementation(Deps.JetBrains.Kotlin(project).gradlePlugin) implementation(Deps.JetBrains.Kotlin.gradlePlugin)
implementation(Deps.Android.Tools.Build.gradlePlugin) implementation(Deps.Android.Tools.Build.gradlePlugin)
implementation(Deps.Squareup.SQLDelight.gradlePlugin) implementation(Deps.Squareup.SQLDelight.gradlePlugin)
} }

27
examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt

@ -1,23 +1,28 @@
// We store Kotlin and Compose versions in gradle.properties to // We store Kotlin and Compose versions in gradle.properties to
// be able to override them on CI. // be able to override them on CI.
// You probably won't need this, so you can get rid of `project` in this file. // You probably won't need this, so you can get rid of `project` in this file.
import org.gradle.api.Project import org.gradle.api.Project
lateinit var properties: Map<String, *>
fun initDeps(project: Project) {
properties = project.properties
}
object Deps { object Deps {
object JetBrains { object JetBrains {
class Kotlin(private val project: Project) { object Kotlin {
private val VERSION = project.properties["kotlin.version"] private val VERSION get() = properties["kotlin.version"]
val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$VERSION" val gradlePlugin get() = "org.jetbrains.kotlin:kotlin-gradle-plugin:$VERSION"
val testCommon = "org.jetbrains.kotlin:kotlin-test-common:$VERSION" val testCommon get() = "org.jetbrains.kotlin:kotlin-test-common:$VERSION"
val testJunit = "org.jetbrains.kotlin:kotlin-test-junit:$VERSION" val testJunit get() = "org.jetbrains.kotlin:kotlin-test-junit:$VERSION"
val testJs = "org.jetbrains.kotlin:kotlin-test-js:$VERSION" val testJs get() = "org.jetbrains.kotlin:kotlin-test-js:$VERSION"
val testAnnotationsCommon = "org.jetbrains.kotlin:kotlin-test-annotations-common:$VERSION" val testAnnotationsCommon get() = "org.jetbrains.kotlin:kotlin-test-annotations-common:$VERSION"
} }
class Compose(private val project: Project) { object Compose {
private val VERSION = project.properties["compose.version"] private val VERSION get() = properties["compose.version"]
val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION" val gradlePlugin get() = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
} }
} }

1
examples/todoapp/buildSrc/gradle.properties

@ -1,2 +1,3 @@
# TODO can we get rid of duplication with root gradle.properties?
kotlin.version=1.6.10 kotlin.version=1.6.10
compose.version=1.0.1-rc2 compose.version=1.0.1-rc2

2
examples/todoapp/buildSrc/src/main/kotlin/android-setup.gradle.kts

@ -2,6 +2,8 @@ plugins {
id("com.android.library") id("com.android.library")
} }
initDeps(project)
android { android {
compileSdkVersion(31) compileSdkVersion(31)

2
examples/todoapp/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts

@ -6,6 +6,8 @@ plugins {
id("org.jetbrains.compose") id("org.jetbrains.compose")
} }
initDeps(project)
kotlin { kotlin {
jvm("desktop") jvm("desktop")
android() android()

12
examples/todoapp/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts

@ -3,6 +3,8 @@ plugins {
id("kotlin-multiplatform") id("kotlin-multiplatform")
} }
initDeps(project)
kotlin { kotlin {
jvm("desktop") jvm("desktop")
android() android()
@ -15,24 +17,24 @@ kotlin {
sourceSets { sourceSets {
named("commonTest") { named("commonTest") {
dependencies { dependencies {
implementation(Deps.JetBrains.Kotlin(project).testCommon) implementation(Deps.JetBrains.Kotlin.testCommon)
implementation(Deps.JetBrains.Kotlin(project).testAnnotationsCommon) implementation(Deps.JetBrains.Kotlin.testAnnotationsCommon)
} }
} }
named("androidTest") { named("androidTest") {
dependencies { dependencies {
implementation(Deps.JetBrains.Kotlin(project).testJunit) implementation(Deps.JetBrains.Kotlin.testJunit)
} }
} }
named("desktopTest") { named("desktopTest") {
dependencies { dependencies {
implementation(Deps.JetBrains.Kotlin(project).testJunit) implementation(Deps.JetBrains.Kotlin.testJunit)
} }
} }
named("jsTest") { named("jsTest") {
dependencies { dependencies {
implementation(Deps.JetBrains.Kotlin(project).testJs) implementation(Deps.JetBrains.Kotlin.testJs)
} }
} }
} }

3
examples/todoapp/gradle.properties

@ -22,3 +22,6 @@ kotlin.code.style=official
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.caching=true org.gradle.caching=true
kotlin.native.disableCompilerDaemon=true kotlin.native.disableCompilerDaemon=true
kotlin.version=1.6.10
compose.version=1.0.1-rc2
Loading…
Cancel
Save