Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Android Gradle Build Tools, Java, compileSdk #70, #72 #76

Merged
merged 4 commits into from
Feb 24, 2025

Conversation

tuancoltech
Copy link
Member

@tuancoltech tuancoltech commented Feb 21, 2025

Upgrade

  • Android Gradle Build Tools to 8.5.2
  • Add Java 21 as an extra Java target to build in Github action script
  • Gradle wrapper to 8.12

Resolves #70 , #72

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Expanded continuous integration testing to run against multiple Java versions for enhanced build reliability.
    • Upgraded the underlying build tools to newer versions to boost performance and improve security checks.
  • Refactor
    • Refined script behaviors for both Unix and Windows environments, improving error detection and messaging for clearer troubleshooting.
    • Clarified method behavior in the HomeScreensActivity and MainActivity for better back navigation handling.

These updates strengthen the overall build system, ensuring more robust development and deployment experiences.

@tuancoltech tuancoltech requested a review from jo-elimu February 21, 2025 03:12
@tuancoltech tuancoltech self-assigned this Feb 21, 2025
@tuancoltech tuancoltech requested a review from a team as a code owner February 21, 2025 03:12
Copy link

coderabbitai bot commented Feb 21, 2025

Walkthrough

This pull request updates multiple build configuration files and wrapper scripts. The CI workflow now tests against both Java 17 and 21. The Android Gradle plugin version in the build file has been bumped up to 8.5.2, and the Gradle wrapper now uses version 8.12 with URL validation enabled. Additionally, both the Unix (gradlew) and Windows (gradlew.bat) scripts have been refined for better error handling and POSIX compliance.

Changes

Files Change Summary
.github/workflows/gradle.yml Updated the Java version matrix from [17] to [17, 21] to run builds on multiple Java versions.
build.gradle Upgraded the Android Gradle plugin version from 8.1.4 to 8.5.2.
gradle/wrapper/gradle-wrapper.properties Changed distributionUrl from gradle-8.1-bin.zip to gradle-8.12-bin.zip and added the validateDistributionUrl property set to true.
gradlew, gradlew.bat Enhanced error handling and POSIX compliance: suppressed unnecessary output, revised Java command checks, and refined error message redirection.
app/src/main/java/ai/elimu/launcher/ui/HomeScreensActivity.java, app/src/main/java/ai/elimu/launcher/MainActivity.java Added @SuppressLint("MissingSuperCall") annotation to onBackPressed() methods to suppress lint warnings for missing superclass calls.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant G as gradlew Script
    U->>G: Invoke gradlew
    G->>G: Set APP_HOME (suppress cd output)
    G->>G: Check for Java using "command -v java"
    alt Java found
        G->>G: Execute Java command with options
    else Java not found
        G->>U: Output error message
    end
Loading

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • 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: 1

🧹 Nitpick comments (4)
gradlew (1)

67-81: Watch out for symlink parsing edge cases.

The script uses ls -ld to retrieve symlink targets and extracts the link path from the output. This behavior can sometimes break if filenames contain unusual characters (e.g., spaces or newlines). Also, the format of ls -ld output may differ across some platforms. Consider using readlink (if available) instead of relying on parsing ls -ld output to reduce potential edge cases.

gradlew.bat (1)

37-37: Double-check memory bounds for large builds.

Setting DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" provides a tight memory limit. This might be insufficient for larger or more complex projects, potentially causing out-of-memory errors. Evaluate whether a higher -Xmx value is needed if your builds are more resource-intensive.

.github/workflows/gradle.yml (1)

17-18: Action Versions Outdated:
Static analysis has flagged that both actions/checkout@v3 and actions/setup-java@v3 might be outdated. Please consider updating these actions (for example, to actions/checkout@v4 and the latest stable release of actions/setup-java) to ensure improved performance, compatibility, and security.

🧰 Tools
🪛 actionlint (1.7.4)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


18-18: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

app/build.gradle (1)

4-5: SDK Version & Namespace Update:
Upgrading to compileSdk 35 and adding the namespace "ai.elimu.launcher" property is a proper step toward modernizing your Android configuration. Consider reviewing whether the targetSdkVersion should also be updated to 35 to fully leverage the behavior changes introduced in the latest Android SDK.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67b78a2 and b83a3ec.

⛔ Files ignored due to path filters (1)
  • gradle/wrapper/gradle-wrapper.jar is excluded by !**/*.jar
📒 Files selected for processing (6)
  • .github/workflows/gradle.yml (1 hunks)
  • app/build.gradle (2 hunks)
  • build.gradle (1 hunks)
  • gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • gradlew (2 hunks)
  • gradlew.bat (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/gradle.yml

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


18-18: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (7)
gradlew (2)

1-1: Ensure full POSIX compliance across all shells.

Changing the shebang to #!/bin/sh is a good step towards broader compatibility. However, different systems have varying implementations of sh. Please verify that all features (e.g., function definitions, parameter expansions, etc.) work reliably in default shells on the targeted systems (e.g., Alpine, Solaris).

Would you like me to generate a script to invoke and test gradlew across multiple Linux environments (Alpine, Ubuntu, Debian, etc.) in a container-based approach?


144-159: Verify portability of “ulimit” usage.

Using ulimit -H -n within a POSIX shell can sometimes be undefined or behave differently on non-GNU systems (e.g., BSD, older UNIX). Although it appears to be standard in most modern environments, you may want to validate that it does not cause unexpected runtime errors if you plan to build on exotic platforms.

gradlew.bat (1)

40-51: Good error messaging for missing Java.

The script clearly directs the user to set JAVA_HOME or install Java on the system if java.exe is not found. This is a clean and user-friendly approach that should reduce confusion.

gradle/wrapper/gradle-wrapper.properties (1)

3-5: Verify that the distribution type aligns with your needs.

Switching from an all distribution to a bin distribution can reduce download size, but it also omits certain Gradle source code and documentation. Make sure that the bin distribution is sufficient for your use cases—particularly if you generate custom Gradle tasks or rely on certain built-in Gradle scripts not bundled in the bin distribution.

Also applies to: 7-7

.github/workflows/gradle.yml (1)

14-21: Matrix Strategy Configuration Update:
The new matrix configuration with java: [17, 21] and the dynamic assignment of java-version: ${{ matrix.java }} is a great enhancement for multi-version testing. This update will help ensure compatibility with both Java 17 and Java 21.

🧰 Tools
🪛 actionlint (1.7.4)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


18-18: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

build.gradle (1)

8-8: Android Gradle Plugin Upgrade:
Updating the dependency to classpath 'com.android.tools.build:gradle:8.5.2' is aligned with the recent build tool changes. Ensure that all sub-projects are compatible with this version, and verify against the official release notes for any migration notes or deprecations.

app/build.gradle (1)

38-40: BuildConfig Generation Enabled:
The added buildFeatures { buildConfig = true } block is effective for generating the BuildConfig class, ensuring that build configuration constants are readily available in your app code. This is particularly useful in newer versions of the Android Gradle plugin.

Copy link
Member

@jo-elimu jo-elimu left a comment

Choose a reason for hiding this comment

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

Build checks are failing.

@tuancoltech
Copy link
Member Author

Build checks are failing.

We'll need to fix #71 first.
There're pretty quite a lot of works to do.

@tuancoltech
Copy link
Member Author

This PR depends on #77

@jo-elimu
Copy link
Member

@tuancoltech Is this PR still needed?

@tuancoltech
Copy link
Member Author

@tuancoltech Is this PR still needed?

@jo-elimu Yes, this PR will do 2 things:

1/ Upgrade Android Gradle build tools to 8.5.2
2/ Add Java 21 as an extra Java target to build in Github action script

@tuancoltech tuancoltech force-pushed the build/upgrade_build_tools branch from b83a3ec to fde78c7 Compare February 23, 2025 15:38
@tuancoltech tuancoltech requested a review from jo-elimu February 23, 2025 15:43
@tuancoltech
Copy link
Member Author

tuancoltech commented Feb 23, 2025

This PR depends on #79

@tuancoltech tuancoltech force-pushed the build/upgrade_build_tools branch from bc2e038 to e69a09f Compare February 23, 2025 15:50
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)
app/src/main/java/ai/elimu/launcher/MainActivity.java (1)

24-30: LGTM! The annotation properly documents the intentional behavior.

The @SuppressLint("MissingSuperCall") annotation correctly indicates that we're intentionally not calling super.onBackPressed(). This is a common pattern in Android when you want to completely override the back navigation behavior.

However, for better maintainability, consider adding a brief comment explaining why back navigation is disabled in this activity.

     @SuppressLint("MissingSuperCall")
     @Override
     public void onBackPressed() {
         Timber.i("onBackPressed");
 
-        // Do nothing
+        // Disable back navigation to prevent users from accidentally exiting the launcher
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc2e038 and 4c06a0e.

📒 Files selected for processing (2)
  • app/src/main/java/ai/elimu/launcher/MainActivity.java (2 hunks)
  • app/src/main/java/ai/elimu/launcher/ui/HomeScreensActivity.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/ai/elimu/launcher/ui/HomeScreensActivity.java
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: build (ubuntu-latest, 21)
  • GitHub Check: build (ubuntu-latest, 17)
🔇 Additional comments (1)
app/src/main/java/ai/elimu/launcher/MainActivity.java (1)

3-3: LGTM!

Clean addition of the required import for the SuppressLint annotation.

@tuancoltech tuancoltech merged commit 5cfead2 into main Feb 24, 2025
4 checks passed
@tuancoltech tuancoltech deleted the build/upgrade_build_tools branch February 24, 2025 01:36
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.

Upgrade to Gradle 8.x
2 participants