Skip to content

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

Merged
hal-eisen-adfa merged 6 commits into
stagefrom
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 into
stagefrom
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

coderabbitaiBot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

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 nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
Title check✅ PassedThe 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✅ PassedThe 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.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

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

Comment threadcommon/src/main/java/com/itsaky/androidide/utils/Environment.java Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

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 teamApril 8, 2026 01:38

@jatezzzjatezzz left a comment

Copy link
Copy Markdown
Collaborator

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 stageApr 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
jatezzz pushed a commit that referenced this pull request Jun 22, 2026
* Rename .androidide/ to .cg/ in multiple locations
* Add error handling for migrating legacy .androidide/ to modern .cg/
* Reduce complexity of LegacyIdeDataDirMigration()
davidschachterADFA added a commit that referenced this pull request Aug 26, 2026
)
The task copied tooling-api-model.jar to <root>/tests/test-home/.cg/init/model.jar.
Nothing reads that file, and nothing reads that directory.
The only consumer of a "test home" is gradle-plugin's test helper, which resolves
FileProvider.testHomeDir() -- testing/resources/test-home, a different directory
-- and then *writes its own* init script there, with a classpath from Gradle's
PluginUnderTestMetadataReading. It never asks for a model jar. A grep for
model.jar across the repo returned only the task that produced it.
The destination had drifted before: 2a84174 (Feb 2023) is "fix: invalid path
specified in copyToTestDir", and #1161 renamed .androidide to .cg inside it.
Removing it takes three problems with it:
- into(rootProject.mkdir(...)) ran at configuration time, so merely realizing the
task created directories in the source tree -- on --dry-run, and again after
every clean. That is why tests/test-home kept reappearing.
- outputs.upToDateWhen { false } on both the copy and jar meant any build
touching this module re-jarred and re-copied unconditionally.
- Its output being a directory inside the source tree is what tripped Gradle's
implicit-dependency validation against Spotless (ADFA-5244). That was worked
around at the consumer by excluding the directory from the Spotless walk.
Verified: the jar still builds; tests/ is no longer created at configuration
time; :app:assembleV8Debug succeeds with the task absent from the graph; and
`:common:compileV8DebugKotlin spotlessCheck` -- the exact invocation ADFA-5244
was filed for -- now passes on this branch, which carries no Spotless exclude at
all. The two .gitignore entries that existed only for this task's output go too.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
davidschachterADFA added a commit that referenced this pull request Aug 28, 2026
)
* ADFA-5263: Delete copyToTestDir, which copied a jar nothing reads
The task copied tooling-api-model.jar to <root>/tests/test-home/.cg/init/model.jar.
Nothing reads that file, and nothing reads that directory.
The only consumer of a "test home" is gradle-plugin's test helper, which resolves
FileProvider.testHomeDir() -- testing/resources/test-home, a different directory
-- and then *writes its own* init script there, with a classpath from Gradle's
PluginUnderTestMetadataReading. It never asks for a model jar. A grep for
model.jar across the repo returned only the task that produced it.
The destination had drifted before: 2a84174 (Feb 2023) is "fix: invalid path
specified in copyToTestDir", and #1161 renamed .androidide to .cg inside it.
Removing it takes three problems with it:
- into(rootProject.mkdir(...)) ran at configuration time, so merely realizing the
task created directories in the source tree -- on --dry-run, and again after
every clean. That is why tests/test-home kept reappearing.
- outputs.upToDateWhen { false } on both the copy and jar meant any build
touching this module re-jarred and re-copied unconditionally.
- Its output being a directory inside the source tree is what tripped Gradle's
implicit-dependency validation against Spotless (ADFA-5244). That was worked
around at the consumer by excluding the directory from the Spotless walk.
Verified: the jar still builds; tests/ is no longer created at configuration
time; :app:assembleV8Debug succeeds with the task absent from the graph; and
`:common:compileV8DebugKotlin spotlessCheck` -- the exact invocation ADFA-5244
was filed for -- now passes on this branch, which carries no Spotless exclude at
all. The two .gitignore entries that existed only for this task's output go too.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5244: Stop Spotless walking the tool-generated tests/test-home
tooling-api-model:copyToTestDir writes a jar into tests/test-home, which lives
in the source tree, so root spotlessJava's fileTree(rootDir) consumed another
task's output. Gradle's validation then failed any invocation that both compiled
and checked formatting -- the combination you run before pushing.
spotlessCheck alone always passed, because copyToTestDir never entered the
graph. That is what made this read as "my change broke Spotless".
traversalExcludes already exists for exactly this, and its comment carries the
rule this needs: a bare directory name so Gradle prunes the subtree instead of
descending and filtering.
Verified: the failing invocation
(:common:compileV8DebugAndroidTestKotlin spotlessCheck) now succeeds; nothing is
tracked under tests/ so no real source is hidden; and an injected 4-space indent
still fails spotlessKotlinGradleCheck, so the check remains effective.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5244: Exclude all of tests/, and make CI able to catch a regression
Review found three things worth acting on here.
The exclude was anchored to tests/test-home while .gitignore reserves
tests/**/.cg/init/model.jar -- so a sibling generated directory would reintroduce
the identical failure. Nothing under tests/ is tracked at all, so the whole
subtree goes.
The comment three lines above said "bare dir names required", which the new
rooted entry appeared to violate. The real rule is that the pattern must match
the directory node itself, rooted or bare; a bare name additionally matches that
name at any depth, which is why "tests" is rooted here -- "test-home" would also
prune testing/resources/test-home, the directory FileProvider.testHomeDir()
actually points at.
CI could not have caught a regression of this: it ran spotlessCheck standalone,
the one invocation that always passed, because copyToTestDir never enters that
graph. The step now runs a compile task in the same invocation, which is the
combination that fails.
What this PR still does not fix is the cause: copyToTestDir writes a jar nothing
reads, into the source tree, from a configuration-time mkdir. That is ADFA-5263.
Fixing it there would make this exclude unnecessary rather than permanent.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5244: Drop the exclude; ADFA-5263 removed what it was hiding
The exclude existed because copyToTestDir wrote a jar into tests/test-home
inside the source tree, which made Spotless consume another task's output. That
task is deleted in ADFA-5263, so nothing creates the directory and there is
nothing to prune -- keeping the exclude would leave a permanent workaround for a
problem that no longer exists.
What stays is the part that is worth keeping either way: the CI step that runs a
compile task in the same invocation as spotlessCheck. CI ran spotlessCheck
standalone, which is the one invocation that can never reproduce this class of
failure, so any regression was invisible to it by construction.
The comment above traversalExcludes also stays corrected: the rule is that a
pattern must match the directory node itself, and a bare name matches that name
at any depth -- "test-home" would have pruned testing/resources/test-home too.
This branch is now based on ADFA-5263 rather than stage, because without that
fix removing the exclude reintroduces the failure -- verified both ways.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5244: Say what Gradle exclude patterns actually do
The comment this PR added claimed a bare exclude name "also matches that
name at any depth". It does not -- bare names are root-anchored, so
exclude("flox") prunes rootDir/flox and nothing else. Verified with a
probe project: with tests/ and testing/resources/test-home/ present,
exclude("tests") leaves a/tests/x untouched and exclude("test-home")
matches nothing at all.
That made the array's own **/ prefixes look redundant, so the comment
invited exactly the wrong simplification: reading "**/.gradle" as
equivalent to ".gradle" stops pruning every per-project cache dir and
brings back the ADFA-4816 12-minute spotlessCheck. The comment it
replaced ("Bare dir names required") had it right.
Also drops the reference to a "tests" entry, which commit 3d62974
removed, and the test-home example, which was inverted -- a bare
"test-home" is not dangerously broad, it is silently narrow.
Found in review of PR #1730.
* ADFA-5244: Keep ignoring tests/test-home, which the tests still fill
Dropping both entries went one too far. The model.jar line is dead --
ADFA-5263 deleted the task that wrote it -- but the directory is not.
writeInitScript() in gradle-plugin/src/test/.../utils.kt resolves
FileProvider.testHomeDir() and creates .cg/init/androidide.init.gradle
on every run of :gradle-plugin:test. That is a test writing a file at
execution time, not a Gradle task declaring an output, so it never
triggers the implicit-dependency validation this branch is about -- it
just leaves "?? tests/" in git status after a test run, in a tree where
nothing under tests/ is tracked.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M4sTwYg47aK8VB9kRKZicU
* ADFA-5244: Stop the combined step blaming Spotless for a compile error
Adding the compile task to this step gave it two possible causes, but
the failure message still named only one -- and told the developer to run
spotlessApply, which cannot fix a compile error. That is precisely the
misdiagnosis the step exists to catch, so it should not commit it itself.
The message now names the invocation rather than a cause, and says which
half spotlessApply can help with. The exit status propagates instead of a
hard-coded 1, so a Gradle exit code survives into the job.
Verified: the YAML parses, `bash -n` accepts the run block, and a
simulated failure returning 3 now exits 3 rather than 1.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M4sTwYg47aK8VB9kRKZicU
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for freeto 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

@hal-eisen-adfa@jatezzz