Skip to content

Refactor gradle build protocols and fix time interval bug for overnight hours of eateries#147

Open
RyanCheung555 wants to merge 4 commits intomainfrom
ryan/refactor-gradle-build
Open

Refactor gradle build protocols and fix time interval bug for overnight hours of eateries#147
RyanCheung555 wants to merge 4 commits intomainfrom
ryan/refactor-gradle-build

Conversation

@RyanCheung555
Copy link
Copy Markdown
Contributor

@RyanCheung555 RyanCheung555 commented Apr 29, 2026

Overview

  • Gradle builds use different variables in secrets.properties depending on the build
  • Small bug fix with eatery hours

Changes Made

  • Using ksp instead of KAPT for annotation processors
  • Update secrets.properties and how build variants read from secrets file
  • Update how time intervals that go past 12am are handled

Test Coverage

  • Manual testing on Medium phone and switching builds
  • Checking if RPCC/Louies/Jansens are shown as open, and shown as open after 12am

Related PRs or Issues

Screenshots

Screenshot taken after 12am image

Summary by CodeRabbit

  • Bug Fixes

    • Fixed business hours status calculation to correctly determine opening/closing times across midnight boundaries.
  • Chores

    • Modernized build system and tooling, including migration to newer annotation processing and updated build plugins for improved stability.
    • Added packaging and optimization tweaks to improve app performance and build reliability.
    • Updated ignore rules to exclude local signing/configuration and build artifacts.
  • Behavior

    • Disabled automatic profile installer to control profile handling within the app.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 583784a6-46c6-4949-bfa5-6c4615a45a16

📥 Commits

Reviewing files that changed from the base of the PR and between 46d1753 and 71dc7cb.

📒 Files selected for processing (3)
  • app/build.gradle.kts
  • app/src/main/java/com/cornellappdev/transit/util/TimeUtils.kt
  • gradle.properties
✅ Files skipped from review due to trivial changes (1)
  • gradle.properties
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/src/main/java/com/cornellappdev/transit/util/TimeUtils.kt
  • app/build.gradle.kts

📝 Walkthrough

Walkthrough

This PR replaces Gradle secrets-plugin with explicit properties loading, migrates annotation processing from KAPT to KSP, updates top-level plugins (Kotlin/Compose/KSP/Apollo), adds signing/App Bundle handling and .gitignore entries, disables AndroidX Profile Installer in the manifest, and refactors TimeUtils to handle overnight intervals via LocalDateTime.

Changes

Cohort / File(s) Summary
Top-level Gradle & Ignore
build.gradle.kts, gradle.properties, .gitignore
Added Compose compiler, KSP, Kotlin serialization 2.0.21, and Apollo plugin declarations (apply false); added commented org.gradle.java.home guidance; updated .gitignore to exclude signing.properties, *.aab, and navi-keystore.
App build script
app/build.gradle.kts
Replaced secrets-plugin + KAPT wiring with explicit Properties loading and helper functions; injects MAPS_KEY, variant-specific BACKEND_URL/EATERY_URL/UPLIFT_URL into BuildConfig and manifest placeholders; conditional signingConfigs.release when signing.properties present; enabled buildConfig generation, baseline profile settings, packaging exclusions; migrated from KAPT to KSP and reorganized dependency declarations.
Android Manifest
app/src/main/AndroidManifest.xml
Added <meta-data android:name="androidx.profileinstaller.enabled" android:value="false"/> to application manifest.
Time utilities
app/src/main/java/com/cornellappdev/transit/util/TimeUtils.kt
Refactored getOpenStatus to compute concrete LocalDateTime intervals for today's ranges and prior-day overnight ranges so open/close and "until"/"opens" times are correct across midnight boundaries.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibble at midnight code and cheer,
Properties found and KSP draws near,
Keys tuck into builds, profiles take flight,
Overnight hours now behave just right,
Hooray — a rabbit's small delight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the two main changes: Gradle build refactoring and a time interval bug fix for overnight eatery hours.
Description check ✅ Passed The description covers Overview, Changes Made, and Test Coverage sections with sufficient detail about KSP migration, secrets.properties handling, and overnight interval fixes. Screenshots provide verification.
Linked Issues check ✅ Passed The PR successfully addresses issue #146 by fixing the overnight hours bug in TimeUtils.kt, where eateries like RPCC now correctly show as open past midnight with proper interval handling.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives: KSP migration, secrets.properties variant handling, and overnight interval fixes. No unrelated modifications detected.

✏️ 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 ryan/refactor-gradle-build

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

Copy link
Copy Markdown

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

🧹 Nitpick comments (2)
app/build.gradle.kts (2)

80-117: Reduce duplicated build-type URL wiring to avoid config drift.

BACKEND_URL/EATERY_URL/UPLIFT_URL setup is repeated in debug, ecosystem, and release. Consider a small helper that takes a prefix (DEBUG/PROD) and applies all related fields/placeholders once.

