Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .claude/settings.local.json

This file was deleted.

12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,15 @@ proguard-project.txt
# Android Studio/IDEA
*.iml
.idea

# Agents
.claude/
.cursor/
.codex/
.copilot/
.aider.chat.history.md
.aider.tags.cache.v3
.windsurf/
.codeium/
.cline/
.anthropic/
12 changes: 11 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ plugins {
alias(libs.plugins.spotless) apply false
}

apply(from = "createSample.gradle.kts")
tasks.register<CreateSampleTask>("createSample") {
description = "Generates a new compose-first camera sample for the Camera Samples Catalog"
group = "generation"

sampleName.set(providers.gradleProperty("sampleName"))
screenName.set(providers.gradleProperty("screenName"))
title.set(providers.gradleProperty("title"))
desc.set(providers.gradleProperty("desc"))
type.set(providers.gradleProperty("type"))
rootDirPath.set(rootDir.absolutePath)
}

// Dagger/Hilt 2.57+ unshades kotlin-metadata-jvm, so it can be overridden independently. Force it to
// match the Kotlin compiler (2.4.0) — otherwise the Hilt aggregating processor (hiltJavaCompileDebug)
Expand Down
8 changes: 8 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
`kotlin-dsl`
}

repositories {
google()
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import org.gradle.api.tasks.TaskAction
* -Ptitle="Camera2 • Flash" \
* -Pdesc="Toggle the flash with Camera2" \
* -Ptype="camera2" # camera2 (default) or camerax
*
* It generates a compose-first module (UiState / ViewModel / Controller / Screen) that already
* shows a working camera preview behind CameraSampleScaffold, then registers it in
* settings.gradle.kts, app/build.gradle.kts, strings.xml and SampleCatalog.kt.
*/
abstract class CreateSampleTask : DefaultTask() {
@get:Input
Expand Down Expand Up @@ -107,7 +103,7 @@ abstract class CreateSampleTask : DefaultTask() {
File(sampleDir, "proguard-rules.pro").writeText(
"# Add project specific ProGuard rules here.\n" +
"# By default, the flags in this file are appended to flags specified\n" +
"# in \$ANDROID_SDK/tools/proguard/proguard-android.txt\n",
"# in ${'$'}ANDROID_SDK/tools/proguard/proguard-android.txt\n",
)

File(srcDir, "${base}UiState.kt").writeText(uiState(pkgName, base))
Expand All @@ -119,16 +115,6 @@ abstract class CreateSampleTask : DefaultTask() {
if (isCameraX) cameraXScreen(pkgName, base, scName) else camera2Screen(pkgName, base, scName),
)

// Per-sample string resources: keep user-facing text out of the Kotlin and in strings.xml.
val resValuesDir = File(sampleDir, "src/main/res/values")
resValuesDir.mkdirs()
File(resValuesDir, "strings.xml").writeText(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<resources>\n" +
" <!-- Add this sample's user-facing strings here; read them with stringResource(R.string.…). -->\n" +
"</resources>\n",
)

// settings.gradle.kts
val settingsFile = File(rootDirFile, "settings.gradle.kts")
val settingsText = settingsFile.readText()
Expand All @@ -142,8 +128,8 @@ abstract class CreateSampleTask : DefaultTask() {
if (!appBuildText.contains("implementation(project(\":samples:$sName\"))")) {
appBuildFile.writeText(
appBuildText.replace(
" implementation(project(\":core-theme\"))",
" implementation(project(\":core-theme\"))\n" +
" implementation(project(\":core-ui\"))",
" implementation(project(\":core-ui\"))\n" +
" implementation(project(\":samples:$sName\"))",
),
)
Expand Down Expand Up @@ -580,15 +566,3 @@ private fun BoxScope.PreviewingContent(onBack: () -> Unit) {
}
""".trimStart()
}

tasks.register<CreateSampleTask>("createSample") {
description = "Generates a new compose-first camera sample for the Camera Samples Catalog"
group = "generation"

sampleName.set(providers.gradleProperty("sampleName"))
screenName.set(providers.gradleProperty("screenName"))
title.set(providers.gradleProperty("title"))
desc.set(providers.gradleProperty("desc"))
type.set(providers.gradleProperty("type"))
rootDirPath.set(rootDir.absolutePath)
}
Loading