Skip to content

ADFA-2117 | Force KTS and hide checkbox in Compose Activity template#637

Merged
jatezzz merged 3 commits intostagefrom
feat/ADFA-2117-force-kts-for-compose-template
Nov 20, 2025
Merged

ADFA-2117 | Force KTS and hide checkbox in Compose Activity template#637
jatezzz merged 3 commits intostagefrom
feat/ADFA-2117-force-kts-for-compose-template

Conversation

@jatezzz
Copy link
Copy Markdown
Collaborator

@jatezzz jatezzz commented Nov 18, 2025

Description

This PR hides the "Use Kotlin Script (.kts)" checkbox exclusively for the Compose Activity template and forces useKts=true internally. The checkbox remains visible for all other templates. This ensures Compose projects always generate using Kotlin Script, preventing Groovy builds that would otherwise fail with the outdated offline Compose artifacts.

Details

The base template now supports a flag to control whether the checkbox is displayed. The Compose Activity template sets this flag to false and programmatically enables Kotlin Script, guaranteeing consistent project generation and avoiding user-triggered build errors.

Screen.Recording.2025-11-18.at.3.23.50.PM.mov

Ticket

ADFA-2117
Relates to: ADFA-1887

Observation

This is a targeted safeguard until the offline localMavenRepository is updated to compatible artifact versions.

…ctivity ensures Compose projects are generated with Kotlin Script only
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Nov 18, 2025

Greptile Summary

  • Adds conditional UI control to hide the "Use Kotlin Script (.kts)" checkbox specifically for the Compose Activity template while forcing KTS internally to prevent build failures with outdated offline Compose artifacts
  • Implements a showUseKts parameter in the base template system that defaults to true for backward compatibility, allowing templates to control checkbox visibility
  • Modifies the Compose Activity template to set showUseKts = false and automatically enable Kotlin Script, ensuring consistent project generation for Compose projects

Important Files Changed

Filename Overview
templates-api/src/main/java/com/itsaky/androidide/templates/base/base.kt Core template API modified to support conditional checkbox visibility with showUseKts parameter and automatic KTS enablement
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/composeActivity/composeActivityTemplate.kt Compose Activity template updated to hide KTS checkbox and force KTS usage by setting showUseKts = false

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it implements a targeted safeguard for a known build issue
  • Score reflects clean implementation with proper parameter defaulting and backward compatibility, but reduced due to potential regression risk if the automatic KTS forcing logic fails or if other templates inadvertently use the new parameter incorrectly
  • Pay close attention to templates-api/src/main/java/com/itsaky/androidide/templates/base/base.kt to ensure the conditional logic correctly handles edge cases where showUseKts is false

Sequence Diagram

sequenceDiagram
    participant User
    participant ProjectTemplate
    participant ProjectTemplateBuilder
    participant AndroidModuleTemplateBuilder
    participant RecipeExecutor

    User->>ProjectTemplate: "Create Compose Activity Project"
    ProjectTemplate->>ProjectTemplateBuilder: "baseProjectImpl(showUseKts=false, isToml=true)"
    ProjectTemplateBuilder->>ProjectTemplateBuilder: "Configure parameters (language=Kotlin only)"
    ProjectTemplateBuilder->>ProjectTemplateBuilder: "Setup preRecipe with ProjectTemplateData"
    ProjectTemplateBuilder->>AndroidModuleTemplateBuilder: "defaultAppModule(isComposeModule=true)"
    AndroidModuleTemplateBuilder->>RecipeExecutor: "createRecipe"
    RecipeExecutor->>RecipeExecutor: "composeDependencies()"
    RecipeExecutor->>RecipeExecutor: "writeXmlResource(themes)"
    RecipeExecutor->>RecipeExecutor: "writeMainActivity(composeActivitySrc)"
    RecipeExecutor->>RecipeExecutor: "writeKtSrc(Color, Theme, Type)"
    RecipeExecutor->>ProjectTemplateBuilder: "Recipe complete"
    ProjectTemplateBuilder->>ProjectTemplateBuilder: "postRecipe: buildGradle(), settingsGradle(), gradleProps()"
    ProjectTemplateBuilder->>User: "Compose project created"
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

@jatezzz jatezzz merged commit f6878b1 into stage Nov 20, 2025
2 checks passed
@jatezzz jatezzz deleted the feat/ADFA-2117-force-kts-for-compose-template branch November 20, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants