Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 9, 2025

Resolves the ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain error that occurred when running ./gradlew commands in GitHub Actions workflows.

Root Cause

The issue was caused by a missing gradle-wrapper.jar file in the gradle/wrapper/ directory. The Gradle wrapper consists of several components:

  • gradlew and gradlew.bat scripts ✅ (present)
  • gradle/wrapper/gradle-wrapper.properties ✅ (present)
  • gradle/wrapper/gradle-wrapper.jar ❌ (missing)

Without the JAR file, the wrapper scripts cannot locate the GradleWrapperMain class needed to bootstrap Gradle.

Changes Made

1. Fixed Gradle Wrapper

  • Added the missing gradle-wrapper.jar for Gradle version 8.14.2
  • Updated .gitignore to allow gradle-wrapper.jar while still excluding other JAR files

2. Updated GitHub Workflows

Updated all three workflow files to use the Gradle wrapper instead of manually installing Gradle:

Before:

- name: Setup Gradle
  uses: gradle/actions/setup-gradle@v4
  with:
    gradle-version: '8.14.2'

- name: Build with Gradle
  run: gradle build

After:

- name: Build with Gradle
  run: ./gradlew build

3. Java Version Consistency

  • Updated workflows to use Java 21 consistently (matching project requirements)
  • Removed unnecessary Gradle setup actions since the wrapper handles version management

Verification

$ ./gradlew --version
Gradle 8.14.2

$ ./gradlew build
BUILD SUCCESSFUL in 42s

The wrapper now correctly downloads and uses Gradle 8.14.2 as specified in gradle-wrapper.properties, eliminating the need for manual Gradle setup in CI pipelines.

Fixes #26.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix ./gradlew wrapper run issue in GitHub workflow Fix ./gradlew wrapper run issue in GitHub workflow Jun 9, 2025
Copilot AI requested a review from hossain-khan June 9, 2025 06:10
Copilot finished work on behalf of hossain-khan June 9, 2025 06:10
@hossain-khan hossain-khan marked this pull request as ready for review June 9, 2025 06:10
Copy link
Owner

@hossain-khan hossain-khan left a comment

Choose a reason for hiding this comment

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

nice

@hossain-khan hossain-khan merged commit b68b367 into main Jun 9, 2025
1 check passed
@hossain-khan hossain-khan deleted the copilot/fix-26 branch June 9, 2025 06:12
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.

Fix ./gradlew wrapper run issue in GitHub workflow

2 participants