Uh oh!
There was an error while loading. Please reload this page.
ADFA-1639 Rename .androidide/ to .cg/ in multiple locations - #1161
Conversation
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 Walkthrough
WalkthroughThe PR renames the app's internal IDE data directory from Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (20)
.gitignorecommon/src/main/java/com/itsaky/androidide/utils/Environment.javacomposite-builds/build-deps-common/constants/src/main/java/org/adfa/constants/constants.ktgradle-plugin/src/test/java/com/itsaky/androidide/gradle/utils.ktlayouteditor/.gitignoreresources/src/main/res/values-ar-rSA/strings.xmlresources/src/main/res/values-bn-rIN/strings.xmlresources/src/main/res/values-de-rDE/strings.xmlresources/src/main/res/values-es-rES/strings.xmlresources/src/main/res/values-fr-rFR/strings.xmlresources/src/main/res/values-hi-rIN/strings.xmlresources/src/main/res/values-in-rID/strings.xmlresources/src/main/res/values-pt-rBR/strings.xmlresources/src/main/res/values-ro-rRO/strings.xmlresources/src/main/res/values-ru-rRU/strings.xmlresources/src/main/res/values-tr-rTR/strings.xmlresources/src/main/res/values-zh-rCN/strings.xmlresources/src/main/res/values/strings.xmlshared/src/main/java/com/itsaky/androidide/utils/SharedEnvironment.ktsubprojects/tooling-api-model/build.gradle.kts
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
common/src/main/java/com/itsaky/androidide/utils/Environment.javacommon/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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
* Rename .androidide/ to .cg/ in multiple locations * Add error handling for migrating legacy .androidide/ to modern .cg/ * Reduce complexity of LegacyIdeDataDirMigration()
) 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-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>
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/....