Skip to content

settings.gradle.kts: add support for subprojects.local.cfg#8074

Open
dconeybe wants to merge 5 commits intomainfrom
dconeybe/GradleLocalSubprojects
Open

settings.gradle.kts: add support for subprojects.local.cfg#8074
dconeybe wants to merge 5 commits intomainfrom
dconeybe/GradleLocalSubprojects

Conversation

@dconeybe
Copy link
Copy Markdown
Contributor

@dconeybe dconeybe commented Apr 29, 2026

Adds support for a subprojects.local.cfg file in the top-level directory that, if it exists, overrides subprojects.cfg, allowing local reduction in then number of gradle submodules in the project. This leads to noticeable improvements in devx due to faster local builds, snappier Android Studio performance, and less "noise" in Android Studio from unrelated code (e.g. in search results).

For example, in my local development of the dataconnect SDK I created subprojects.local.cfg with these lines:

firebase-dataconnect
firebase-dataconnect:androidTestutil
firebase-dataconnect:connectors
firebase-dataconnect:testutil
tools:lint # seems to be required or else the build fails 🤷🏻 

This reduced the number of Gradle submodules in my ./gradlew builds and in Android Studio by 93% (72 projects down to 5 projects). Anecdotally, this made builds faster and Android Studio wayyyyyy snappier, with fewer hangs (GC hangs?) and less visual clutter from code and modules that are not relevant to my daily work.

Highlights

  • Introduced subprojects.local.cfg as an optional local override for subprojects.cfg, enabling developers to load a subset of submodules for faster builds and improved IDE performance.
  • Refactored settings.gradle.kts to use a robust file-reading mechanism that prioritizes local configuration and provides helpful logging.
  • Updated .gitignore to ensure that subprojects.local.cfg remains a local-only configuration and is not committed to the repository.

Changelog

2 files affected
  • .gitignore: Added subprojects.local.cfg to the ignored files.
  • settings.gradle.kts: Implemented logic to prioritize subprojects.local.cfg over subprojects.cfg and refactored subproject discovery to handle string-based file contents.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@dconeybe
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new utility functions in settings.gradle.kts to manage subprojects, allowing for local overrides via subprojects.local.cfg. The .gitignore file is updated to include /subprojects.local.cfg. The review suggests refactoring the exception handling in readSubprojectsFile to use the standard error() function and simplifying the parsing logic in discoverSubprojects using more idiomatic Kotlin constructs like substringBefore and takeIf.

Comment thread settings.gradle.kts Outdated
Comment thread settings.gradle.kts
…c string filtering

Changed

```
return subprojectsFileContents
  .lines()
  .mapNotNull { it.split("#").firstOrNull()?.trim() }
  .filter { it.isNotEmpty() }
```

to

```
return subprojectsFileContents.lines().mapNotNull { line ->
  line.substringBefore('#').trim().takeIf { it.isNotEmpty() }
}
```
@dconeybe dconeybe marked this pull request as ready for review April 30, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant