From f483c9380383802e38e1ac33c23b0bd5acb61cab Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Fri, 2 Sep 2022 21:10:59 +0900 Subject: [PATCH 01/20] add paparazzi & showcase --- core-ui/build.gradle.kts | 5 +++++ feature-contributors/build.gradle.kts | 6 ++++++ feature-sessions/build.gradle.kts | 6 ++++++ gradle/libs.versions.toml | 9 +++++++++ 4 files changed, 26 insertions(+) diff --git a/core-ui/build.gradle.kts b/core-ui/build.gradle.kts index 201541a1a..ab3b3fcc5 100644 --- a/core-ui/build.gradle.kts +++ b/core-ui/build.gradle.kts @@ -1,3 +1,5 @@ +// TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed +@Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.primitive.android") id("droidkaigi.primitive.android.kotlin") @@ -5,10 +7,13 @@ plugins { id("droidkaigi.primitive.android.hilt") id("droidkaigi.primitive.molecule") id("droidkaigi.primitive.spotless") + alias(libs.plugins.ksp) } android.namespace = "io.github.droidkaigi.confsched2022.template.core.ui" dependencies { implementation(libs.accompanistPager) + implementation(libs.showkase.runtime) + ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/feature-contributors/build.gradle.kts b/feature-contributors/build.gradle.kts index 9d35d6c63..0e890e35c 100644 --- a/feature-contributors/build.gradle.kts +++ b/feature-contributors/build.gradle.kts @@ -1,5 +1,8 @@ +// TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed +@Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.convention.androidfeature") + alias(libs.plugins.ksp) } android.namespace = "io.github.droidkaigi.confsched2022.feature.contributors" @@ -23,4 +26,7 @@ dependencies { androidTestImplementation(libs.composeUiTestJunit4) debugImplementation(libs.composeUiTooling) debugImplementation(libs.composeUiTestManifest) + + implementation(libs.showkase.runtime) + ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/feature-sessions/build.gradle.kts b/feature-sessions/build.gradle.kts index d88fa0ae9..dfa395c95 100644 --- a/feature-sessions/build.gradle.kts +++ b/feature-sessions/build.gradle.kts @@ -1,5 +1,8 @@ +// TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed +@Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.convention.androidfeature") + alias(libs.plugins.ksp) } android.namespace = "io.github.droidkaigi.confsched2022.feature.sessions" @@ -25,4 +28,7 @@ dependencies { androidTestImplementation(libs.composeUiTestJunit4) debugImplementation(libs.composeUiTooling) debugImplementation(libs.composeUiTestManifest) + + implementation(libs.showkase.runtime) + ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 69fa508a6..cd83d87f0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -41,6 +41,10 @@ firebaseAuth = "21.0.7" androidxStartup = "1.1.1" kluent = "1.68" coilCompose="2.2.0" +ksp = "1.7.10-1.0.6" +paparazzi = "1.0.0" +showkase = "1.0.0-beta13" +testParameterInjector = "1.8" [libraries] androidGradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } @@ -112,9 +116,14 @@ androidxTestEspressoEspressoCore = { module = "androidx.test.espresso:espresso-c hiltAndroidTesting = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "dagger" } robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } kluentAndroid = {module = "org.amshove.kluent:kluent-android", version.ref = "kluent" } +showkase-runtime = { group = "com.airbnb.android", name = "showkase", version.ref = "showkase" } +showkase-processor = { group = "com.airbnb.android", name = "showkase-processor", version.ref = "showkase" } +testParameterInjector = { group = "com.google.testparameterinjector", name = "test-parameter-injector", version.ref = "testParameterInjector" } [plugins] androidGradlePlugin = { id = "com.android.application", version.ref = "androidGradlePlugin" } androidGradleLibraryPlugin = { id = "com.android.library", version.ref = "androidGradlePlugin" } kotlinPlugin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } hiltGradlePlugin = { id = "com.google.dagger.hilt.android", version.ref = "dagger" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } \ No newline at end of file From 48802bb9ed14c1423a17aec96bb78dffe54fc7bc Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Fri, 2 Sep 2022 22:45:05 +0900 Subject: [PATCH 02/20] add test module --- preview-screenshots/.gitignore | 1 + preview-screenshots/build.gradle.kts | 46 ++++++++++++ preview-screenshots/consumer-rules.pro | 0 preview-screenshots/proguard-rules.pro | 21 ++++++ .../src/main/AndroidManifest.xml | 4 + .../confsched2022/PreviewScreenshotTests.kt | 73 +++++++++++++++++++ .../confsched2022/ScreenshotShowkaseModule.kt | 7 ++ settings.gradle.kts | 3 +- 8 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 preview-screenshots/.gitignore create mode 100644 preview-screenshots/build.gradle.kts create mode 100644 preview-screenshots/consumer-rules.pro create mode 100644 preview-screenshots/proguard-rules.pro create mode 100644 preview-screenshots/src/main/AndroidManifest.xml create mode 100644 preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt create mode 100644 preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt diff --git a/preview-screenshots/.gitignore b/preview-screenshots/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/preview-screenshots/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/preview-screenshots/build.gradle.kts b/preview-screenshots/build.gradle.kts new file mode 100644 index 000000000..c90f041c9 --- /dev/null +++ b/preview-screenshots/build.gradle.kts @@ -0,0 +1,46 @@ +// TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed +@Suppress("DSL_SCOPE_VIOLATION") +plugins { + id("droidkaigi.primitive.android") + id("droidkaigi.primitive.android.kotlin") + id("droidkaigi.primitive.android.compose") + id("droidkaigi.primitive.molecule") + id("droidkaigi.primitive.spotless") + alias(libs.plugins.ksp) + alias(libs.plugins.paparazzi) +} + +android.namespace = "io.github.droidkaigi.confsched2022.template.preview.screenshots" + +androidComponents { + // Disable release builds for this test-only library, no need to run screenshot tests more than + // once + beforeVariants(selector().withBuildType("release")) { builder -> + builder.enable = false + } + beforeVariants(selector().withBuildType("prod")) { builder -> + builder.enable = false + } +} + +dependencies { + + implementation(project(":core-ui")) + implementation(project(":feature-contributors")) + implementation(project(":feature-sessions")) + + implementation(libs.showkase.runtime) + ksp(libs.showkase.processor) + + testImplementation(projects.coreTesting) + testImplementation(libs.testParameterInjector) +} + +tasks.named("check") { + dependsOn("verifyPaparazziDemoDebug") +} + +tasks.withType().configureEach { + // Increase memory for Paparazzi tests + maxHeapSize = "2g" +} \ No newline at end of file diff --git a/preview-screenshots/consumer-rules.pro b/preview-screenshots/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/preview-screenshots/proguard-rules.pro b/preview-screenshots/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/preview-screenshots/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/preview-screenshots/src/main/AndroidManifest.xml b/preview-screenshots/src/main/AndroidManifest.xml new file mode 100644 index 000000000..a5918e68a --- /dev/null +++ b/preview-screenshots/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt new file mode 100644 index 000000000..51073aae1 --- /dev/null +++ b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt @@ -0,0 +1,73 @@ +package io.github.droidkaigi.confsched2022 + +import androidx.compose.foundation.layout.Box +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.unit.Density +import app.cash.paparazzi.DeviceConfig +import app.cash.paparazzi.Paparazzi +import com.airbnb.android.showkase.models.Showkase +import com.airbnb.android.showkase.models.ShowkaseBrowserComponent +import com.google.testing.junit.testparameterinjector.TestParameter +import com.google.testing.junit.testparameterinjector.TestParameter.TestParameterValuesProvider +import com.google.testing.junit.testparameterinjector.TestParameterInjector +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +class ComponentPreview( + private val showkaseBrowserComponent: ShowkaseBrowserComponent +) { + val content: @Composable () -> Unit = showkaseBrowserComponent.component + override fun toString(): String = showkaseBrowserComponent.componentKey +} + +@RunWith(TestParameterInjector::class) +class PreviewScreenshotTests { + + object PreviewProvider : TestParameterValuesProvider { + override fun provideValues(): List = + Showkase.getMetadata().componentList.map(::ComponentPreview) + } + + enum class BaseDeviceConfig( + val deviceConfig: DeviceConfig, + ) { + NEXUS_5(DeviceConfig.NEXUS_5), + PIXEL_5(DeviceConfig.PIXEL_5), + PIXEL_C(DeviceConfig.PIXEL_C), + } + + @get:Rule + val paparazzi = Paparazzi( + maxPercentDifference = 0.0, + ) + + @Test + fun preview_tests( + @TestParameter(valuesProvider = PreviewProvider::class) componentPreview: ComponentPreview, + @TestParameter baseDeviceConfig: BaseDeviceConfig, + @TestParameter(value = ["1.0", "1.5"]) fontScale: Float + ) { + paparazzi.unsafeUpdateConfig( + baseDeviceConfig.deviceConfig.copy( + softButtons = false, + ) + ) + paparazzi.snapshot { + CompositionLocalProvider( + LocalInspectionMode provides true, + LocalDensity provides Density( + density = LocalDensity.current.density, + fontScale = fontScale + ) + ) { + Box { + componentPreview.content() + } + } + } + } +} \ No newline at end of file diff --git a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt new file mode 100644 index 000000000..db5675a87 --- /dev/null +++ b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt @@ -0,0 +1,7 @@ +package io.github.droidkaigi.confsched2022 + +import com.airbnb.android.showkase.annotation.ShowkaseRoot +import com.airbnb.android.showkase.annotation.ShowkaseRootModule + +@ShowkaseRoot +class ScreenshotShowkaseModule : ShowkaseRootModule \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 64c915f6f..aebd0a4f9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,7 +35,8 @@ include( ":core-designsystem", ":core-data", ":core-testing", - ":core-model" + ":core-model", + ":preview-screenshots" ) // for iOS framework name From df249fe3312c72f7a3c78463b458e62ad95c8d86 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Fri, 2 Sep 2022 23:19:28 +0900 Subject: [PATCH 03/20] add preview parameter add ci setting --- .github/workflows/Build.yml | 5 ++++- .../feature/contributors/Contributors.kt | 11 ++++++++++- preview-screenshots/build.gradle.kts | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 535eecf6a..270e853a6 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -48,7 +48,10 @@ jobs: run: ./gradlew compileZipline --stacktrace - name: Run local tests - run: ./gradlew testDebug --stacktrace + run: ./gradlew testDebug -x :preview-screenshots:tesDebug --stacktrace + + - name: Run screenshot tests + run: ./gradlew :preview-screenshots:verifyPaparazziDebug --stacktrace - name: Upload build outputs (APKs) uses: actions/upload-artifact@v3 diff --git a/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt b/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt index 60b7b8618..298234af5 100644 --- a/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt +++ b/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt @@ -27,6 +27,8 @@ import coil.compose.AsyncImage import io.github.droidkaigi.confsched2022.designsystem.theme.KaigiScaffold import io.github.droidkaigi.confsched2022.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched2022.feature.contributors.ContributorsUiModel.ContributorsState.Loaded +import io.github.droidkaigi.confsched2022.model.Contributor +import io.github.droidkaigi.confsched2022.model.fakes @Composable fun ContributorsScreenRoot( @@ -90,6 +92,13 @@ fun Contributors( @Composable fun ContributorsPreview() { KaigiTheme { - ContributorsScreenRoot() + Contributors( + uiModel = ContributorsUiModel( + Loaded( + contributors = Contributor.fakes() + ) + ), + onNavigationIconClick = {} + ) } } diff --git a/preview-screenshots/build.gradle.kts b/preview-screenshots/build.gradle.kts index c90f041c9..4d5d0b7c5 100644 --- a/preview-screenshots/build.gradle.kts +++ b/preview-screenshots/build.gradle.kts @@ -29,6 +29,7 @@ dependencies { implementation(project(":feature-contributors")) implementation(project(":feature-sessions")) + implementation(libs.composeUi) implementation(libs.showkase.runtime) ksp(libs.showkase.processor) From 5fd94757771233c7349b868f987f8d6506897db0 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Fri, 2 Sep 2022 23:28:18 +0900 Subject: [PATCH 04/20] fixed spotless --- .../github/droidkaigi/confsched2022/PreviewScreenshotTests.kt | 2 +- .../github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt index 51073aae1..631dfca44 100644 --- a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt +++ b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt @@ -70,4 +70,4 @@ class PreviewScreenshotTests { } } } -} \ No newline at end of file +} diff --git a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt index db5675a87..ce418583f 100644 --- a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt +++ b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/ScreenshotShowkaseModule.kt @@ -4,4 +4,4 @@ import com.airbnb.android.showkase.annotation.ShowkaseRoot import com.airbnb.android.showkase.annotation.ShowkaseRootModule @ShowkaseRoot -class ScreenshotShowkaseModule : ShowkaseRootModule \ No newline at end of file +class ScreenshotShowkaseModule : ShowkaseRootModule From 94224d0e77a37f6520948bce1993554d3a587af6 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Sat, 3 Sep 2022 20:09:03 +0900 Subject: [PATCH 05/20] fixed sdk32 --- .github/workflows/Build.yml | 2 +- .../droidkaigi/confsched2022/PreviewScreenshotTests.kt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 270e853a6..f03691f36 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -48,7 +48,7 @@ jobs: run: ./gradlew compileZipline --stacktrace - name: Run local tests - run: ./gradlew testDebug -x :preview-screenshots:tesDebug --stacktrace + run: ./gradlew testDebug -x :preview-screenshots:testDebug --stacktrace - name: Run screenshot tests run: ./gradlew :preview-screenshots:verifyPaparazziDebug --stacktrace diff --git a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt index 631dfca44..53693824b 100644 --- a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt +++ b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt @@ -8,6 +8,8 @@ import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.unit.Density import app.cash.paparazzi.DeviceConfig import app.cash.paparazzi.Paparazzi +import app.cash.paparazzi.androidHome +import app.cash.paparazzi.detectEnvironment import com.airbnb.android.showkase.models.Showkase import com.airbnb.android.showkase.models.ShowkaseBrowserComponent import com.google.testing.junit.testparameterinjector.TestParameter @@ -42,6 +44,10 @@ class PreviewScreenshotTests { @get:Rule val paparazzi = Paparazzi( + environment = detectEnvironment().copy( + platformDir = "${androidHome()}/platforms/android-32", + compileSdkVersion = 32 + ), maxPercentDifference = 0.0, ) From d133d4c1f52db446fb22f867d224741217c001b1 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Sat, 3 Sep 2022 20:46:30 +0900 Subject: [PATCH 06/20] test record snapshots --- .github/workflows/Build.yml | 3 +++ .../confsched2022/feature/sessions/Sessions.kt | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index f03691f36..13872d02e 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -34,6 +34,9 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Record SnapShot + uses: ./gradlew recordPaparazziDebug + - name: Check spotless run: ./gradlew spotlessCheck --stacktrace diff --git a/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt b/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt index 23a010028..bf5d587ff 100644 --- a/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt +++ b/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt @@ -25,6 +25,8 @@ import com.google.accompanist.pager.rememberPagerState import io.github.droidkaigi.confsched2022.designsystem.theme.KaigiScaffold import io.github.droidkaigi.confsched2022.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched2022.feature.sessions.SessionsUiModel.ScheduleState.Loaded +import io.github.droidkaigi.confsched2022.feature.sessions.SessionsUiModel.ScheduleState.Loading +import io.github.droidkaigi.confsched2022.model.DroidKaigiSchedule import io.github.droidkaigi.confsched2022.model.TimetableItemId import io.github.droidkaigi.confsched2022.model.orEmptyContents @@ -122,6 +124,14 @@ fun Sessions( @Composable fun SessionsPreview() { KaigiTheme { - SessionsScreenRoot() + Sessions( + uiModel = SessionsUiModel(scheduleState = Loading, isFilterOn = false), + selectedTab = 0, + onNavigationIconClick = {}, + onFavoriteClick = { _, _ -> }, + onTabClicked = {}, + onTimetableClick = {}, + onToggleFilter = {} + ) } } From 01b8392f532ae166430d1658454f33f4150b9048 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Sat, 3 Sep 2022 21:04:32 +0900 Subject: [PATCH 07/20] remove record snapshots --- .github/workflows/Build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 13872d02e..f03691f36 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -34,9 +34,6 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - - name: Record SnapShot - uses: ./gradlew recordPaparazziDebug - - name: Check spotless run: ./gradlew spotlessCheck --stacktrace From 1809b9c170735f729423621e9bc449fdd998a9d7 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Sun, 4 Sep 2022 13:09:11 +0900 Subject: [PATCH 08/20] use snapshot1.1.0 --- .../droidkaigi/confsched2022/feature/sessions/Sessions.kt | 2 -- gradle/libs.versions.toml | 4 ++-- settings.gradle.kts | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt b/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt index 8f19329e7..d290b7157 100644 --- a/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt +++ b/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt @@ -151,10 +151,8 @@ fun SessionsPreview() { KaigiTheme { Sessions( uiModel = SessionsUiModel(scheduleState = Loading, isFilterOn = false), - selectedTab = 0, onNavigationIconClick = {}, onFavoriteClick = { _, _ -> }, - onTabClicked = {}, onTimetableClick = {}, onToggleFilter = {} ) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 71163063e..dc6e6afa8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -43,7 +43,7 @@ kluent = "1.68" coilCompose="2.2.0" koin = "3.2.0" ksp = "1.7.10-1.0.6" -paparazzi = "1.0.0" +paparazzi = "1.1.0-SNAPSHOT" showkase = "1.0.0-beta13" testParameterInjector = "1.8" @@ -130,4 +130,4 @@ androidGradleLibraryPlugin = { id = "com.android.library", version.ref = "androi kotlinPlugin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } hiltGradlePlugin = { id = "com.google.dagger.hilt.android", version.ref = "dagger" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } -paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } \ No newline at end of file +paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } diff --git a/settings.gradle.kts b/settings.gradle.kts index aebd0a4f9..34cc96d05 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,7 +4,7 @@ pluginManagement { gradlePluginPortal() google() mavenCentral() -// maven("https://oss.sonatype.org/content/repositories/snapshots/") + maven("https://oss.sonatype.org/content/repositories/snapshots/") } } enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") @@ -14,6 +14,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven("https://oss.sonatype.org/content/repositories/snapshots/") // for datastore-okio // maven(url = "https://androidx.dev/snapshots/builds/8938977/artifacts/repository") { // content { From 93208e4a626dde40640fbaecfa21b2072b2ab040 Mon Sep 17 00:00:00 2001 From: takahirom Date: Sun, 4 Sep 2022 15:19:09 +0900 Subject: [PATCH 09/20] Just use 31 --- .../github/droidkaigi/confsched2022/PreviewScreenshotTests.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt index 53693824b..1ba89f1b1 100644 --- a/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt +++ b/preview-screenshots/src/test/java/io/github/droidkaigi/confsched2022/PreviewScreenshotTests.kt @@ -45,8 +45,8 @@ class PreviewScreenshotTests { @get:Rule val paparazzi = Paparazzi( environment = detectEnvironment().copy( - platformDir = "${androidHome()}/platforms/android-32", - compileSdkVersion = 32 + platformDir = "${androidHome()}/platforms/android-31", + compileSdkVersion = 31 ), maxPercentDifference = 0.0, ) From 937377627dc5916a3bae6c853501a8650c1b0a44 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Mon, 5 Sep 2022 21:46:46 +0900 Subject: [PATCH 10/20] add workflow --- .github/workflows/ScreenShotTest.yml | 59 +++++++++++++++++++++++++ .github/workflows/UpdateScreenshots.yml | 25 +++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/workflows/ScreenShotTest.yml create mode 100644 .github/workflows/UpdateScreenshots.yml diff --git a/.github/workflows/ScreenShotTest.yml b/.github/workflows/ScreenShotTest.yml new file mode 100644 index 000000000..e9506cf1c --- /dev/null +++ b/.github/workflows/ScreenShotTest.yml @@ -0,0 +1,59 @@ +on: + push: + branches: + - main + pull_request: + +jobs: + screenshot-test: + runs-on: ubuntu-latest + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Download Screenshots + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: UpdateScreenshots.yml + name: screenshots + path: preview-screenshots/src/test/snapshots/images + + - name: Run screenshot tests + id: verifyPaparazziDebug + continue-on-error: true + run: ./gradlew preview-screenshots:verifyPaparazziDebug + + - name: Error Screenshot tests + continue-on-error: true + if: ${{ hashFiles('preview-screenshots/out/failures/*.png') != '' }} + uses: actions/upload-artifact@v3 + with: + name: scrennshot-test-results + path: preview-screenshots/out/failures + + - name: Comment PR + continue-on-error: true + if: ${{ hashFiles('preview-screenshots/out/failures/*.png') != '' }} + uses: thollander/actions-comment-pull-request@v1 + with: + message: | + There are differences in Compose previews. Please check your build and download the diff artifact. + https://github.com/DroidKaigi/conference-app-2022/actions/workflows/ScreenShotTest.yml + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/UpdateScreenshots.yml b/.github/workflows/UpdateScreenshots.yml new file mode 100644 index 000000000..ab26846c5 --- /dev/null +++ b/.github/workflows/UpdateScreenshots.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - main + types: [closed] + +jobs: + update-screenshot: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v1 + with: + java-version: '11' + - name: Run Update Screenshots + run: ./gradlew recordPaparazziDebug + + - name: Upload Screenshots + uses: actions/upload-artifact@v3 + with: + name: screenshots + path: preview-screenshots/src/test/snapshots/images + retention-days: 15 From 19bef1610b1daeb42e58b7e88a0dd408d3fdf0d0 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Mon, 5 Sep 2022 22:09:26 +0900 Subject: [PATCH 11/20] remove screenshot test in Build.yml --- .github/workflows/Build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index bc03b949d..518ac3f44 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -48,10 +48,7 @@ jobs: run: ./gradlew compileZipline --stacktrace - name: Run local tests - run: ./gradlew testDebug -x :preview-screenshots:testDebug --stacktrace - - - name: Run screenshot tests - run: ./gradlew :preview-screenshots:verifyPaparazziDebug --stacktrace + run: ./gradlew testDebug --stacktrace - name: Upload build outputs (APKs) uses: actions/upload-artifact@v3 From 50e642b0121a32e4c5a66971058e63ca00d12a63 Mon Sep 17 00:00:00 2001 From: shimoju Date: Tue, 6 Sep 2022 16:45:47 +0900 Subject: [PATCH 12/20] fixded review comment --- .github/workflows/ScreenShotTest.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ScreenShotTest.yml b/.github/workflows/ScreenShotTest.yml index e9506cf1c..973e3457c 100644 --- a/.github/workflows/ScreenShotTest.yml +++ b/.github/workflows/ScreenShotTest.yml @@ -1,7 +1,4 @@ on: - push: - branches: - - main pull_request: jobs: @@ -41,7 +38,6 @@ jobs: run: ./gradlew preview-screenshots:verifyPaparazziDebug - name: Error Screenshot tests - continue-on-error: true if: ${{ hashFiles('preview-screenshots/out/failures/*.png') != '' }} uses: actions/upload-artifact@v3 with: @@ -49,11 +45,10 @@ jobs: path: preview-screenshots/out/failures - name: Comment PR - continue-on-error: true if: ${{ hashFiles('preview-screenshots/out/failures/*.png') != '' }} uses: thollander/actions-comment-pull-request@v1 with: message: | There are differences in Compose previews. Please check your build and download the diff artifact. - https://github.com/DroidKaigi/conference-app-2022/actions/workflows/ScreenShotTest.yml + https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 38f01f1e0a61bf684dd788b470a934c06f4db820 Mon Sep 17 00:00:00 2001 From: shimoju Date: Tue, 6 Sep 2022 16:46:25 +0900 Subject: [PATCH 13/20] update screenshots --- .github/workflows/UpdateScreenshots.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/UpdateScreenshots.yml b/.github/workflows/UpdateScreenshots.yml index ab26846c5..781a73198 100644 --- a/.github/workflows/UpdateScreenshots.yml +++ b/.github/workflows/UpdateScreenshots.yml @@ -2,12 +2,12 @@ on: pull_request: branches: - main - types: [closed] +# types: [closed] jobs: update-screenshot: runs-on: ubuntu-latest - if: github.event.pull_request.merged == true +# if: github.event.pull_request.merged == true steps: - uses: actions/checkout@v3 From dff7c71ed01a9d894cd4f9219f951159322342f2 Mon Sep 17 00:00:00 2001 From: shimoju Date: Tue, 6 Sep 2022 16:58:54 +0900 Subject: [PATCH 14/20] revert UpdateScreenshots.yml --- .github/workflows/UpdateScreenshots.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/UpdateScreenshots.yml b/.github/workflows/UpdateScreenshots.yml index 781a73198..ab26846c5 100644 --- a/.github/workflows/UpdateScreenshots.yml +++ b/.github/workflows/UpdateScreenshots.yml @@ -2,12 +2,12 @@ on: pull_request: branches: - main -# types: [closed] + types: [closed] jobs: update-screenshot: runs-on: ubuntu-latest -# if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true steps: - uses: actions/checkout@v3 From cdea9489286f5f56aadd4cd36485b91d1e6509ef Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Thu, 8 Sep 2022 20:39:00 +0900 Subject: [PATCH 15/20] fixed build error --- .../confsched2022/feature/contributors/Contributors.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt b/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt index 6e3aba50a..cb9c6639e 100644 --- a/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt +++ b/feature-contributors/src/main/java/io/github/droidkaigi/confsched2022/feature/contributors/Contributors.kt @@ -150,7 +150,8 @@ fun ContributorsPreview() { contributors = Contributor.fakes() ) ), - onNavigationIconClick = {} + onNavigationIconClick = {}, + showNavigationIcon = true ) } } From 0d8f6ef8cb4b3794021b124f3963a6c55a86b067 Mon Sep 17 00:00:00 2001 From: sobaya-0141 Date: Wed, 14 Sep 2022 09:42:40 +0900 Subject: [PATCH 16/20] update setup-java version --- .github/workflows/ScreenShotTest.yml | 2 +- .github/workflows/UpdateScreenshots.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ScreenShotTest.yml b/.github/workflows/ScreenShotTest.yml index 973e3457c..1fa808373 100644 --- a/.github/workflows/ScreenShotTest.yml +++ b/.github/workflows/ScreenShotTest.yml @@ -17,7 +17,7 @@ jobs: run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 11 diff --git a/.github/workflows/UpdateScreenshots.yml b/.github/workflows/UpdateScreenshots.yml index ab26846c5..e1d0eb5bd 100644 --- a/.github/workflows/UpdateScreenshots.yml +++ b/.github/workflows/UpdateScreenshots.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v3 with: java-version: '11' - name: Run Update Screenshots From f6debee64f8344dc30b042598ed89e7c584251f1 Mon Sep 17 00:00:00 2001 From: Soichi Ikebe Date: Thu, 15 Sep 2022 02:36:21 +0900 Subject: [PATCH 17/20] Fix JDK setup error --- .github/workflows/ScreenShotTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ScreenShotTest.yml b/.github/workflows/ScreenShotTest.yml index 1fa808373..15048956d 100644 --- a/.github/workflows/ScreenShotTest.yml +++ b/.github/workflows/ScreenShotTest.yml @@ -19,6 +19,7 @@ jobs: - name: Set up JDK 11 uses: actions/setup-java@v3 with: + distribution: temurin java-version: 11 - name: Setup Gradle From 8dce81065321bd0b2f6a14ebe6fc0d296c8212eb Mon Sep 17 00:00:00 2001 From: Soichi Ikebe Date: Thu, 15 Sep 2022 02:37:57 +0900 Subject: [PATCH 18/20] Fix showkase build error --- .../droidkaigi/confsched2022/feature/sessions/Search.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Search.kt b/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Search.kt index fd30b878f..ac54da5c5 100644 --- a/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Search.kt +++ b/feature-sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Search.kt @@ -286,7 +286,7 @@ private fun SearchedItem( } @Composable -private fun FullScreenLoading(modifier: Modifier = Modifier) { +fun FullScreenLoading(modifier: Modifier = Modifier) { Box( modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center, @@ -297,7 +297,7 @@ private fun FullScreenLoading(modifier: Modifier = Modifier) { @Preview(showSystemUi = true) @Composable -private fun SearchScreenPreview() { +fun SearchScreenPreview() { SearchScreen( uiModel = SearchUiModel( state = Success(DroidKaigiSchedule.fake()) From eece50889d8ba649fdfc02de45f312b4d8bca577 Mon Sep 17 00:00:00 2001 From: Soichi Ikebe Date: Thu, 15 Sep 2022 05:38:41 +0900 Subject: [PATCH 19/20] Migrate to primitive plugins --- core-ui/build.gradle.kts | 4 +--- feature-contributors/build.gradle.kts | 5 +---- feature-sessions/build.gradle.kts | 5 +---- gradle/libs.versions.toml | 12 ++++++----- gradle/plugins/build.gradle.kts | 11 +++++++++- .../primitive/KotlinGradleDsl.kt | 6 ++++++ .../primitive/PaparazziPlugin.kt | 13 ++++++++++++ .../confsched2022/primitive/ShowkasePlugin.kt | 21 +++++++++++++++++++ preview-screenshots/build.gradle.kts | 6 ++---- settings.gradle.kts | 1 - 10 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/PaparazziPlugin.kt create mode 100644 gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/ShowkasePlugin.kt diff --git a/core-ui/build.gradle.kts b/core-ui/build.gradle.kts index d3a31bdc5..ba69aba41 100644 --- a/core-ui/build.gradle.kts +++ b/core-ui/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("droidkaigi.primitive.android.hilt") id("droidkaigi.primitive.molecule") id("droidkaigi.primitive.spotless") - alias(libs.plugins.ksp) + id("droidkaigi.primitive.android.compose.showkase") } android.namespace = "io.github.droidkaigi.confsched2022.template.core.ui" @@ -17,6 +17,4 @@ android.kotlinOptions.freeCompilerArgs = listOf( dependencies { implementation(libs.accompanistPager) - implementation(libs.showkase.runtime) - ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/feature-contributors/build.gradle.kts b/feature-contributors/build.gradle.kts index 0e890e35c..aca98f142 100644 --- a/feature-contributors/build.gradle.kts +++ b/feature-contributors/build.gradle.kts @@ -2,7 +2,7 @@ @Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.convention.androidfeature") - alias(libs.plugins.ksp) + id("droidkaigi.primitive.android.compose.showkase") } android.namespace = "io.github.droidkaigi.confsched2022.feature.contributors" @@ -26,7 +26,4 @@ dependencies { androidTestImplementation(libs.composeUiTestJunit4) debugImplementation(libs.composeUiTooling) debugImplementation(libs.composeUiTestManifest) - - implementation(libs.showkase.runtime) - ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/feature-sessions/build.gradle.kts b/feature-sessions/build.gradle.kts index f9cba6155..9bc92d80a 100644 --- a/feature-sessions/build.gradle.kts +++ b/feature-sessions/build.gradle.kts @@ -2,7 +2,7 @@ @Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.convention.androidfeature") - alias(libs.plugins.ksp) + id("droidkaigi.primitive.android.compose.showkase") } android.namespace = "io.github.droidkaigi.confsched2022.feature.sessions" @@ -30,7 +30,4 @@ dependencies { androidTestImplementation(libs.composeUiTestJunit4) debugImplementation(libs.composeUiTooling) debugImplementation(libs.composeUiTestManifest) - - implementation(libs.showkase.runtime) - ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3616286a7..5d4d49289 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -45,7 +45,7 @@ coilCompose = "2.2.1" koin = "3.2.1" androidXChromeCustomTabs = "1.4.0" ksp = "1.7.10-1.0.6" -paparazzi = "1.1.0-SNAPSHOT" +paparazzi = "1.0.0" showkase = "1.0.0-beta13" testParameterInjector = "1.8" mokoResources = "0.20.1" @@ -66,6 +66,8 @@ firebasePlugin = { module = "com.google.gms:google-services", version.ref = "fir mokoResourcesPlugin = { module = "dev.icerock.moko:resources-generator", version.ref = "mokoResources" } androidDesugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" } detektGradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" } +kspGradlePlugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } +paparazziGradlePlugin = { module = "app.cash.paparazzi:paparazzi-gradle-plugin", version.ref = "paparazzi" } composeRuntime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" } composeUi = { module = "androidx.compose.ui:ui", version.ref = "compose" } @@ -136,8 +138,8 @@ androidxTestEspressoEspressoCore = { module = "androidx.test.espresso:espresso-c hiltAndroidTesting = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "dagger" } robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } kluentAndroid = { module = "org.amshove.kluent:kluent-android", version.ref = "kluent" } -showkase-runtime = { group = "com.airbnb.android", name = "showkase", version.ref = "showkase" } -showkase-processor = { group = "com.airbnb.android", name = "showkase-processor", version.ref = "showkase" } +showkaseRuntime = { group = "com.airbnb.android", name = "showkase", version.ref = "showkase" } +showkaseProcessor = { group = "com.airbnb.android", name = "showkase-processor", version.ref = "showkase" } testParameterInjector = { group = "com.google.testparameterinjector", name = "test-parameter-injector", version.ref = "testParameterInjector" } [plugins] @@ -145,7 +147,7 @@ androidGradlePlugin = { id = "com.android.application", version.ref = "androidGr androidGradleLibraryPlugin = { id = "com.android.library", version.ref = "androidGradlePlugin" } kotlinPlugin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } hiltGradlePlugin = { id = "com.google.dagger.hilt.android", version.ref = "dagger" } -ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } -paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } +kspPlugin = { id = "com.google.devtools.ksp", version.ref = "ksp" } +paparazziPlugin = { id = "app.cash.paparazzi", version.ref = "paparazzi" } sqldelightGradlePlugin = { id = "com.squareup.sqldelight", version.ref = "sqldelight" } detektPlugin = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } diff --git a/gradle/plugins/build.gradle.kts b/gradle/plugins/build.gradle.kts index dbdc3018c..4fc671111 100644 --- a/gradle/plugins/build.gradle.kts +++ b/gradle/plugins/build.gradle.kts @@ -27,6 +27,8 @@ dependencies { implementation(libs.sqldelightGradlePlugin) implementation(libs.detektGradlePlugin) implementation(libs.mokoResourcesPlugin) + implementation(libs.kspGradlePlugin) + implementation(libs.paparazziGradlePlugin) } gradlePlugin { @@ -108,7 +110,14 @@ gradlePlugin { id = "droidkaigi.primitive.detekt" implementationClass = "io.github.droidkaigi.confsched2022.primitive.DetektPlugin" } - + register("paparazzi") { + id = "droidkaigi.primitive.android.paparazzi" + implementationClass = "io.github.droidkaigi.confsched2022.primitive.PaparazziPlugin" + } + register("showkase") { + id = "droidkaigi.primitive.android.compose.showkase" + implementationClass = "io.github.droidkaigi.confsched2022.primitive.ShowkasePlugin" + } // Conventions register("androidFeature") { id = "droidkaigi.convention.androidfeature" diff --git a/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/KotlinGradleDsl.kt b/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/KotlinGradleDsl.kt index b88609613..ec4b621ec 100644 --- a/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/KotlinGradleDsl.kt +++ b/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/KotlinGradleDsl.kt @@ -22,4 +22,10 @@ fun DependencyHandlerScope.kaptTest( fun TestedExtension.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { (this as ExtensionAware).extensions.configure("kotlinOptions", block) +} + +fun DependencyHandlerScope.ksp( + artifact: Optional> +) { + add("ksp", artifact.get()) } \ No newline at end of file diff --git a/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/PaparazziPlugin.kt b/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/PaparazziPlugin.kt new file mode 100644 index 000000000..4c45e6197 --- /dev/null +++ b/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/PaparazziPlugin.kt @@ -0,0 +1,13 @@ +package io.github.droidkaigi.confsched2022.primitive + +import org.gradle.api.Plugin +import org.gradle.api.Project + +@Suppress("unused") +class PaparazziPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + pluginManager.apply("app.cash.paparazzi") + } + } +} \ No newline at end of file diff --git a/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/ShowkasePlugin.kt b/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/ShowkasePlugin.kt new file mode 100644 index 000000000..52279c4fd --- /dev/null +++ b/gradle/plugins/src/main/kotlin/io/github/droidkaigi/confsched2022/primitive/ShowkasePlugin.kt @@ -0,0 +1,21 @@ +package io.github.droidkaigi.confsched2022.primitive + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.get + +@Suppress("unused") +class ShowkasePlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.google.devtools.ksp") + } + dependencies { + implementation(libs.findLibrary("showkaseRuntime")) + ksp(libs.findLibrary("showkaseProcessor")) + } + } + } +} \ No newline at end of file diff --git a/preview-screenshots/build.gradle.kts b/preview-screenshots/build.gradle.kts index 4d5d0b7c5..cd76af8fb 100644 --- a/preview-screenshots/build.gradle.kts +++ b/preview-screenshots/build.gradle.kts @@ -6,8 +6,8 @@ plugins { id("droidkaigi.primitive.android.compose") id("droidkaigi.primitive.molecule") id("droidkaigi.primitive.spotless") - alias(libs.plugins.ksp) - alias(libs.plugins.paparazzi) + id("droidkaigi.primitive.android.compose.showkase") + id("droidkaigi.primitive.android.paparazzi") } android.namespace = "io.github.droidkaigi.confsched2022.template.preview.screenshots" @@ -30,8 +30,6 @@ dependencies { implementation(project(":feature-sessions")) implementation(libs.composeUi) - implementation(libs.showkase.runtime) - ksp(libs.showkase.processor) testImplementation(projects.coreTesting) testImplementation(libs.testParameterInjector) diff --git a/settings.gradle.kts b/settings.gradle.kts index 6c7a70b02..c921100d6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,7 +4,6 @@ pluginManagement { gradlePluginPortal() google() mavenCentral() - maven("https://oss.sonatype.org/content/repositories/snapshots/") } } enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") From 513aaa28b7ad6ffb06874a7b93e0e1bee52022b6 Mon Sep 17 00:00:00 2001 From: Soichi Ikebe Date: Thu, 15 Sep 2022 05:41:38 +0900 Subject: [PATCH 20/20] Remove unused attributes --- core-ui/build.gradle.kts | 1 - feature-contributors/build.gradle.kts | 1 - feature-sessions/build.gradle.kts | 1 - preview-screenshots/build.gradle.kts | 1 - 4 files changed, 4 deletions(-) diff --git a/core-ui/build.gradle.kts b/core-ui/build.gradle.kts index ba69aba41..15977ef3a 100644 --- a/core-ui/build.gradle.kts +++ b/core-ui/build.gradle.kts @@ -1,5 +1,4 @@ // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed -@Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.primitive.android") id("droidkaigi.primitive.android.kotlin") diff --git a/feature-contributors/build.gradle.kts b/feature-contributors/build.gradle.kts index aca98f142..6f6bb76ce 100644 --- a/feature-contributors/build.gradle.kts +++ b/feature-contributors/build.gradle.kts @@ -1,5 +1,4 @@ // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed -@Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.convention.androidfeature") id("droidkaigi.primitive.android.compose.showkase") diff --git a/feature-sessions/build.gradle.kts b/feature-sessions/build.gradle.kts index 9bc92d80a..62cd87525 100644 --- a/feature-sessions/build.gradle.kts +++ b/feature-sessions/build.gradle.kts @@ -1,5 +1,4 @@ // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed -@Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.convention.androidfeature") id("droidkaigi.primitive.android.compose.showkase") diff --git a/preview-screenshots/build.gradle.kts b/preview-screenshots/build.gradle.kts index cd76af8fb..2d448711f 100644 --- a/preview-screenshots/build.gradle.kts +++ b/preview-screenshots/build.gradle.kts @@ -1,5 +1,4 @@ // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed -@Suppress("DSL_SCOPE_VIOLATION") plugins { id("droidkaigi.primitive.android") id("droidkaigi.primitive.android.kotlin")