Also applies to: 132-147

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/build.gradle.kts` around lines 80 - 117, The debug/ecosystem/release
blocks duplicate wiring of BACKEND_URL/EATERY_URL/UPLIFT_URL and
manifestPlaceholders; extract a helper function (e.g.,
configureUrlsForVariant(prefix: String, target:
com.android.build.gradle.internal.dsl.BuildType) or an extension on
DefaultConfig/BuildType) that calls buildConfigField("String", "BACKEND_URL",
asBuildConfigString(secretsProperties.requireString("${prefix}_BACKEND_URL"))),
manifestPlaceholders["BACKEND_URL"] = asManifestPlaceholder(...), and similar
for EATERY_URL and UPLIFT_URL, then call that helper from the debug,
create("ecosystem") and release blocks (keep ECOSYSTEM_FLAG where needed) to
remove the repeated buildConfigField/manifestPlaceholders logic while still
using asBuildConfigString, asManifestPlaceholder and
secretsProperties.requireString.

13-16: Add an explicit existence check for secrets.properties with a clear error.

Current load path fails with a generic exception if the file is absent. A pre-check with a targeted message will make local setup and CI failures easier to diagnose.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/build.gradle.kts` around lines 13 - 16, The code currently attempts to
load secrets.properties without checking existence; update the block around
secretsPropertiesFile and secretsProperties to first check
secretsPropertiesFile.exists() and throw a clear Gradle error (e.g., throw
GradleException or error("secrets.properties not found: ...")) with guidance
about creating the file or pointing to CI secrets, before calling
secretsPropertiesFile.inputStream().use(::load); keep the Properties().apply
pattern but move the existence guard so the load only runs when the file is
present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/build.gradle.kts`:
- Around line 68-75: In the signingConfigs create("release") block, replace the
unsafe signingProperties["..."].toString() calls with the requireString() helper
so missing keys fail fast; specifically use
signingProperties.requireString("KEYSTORE_PATH"),
requireString("KEYSTORE_PASSWORD"), requireString("KEY_ALIAS"), and
requireString("KEY_PASSWORD") when assigning
storeFile/storePassword/keyAlias/keyPassword in the create("release") block to
match how secretsProperties is handled.

In `@app/src/main/java/com/cornellappdev/transit/util/TimeUtils.kt`:
- Around line 238-248: The early return when todaySchedule contains "Closed" can
incorrectly treat a venue as closed even if a yesterday overnight interval spans
into the current date; to fix, compute yesterdayOvernightIntervals (using
buildIntervalsForDate with overnightOnly = true and
rotatedOperatingHours.last().hours) and check whether any of those intervals
contain the current date/time before doing the closed-day fallback
(findOpenNextDay); if an overnight interval covers currentDateTime, proceed with
normal open/interval handling instead of returning findOpenNextDay.

In `@gradle.properties`:
- Around line 27-28: Remove the machine-specific org.gradle.java.home entry from
gradle.properties (the hardcoded /Applications/Android Studio... path) so the
repo no longer pins a local macOS JDK; instead delete or comment out the
org.gradle.java.home line and document that contributors should set this in
their user ~/.gradle/gradle.properties or rely on Gradle toolchains / JAVA_HOME.
Ensure no replacement hardcoded path is committed and update any README or CI
config to indicate how to configure JAVA_HOME or toolchain if needed.

---

Nitpick comments:
In `@app/build.gradle.kts`:
- Around line 80-117: The debug/ecosystem/release blocks duplicate wiring of
BACKEND_URL/EATERY_URL/UPLIFT_URL and manifestPlaceholders; extract a helper
function (e.g., configureUrlsForVariant(prefix: String, target:
com.android.build.gradle.internal.dsl.BuildType) or an extension on
DefaultConfig/BuildType) that calls buildConfigField("String", "BACKEND_URL",
asBuildConfigString(secretsProperties.requireString("${prefix}_BACKEND_URL"))),
manifestPlaceholders["BACKEND_URL"] = asManifestPlaceholder(...), and similar
for EATERY_URL and UPLIFT_URL, then call that helper from the debug,
create("ecosystem") and release blocks (keep ECOSYSTEM_FLAG where needed) to
remove the repeated buildConfigField/manifestPlaceholders logic while still
using asBuildConfigString, asManifestPlaceholder and
secretsProperties.requireString.
- Around line 13-16: The code currently attempts to load secrets.properties
without checking existence; update the block around secretsPropertiesFile and
secretsProperties to first check secretsPropertiesFile.exists() and throw a
clear Gradle error (e.g., throw GradleException or error("secrets.properties not
found: ...")) with guidance about creating the file or pointing to CI secrets,
before calling secretsPropertiesFile.inputStream().use(::load); keep the
Properties().apply pattern but move the existence guard so the load only runs
when the file is present.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2c71698-9682-455f-8c8a-ad9d307cdd87

📥 Commits

Reviewing files that changed from the base of the PR and between d1e2a3b and 46d1753.

📒 Files selected for processing (7)
  • .gitignore
  • app/build.gradle.kts
  • app/release/app-release.aab
  • app/src/main/AndroidManifest.xml
  • app/src/main/java/com/cornellappdev/transit/util/TimeUtils.kt
  • build.gradle.kts
  • gradle.properties

Comment thread app/build.gradle.kts
Comment thread app/src/main/java/com/cornellappdev/transit/util/TimeUtils.kt Outdated
Comment thread gradle.properties Outdated
Comment thread gradle.properties Outdated
android.defaults.buildfeatures.buildconfig=true

# Gradle JDK Configuration
org.gradle.java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 for coderabbit message. need to support window devs

<meta-data
android:name="BACKEND_URL"
android:value="${BACKEND_URL}" />
<meta-data
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we setting this to false?

Comment thread app/build.gradle.kts Outdated
create("ecosystem") {
initWith(getByName("debug"))
isDebuggable = true
buildConfigField(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

build config field for ecosystem is pretty much the same as debug, so we can consider making a helper

- Add explicit existence check for secrets.properties with clear error message
- Replace unsafe signing properties .toString() calls with requireString() helper
- Extract helper function to reduce duplicated build-type URL wiring
- Fix TimeUtils overnight interval logic to check yesterday's overnight intervals before early return for closed days
- Remove machine-specific org.gradle.java.home configuration from gradle.properties
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.

Rpcc never open

2 participants