Skip to content

ADFA-1639 Rename .androidide/ to .cg/ in multiple locations#1161

Merged
hal-eisen-adfa merged 6 commits intostagefrom
ADFA-1639-Change-.androidide-directory-to-.cg
Apr 9, 2026
Merged

ADFA-1639 Rename .androidide/ to .cg/ in multiple locations#1161
hal-eisen-adfa merged 6 commits intostagefrom
ADFA-1639-Change-.androidide-directory-to-.cg

Conversation

@hal-eisen-adfa
Copy link
Copy Markdown
Collaborator

Runtime and shared constants
SharedEnvironment.kt: PROJECT_CACHE_DIR_NAME = ".cg", LEGACY_PROJECT_CACHE_DIR_NAME = ".androidide". All derived paths (e.g. PROJECT_SYNC_CACHE_DIR) now use .cg.
LegacyIdeDataDir.kt: migrateLegacyIdeDataDirIfNeeded(legacy, current) — renames legacy → current when only legacy exists; if both exist, logs a warning and keeps the new dir.
Environment.java: Runs migration on files/home/ before creating ANDROIDIDE_HOME, uses SharedEnvironment.PROJECT_CACHE_DIR_NAME (no hardcoded .androidide). getProjectCacheDir runs the same migration per project.

Build constants
constants.kt: IDE_DATA_DIR_NAME = ".cg" and ANDROIDIDE_HOME built from it so plugin paths stay aligned with the app.

Host tooling / ignores
subprojects/tooling-api-model/build.gradle.kts: copy target tests/test-home/.cg/init.
gradle-plugin/.../utils.kt: init script path uses SharedEnvironment.PROJECT_CACHE_DIR_NAME.
.gitignore: tests/**/.cg/init/model.jar.
layouteditor/.gitignore: .cg/.

Strings
All values / values-* strings.xml: /home/.androidide → /home/.cg, $HOME/.androidide → $HOME/.cg.
Hindi: fixed package typo com.itsaky.android → com.itsaky.androidide.
Arabic: fixed font path prefix to /data/data/com.itsaky.androidide/....

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eded87af-d630-4d90-81eb-5f2cbc209a78

📥 Commits

Reviewing files that changed from the base of the PR and between 17f795a and a0afb0b.

📒 Files selected for processing (1)
  • common/src/main/java/com/itsaky/androidide/utils/LegacyIdeDataDirMigration.java

📝 Walkthrough
  • Core change: Rename project/IDE data directory from .androidide → .cg across runtime/shared constants, build constants, host tooling, VCS ignores, and user-facing strings.

  • Shared constants:

    • SharedEnvironment.PROJECT_CACHE_DIR_NAME changed to ".cg".
    • Added SharedEnvironment.LEGACY_PROJECT_CACHE_DIR_NAME = ".androidide".
  • Migration:

    • Added LegacyIdeDataDirMigration.migrateLegacyIdeDataDirIfNeeded(File legacy, File current) to perform a one-time migration:
      • If only legacy exists → attempts legacy.renameTo(current) and returns current on success (falls back to legacy on rename failure).
      • If both exist → logs a warning and returns current (new) directory.
      • If neither exists → returns current so callers may create it.
    • Environment.init and Environment.getProjectCacheDir call the migration so per-home and per-project data migrate on first access; code ensures the resolved IDE home is created when needed and avoids crash on rename failure.
  • Build constants:

    • Added IDE_DATA_DIR_NAME = ".cg".
    • ANDROIDIDE_HOME now built using IDE_DATA_DIR_NAME (no hardcoded ".androidide").
  • Host tooling / tests:

    • tooling-api-model build task now places model.jar into tests/test-home/.cg/init.
    • gradle-plugin test utilities construct init-script path using SharedEnvironment.PROJECT_CACHE_DIR_NAME (so tests use .cg).
  • VCS ignores:

    • .gitignore and layouteditor/.gitignore updated to ignore .cg paths (replacing .androidide).
  • Strings & localization:

    • Many locales (default and locale-specific values/*) updated to reference .cg in examples for font and log paths (e.g., /data/.../files/home/.cg/ui/font.ttf and $HOME/.cg/logs).
    • Hindi strings: fixed package typo com.itsaky.android → com.itsaky.androidide.
    • Arabic strings: fixed font path prefix to include /data/data/com.itsaky.androidide/... .
  • Public/API surface:

    • Added public class com.itsaky.androidide.utils.LegacyIdeDataDirMigration with a public static migrateLegacyIdeDataDirIfNeeded(File, File).
    • Added IDE_DATA_DIR_NAME constant (public) in build constants.
  • Risks / best-practice notes:

    • ⚠️ Migration robustness: rename can fail on some filesystems, mounts, or permission scenarios. On failure the code falls back to using the legacy directory (avoids data loss) but failure reporting is limited; add broader testing across device/storage setups and consider clearer user-facing error reporting.
    • ⚠️ Coexistence ambiguity: when both legacy and new dirs exist the code prefers the new dir and only logs a warning — operators may need explicit guidance or a safer merge/alert process.
    • ⚠️ Breakage risk: any external tooling, CI, scripts, plugins, or user workflows that hard-code ".androidide" will break; coordinate communications and update downstream consumers (docs, scripts, CI).
    • ⚠️ Coverage risk: verify there are no remaining references to ".androidide" in docs, build scripts, third-party configs, or external repositories.
    • ✓ Backwards compatibility: in-place migration aims to preserve existing data and enable seamless upgrades where rename succeeds.
  • Commit/implementation notes:

    • Migration logic simplified (refactor) and added defensive handling to avoid crashes and to fall back to legacy data on rename failure.

Walkthrough

The PR renames the app's internal IDE data directory from .androidide to .cg, adds a one-time migration helper to move legacy data, and updates constants, environment initialization, build/test artifact paths, .gitignore entries, and localized strings that referenced the old path.

Changes

Cohort / File(s) Summary
Core constants
shared/src/main/java/com/itsaky/androidide/utils/SharedEnvironment.kt, composite-builds/build-deps-common/constants/src/main/java/org/adfa/constants/constants.kt
Renamed project/IDE data dir constant from ".androidide"".cg", added LEGACY_PROJECT_CACHE_DIR_NAME = ".androidide", and introduced IDE_DATA_DIR_NAME used by ANDROIDIDE_HOME.
Environment & migration
common/src/main/java/com/itsaky/androidide/utils/Environment.java, common/src/main/java/com/itsaky/androidide/utils/LegacyIdeDataDirMigration.java
Added LegacyIdeDataDirMigration.migrateLegacyIdeDataDirIfNeeded(legacy,current) and updated Environment to resolve/migrate legacy dir before creating/using the new .cg locations.
Build, tests & artifacts
subprojects/tooling-api-model/build.gradle.kts, gradle-plugin/src/test/java/com/itsaky/androidide/gradle/utils.kt
Adjusted copy task and test init-script lookup to place/read init files under .../.cg/init instead of .../.androidide/init.
VCS ignore patterns
.gitignore, layouteditor/.gitignore
Replaced ignore entries targeting .androidide with .cg.
Localized resources
resources/src/main/res/values*/strings.xml (multiple locales incl. default)
Updated idepref_customFont_summary and idepref_devOptions_dumpLogs_summary across locales to reference .cg paths instead of .androidide.
Tooling artifact placement
tooling-api-model copy task (build script)
Changed destination for model.jar to tests/test-home/.cg/init (was .androidide).

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Env as Environment
    participant Legacy as LegacyIdeDataDirMigration
    participant FS as FileSystem

    App->>Env: init(context)
    Env->>Env: build candidate path (HOME/.cg)
    Env->>Env: build legacy path (HOME/.androidide)
    Env->>Legacy: migrateLegacyIdeDataDirIfNeeded(legacy, current)
    Legacy->>FS: check existence (current, legacy)
    alt current exists
        Legacy-->>Env: return current
    else legacy exists and current missing
        Legacy->>FS: rename legacy -> current
        alt rename success
            Legacy-->>Env: return current
        else rename failed
            Legacy-->>Env: return legacy
        end
    else neither exists
        Legacy-->>Env: return current
    end
    Env->>FS: mkdirIfNotExists(resolved current)
    Env-->>App: set ANDROIDIDE_HOME to resolved directory
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested reviewers

  • itsaky-adfa
  • Daniel-ADFA

Poem

🐰 I hopped from .androidide to .cg,
I nudged old nests so nothing would fray,
I moved jars, strings, tests with care,
A tidy home for files to stay — hooray! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: renaming .androidide/ to .cg/ across multiple locations, which is the primary objective of this PR.
Description check ✅ Passed The description comprehensively details all major changes across runtime constants, build configuration, tooling, ignores, and localized strings, directly corresponding to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-1639-Change-.androidide-directory-to-.cg

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@common/src/main/java/com/itsaky/androidide/utils/Environment.java`:
- Around line 130-133: The build fails because the Kotlin function
LegacyIdeDataDirKt.migrateLegacyIdeDataDirIfNeeded(File, File) is referenced but
missing; add a Kotlin file in the same package that declares a top-level
function migrateLegacyIdeDataDirIfNeeded(legacy: File, current: File) (matching
the Java call LegacyIdeDataDirKt.migrateLegacyIdeDataDirIfNeeded) and implement
the migration behavior (or a safe no-op/stub that logs and returns) so the
symbol resolves; ensure the Kotlin file's package matches the Java callers and
the function signature and visibility are public so the Java code in
Environment.java can call it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c76300d0-95e4-4e48-929d-517e53bc63a5

📥 Commits

Reviewing files that changed from the base of the PR and between daaccab and c3b7c17.

📒 Files selected for processing (20)
  • .gitignore
  • common/src/main/java/com/itsaky/androidide/utils/Environment.java
  • composite-builds/build-deps-common/constants/src/main/java/org/adfa/constants/constants.kt
  • gradle-plugin/src/test/java/com/itsaky/androidide/gradle/utils.kt
  • layouteditor/.gitignore
  • resources/src/main/res/values-ar-rSA/strings.xml
  • resources/src/main/res/values-bn-rIN/strings.xml
  • resources/src/main/res/values-de-rDE/strings.xml
  • resources/src/main/res/values-es-rES/strings.xml
  • resources/src/main/res/values-fr-rFR/strings.xml
  • resources/src/main/res/values-hi-rIN/strings.xml
  • resources/src/main/res/values-in-rID/strings.xml
  • resources/src/main/res/values-pt-rBR/strings.xml
  • resources/src/main/res/values-ro-rRO/strings.xml
  • resources/src/main/res/values-ru-rRU/strings.xml
  • resources/src/main/res/values-tr-rTR/strings.xml
  • resources/src/main/res/values-zh-rCN/strings.xml
  • resources/src/main/res/values/strings.xml
  • shared/src/main/java/com/itsaky/androidide/utils/SharedEnvironment.kt
  • subprojects/tooling-api-model/build.gradle.kts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@common/src/main/java/com/itsaky/androidide/utils/LegacyIdeDataDirMigration.java`:
- Around line 48-50: Change the migration method in LegacyIdeDataDirMigration so
it returns the actual directory to use (File) instead of void: detect if
legacy.exists() and attempt legacy.renameTo(current); if renameTo succeeds
return current, otherwise return legacy (and log the failure). Update callers
getProjectCacheDir() and init() to accept/use the returned File from that
migration method rather than unconditionally using the hardcoded current path so
they will fall back to legacy when migration fails (adjust calls to
mkdirIfNotExists to operate on the returned File).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17912b39-2502-477d-b63f-167704f8d2ff

📥 Commits

Reviewing files that changed from the base of the PR and between c3b7c17 and 7c4eac1.

📒 Files selected for processing (2)
  • common/src/main/java/com/itsaky/androidide/utils/Environment.java
  • common/src/main/java/com/itsaky/androidide/utils/LegacyIdeDataDirMigration.java
✅ Files skipped from review due to trivial changes (1)
  • common/src/main/java/com/itsaky/androidide/utils/Environment.java

@hal-eisen-adfa hal-eisen-adfa requested a review from a team April 8, 2026 01:38
Copy link
Copy Markdown
Collaborator

@jatezzz jatezzz left a comment

Choose a reason for hiding this comment

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

LGTM with a nitpick

@hal-eisen-adfa hal-eisen-adfa merged commit 80191ad into stage Apr 9, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the ADFA-1639-Change-.androidide-directory-to-.cg branch April 9, 2026 22:57
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