Skip to content

fix: translate RELEASE/LATEST to Gradle's latest.* in generated build.gradle - #2750

Merged
maxandersen merged 2 commits into
jbangdev:mainfrom
sagarrsharmaa:fix/gradle-release-latest-versions
Nov 28, 2026
Merged

maxandersen merged 2 commits into
jbangdev:mainfrom
sagarrsharmaa:fix/gradle-release-latest-versions

Conversation

@sagarrsharmaa

@sagarrsharmaa sagarrsharmaa commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1777

jbang edit and jbang export gradle copy //DEPS coordinates into build.gradle unchanged.
When a script uses Maven's RELEASE or LATEST meta-version, for example
//DEPS ch.qos.reload4j:reload4j:RELEASE, JBang itself resolves it fine, but Gradle treats it
as a literal version and the generated project fails to build:

> Could not find ch.qos.reload4j:reload4j:RELEASE.

Gradle's equivalents are latest.release (highest non-SNAPSHOT version) and
latest.integration (highest version of any status, including SNAPSHOTs); see
https://docs.gradle.org/current/userguide/dependency_versions.html and
https://docs.gradle.org/current/userguide/component_metadata_rules.html.

This adds DependencyUtil.toGradleGav, which rewrites the version only when it is exactly
RELEASE or LATEST and keeps any classifier, @type or @pom suffix as is. Both
gradleify methods (Edit and Export) now run dependencies through it. Versions that only
contain the word, such as Spring's 5.3.0.RELEASE, are left alone, and the match is
case-sensitive like Maven's own resolver. Maven export and dependency resolution are not
touched.

Tests:

  • DependencyResolverTest.testToGradleGav covers the mapping, classifiers, @pom BOMs, and
    versions that merely contain RELEASE.
  • TestEdit.testEditDepsReleaseAndLatest and
    TestExport.testExportGradleProjectWithReleaseAndLatest generate a project from a script
    using RELEASE, LATEST and 1.0.RELEASE against a small file-based Maven repo (new
    BaseTest.writeTestArtifact helper), so they run offline. Without the fix they fail with
    implementation 'example:rel:RELEASE' in the generated build.gradle.

I also checked the generated lines with Gradle 8.14.6 against a local repo: with
RELEASE/LATEST, gradle dependencies shows them as FAILED, while latest.release,
latest.integration, platform('...:latest.release') and '...:latest.release:linux@zip'
all resolve, and latest.integration picks up a SNAPSHOT where latest.release does not.

Summary by CodeRabbit

  • Bug Fixes
    • Gradle dependencies using the exact version values RELEASE and LATEST now appear as Gradle-compatible selectors (latest.release and latest.integration) in linked edits and exported projects.
    • Other version values—including longer versions containing RELEASE or LATEST—remain unchanged. Classifiers and artifact types are preserved during conversion, so generated Gradle dependencies retain these details.

….gradle

`jbang edit` and `jbang export gradle` copied //DEPS coordinates into
build.gradle as-is. Maven's RELEASE and LATEST meta versions mean
nothing to Gradle: it looks for a module literally versioned "RELEASE"
and fails with "Could not find g:a:RELEASE", so neither the IDE project
nor the exported project builds.

When rendering the Gradle dependencies, map RELEASE to latest.release
and LATEST to latest.integration, which are Gradle's equivalents. Any
classifier, @type or @pom (platform) suffix is kept. Only a version that
is exactly RELEASE or LATEST is translated, so versions such as
5.3.0.RELEASE are left alone.

Fixes jbangdev#1777
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change converts exact RELEASE and LATEST dependency versions to Gradle selectors. Linked-edit and Gradle-export output use the converted coordinates. Tests cover converted versions, unchanged versions, and coordinates with classifiers or artifact types.

Changes: Gradle Version Selector Conversion

Layer / File(s) Summary
Convert exact version selectors
src/main/java/dev/jbang/dependencies/DependencyUtil.java, src/test/java/dev/jbang/dependencies/DependencyResolverTest.java
DependencyUtil.toGradleGav converts exact RELEASE to latest.release and exact LATEST to latest.integration. It preserves other versions and coordinate forms.
Apply converted coordinates to Gradle output
src/main/java/dev/jbang/cli/Edit.java, src/main/java/dev/jbang/cli/Export.java, src/test/java/dev/jbang/BaseTest.java, src/test/java/dev/jbang/cli/TestEdit.java, src/test/java/dev/jbang/cli/TestExport.java
Linked-edit and Gradle-export paths convert dependency coordinates before formatting them as Gradle dependencies. Tests create local artifacts and check the generated dependency versions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: maxandersen

Merge Risk: Minimal · up to 75b94

Gradle build files generated by edit and export now use Gradle's latest.release and latest.integration for exact RELEASE and LATEST versions. Other versions are unchanged, and no actionable merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: jbang edit and export gradle now translate the Maven RELEASE and LATEST versions to Gradle's latest.release and latest.integration selectors in the generated build fil…
Linked Issues check Passed [#1777] The issue requires the generated build.gradle from jbang edit -b to use latest.release instead of the literal RELEASE. The reviewed head adds DependencyUtil.toGradleGav, which maps an …
Out of Scope Changes check Passed The feature files (DependencyUtil.java, Edit.java, Export.java) have no incremental change since the previous reviewed head, so the previous in-scope conclusion holds for them. The only new commit sin…
Full details: Title check

Explanation

The title names the main change: jbang edit and export gradle now translate the Maven RELEASE and LATEST versions to Gradle's latest.release and latest.integration selectors in the generated build file. The title uses a conventional fix: prefix, and the changeset matches it through DependencyUtil.toGradleGav and its call sites in Edit.java and Export.java, plus the tests.

Full details: Linked Issues check

Explanation

[#1777] The issue requires the generated build.gradle from jbang edit -b to use latest.release instead of the literal RELEASE. The reviewed head adds DependencyUtil.toGradleGav, which maps an exact RELEASE version to latest.release, and Edit.gradleify applies it to each dependency. The previous review found this covered by TestEdit.testEditDepsReleaseAndLatest. The incremental diff from the previous reviewed head (34f4f15) to head (75b94cc) is a merge of main. It shows no change to DependencyUtil.java, Edit.java or Export.java. The previous PASS conclusion still holds. I did not run the test suite.

Full details: Out of Scope Changes check

Explanation

The feature files (DependencyUtil.java, Edit.java, Export.java) have no incremental change since the previous reviewed head, so the previous in-scope conclusion holds for them. The only new commit since that head is a merge of main (75b94cc). Its history shows upstream CI and init-cleanup commits. These are not authored by this PR and do not touch the feature code. I did not run a full whole-PR file listing against the merge base, so the status of those merged upstream commits in the whole-PR diff is not fully confirmed. The authored changes remain tied to #1777 and the PR objectives.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 34f4f15 and 75b94cc.

Files selected for processing: 1

  • src/test/java/dev/jbang/BaseTest.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@maxandersen maxandersen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

makes sense

@github-actions

Copy link
Copy Markdown

📦 PR Build Available

Install this PR build:

curl -sL https://github.com/jbangdev/jbang-pr-builds/releases/download/pr-2750/jbang.tar | tar xf - && ./jbang/bin/jbang version

Release
| Built from 75b94cc

@maxandersen
maxandersen merged commit c5ee076 into jbangdev:main Nov 28, 2026
34 checks passed
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.

Version RELEASE is incorrectly transformed when the gradle project is created

2 participants