Skip to content

Conversation

takahirom
Copy link
Owner

@takahirom takahirom commented Aug 22, 2025

What

Fixes cross-variant task dependency error in AGP 8.12+ by separating output directories per variant.

Why

  • GitHub Issue AGP 8.12 composePreviewRoboelectricTest #732: KSP tasks for different variants (Debug/Release) were accessing shared generated source directories
  • AGP 8.12+ stricter task dependency validation caused build failures
  • TDD test now passes (100% success rate)

Summary by CodeRabbit

  • New Features

    • Generated preview Robolectric tests are now created per build variant and stored in variant-specific directories (e.g., one folder per variant), improving organization and preventing cross-variant file collisions.
  • Chores

    • Adjusted generation paths to align outputs with build variants without altering other task behaviors.
    • No changes to public APIs or configuration options.

Copy link

coderabbitai bot commented Aug 22, 2025

Walkthrough

Output directory for GenerateComposePreviewRobolectricTestsTask changed from a shared path to a per-variant path: generated/roborazzi/preview-screenshot/${variant.name}. No other task properties were modified.

Changes

Cohort / File(s) Summary of Changes
Per-variant output directory
include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/GenerateComposePreviewRobolectricTestsExtension.kt
Set task outputDir to generated/roborazzi/preview-screenshot/${variant.name} instead of a single shared directory.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Developer
    participant Gradle
    participant Task as GenerateComposePreviewRobolectricTestsTask
    participant FS as FileSystem

    Developer->>Gradle: Run build (assemble/test)
    Gradle->>Task: Configure for each variant
    Note over Task: Changed: outputDir = generated/roborazzi/preview-screenshot/${variant.name}
    Gradle->>Task: Execute per variant
    Task->>FS: Write generated tests/screenshots to per-variant directory
    FS-->>Task: Files created
    Task-->>Gradle: Task completed per variant
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • sergio-sastre

Poem

In burrows of builds where variants play,
I hop between folders, tidy as day.
Each path now labeled, neat as a nib,
No more collisions—just carrot and crib.
Thump-thump! Screenshots in lanes so bright,
Per-variant warrens, sorted right. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tm/fix-cross-variant-ksp-dependency

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 0

🧹 Nitpick comments (1)
include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/GenerateComposePreviewRobolectricTestsExtension.kt (1)

106-113: Optional: align directory with Gradle “generated/source” convention

Not required for correctness, but placing generated code under a conventional path can improve IDE/tooling expectations.

Proposed change (only if it doesn’t conflict with existing consumer assumptions):

-    it.outputDir.set(project.layout.buildDirectory.dir("generated/roborazzi/preview-screenshot/${variant.name}"))
+    it.outputDir.set(project.layout.buildDirectory.dir("generated/source/roborazzi/${variant.name}"))
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b18ac1c and 786f634.

📒 Files selected for processing (1)
  • include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/GenerateComposePreviewRobolectricTestsExtension.kt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: test
  • GitHub Check: store-screenshot-test
  • GitHub Check: report
  • GitHub Check: compare-screenshot-test
  • GitHub Check: build
  • GitHub Check: ollama-test
  • GitHub Check: test
🔇 Additional comments (3)
include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/GenerateComposePreviewRobolectricTestsExtension.kt (3)

106-113: Per-variant outputDir fixes AGP 8.12+ cross-variant overlap — good change

Scoping the generated tests to "generated/roborazzi/preview-screenshot/${variant.name}" removes output/input sharing between Debug/Release and aligns with AGP’s stricter task dependency validation. This should prevent concurrent variant builds from clobbering each other and satisfy validation.


106-113: No remaining references to the old shared path detected
I ran a global search for “generated/roborazzi/preview-screenshot” across non-build files and only found its intended use in GenerateComposePreviewRobolectricTestsExtension.kt (lines 106–108). There are no stray hard-coded occurrences elsewhere in the plugin. All variant-scoped task invocations also correctly pass the per-variant output directory.


120-123: No cross-variant coupling detected: testTaskProvider is variant-scoped

The testTaskProvider passed into the extension is created via

project.tasks.withType(Test::class.java)
    .matching { it.name == testTaskName }

where testTaskName is computed per-variant as "test" + unitTest.name.capitalizeUS() (e.g. "testDebugUnitTest"). This ensures only the current variant’s Test task is selected, so configuring its inputs directory cannot accidentally wire in other variants’ tasks.

– No changes required here; resolving this comment.

@takahirom takahirom merged commit 02c1456 into tm/reproduce-github-issue-732 Aug 22, 2025
8 checks passed
@takahirom takahirom deleted the tm/fix-cross-variant-ksp-dependency branch August 22, 2025 22:47
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.

1 participant