Repository navigation
fix: translate RELEASE/LATEST to Gradle's latest.* in generated build.gradle - #2750
Conversation
….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
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes #1777
jbang editandjbang export gradlecopy//DEPScoordinates intobuild.gradleunchanged.When a script uses Maven's
RELEASEorLATESTmeta-version, for example//DEPS ch.qos.reload4j:reload4j:RELEASE, JBang itself resolves it fine, but Gradle treats itas a literal version and the generated project fails to build:
Gradle's equivalents are
latest.release(highest non-SNAPSHOT version) andlatest.integration(highest version of any status, including SNAPSHOTs); seehttps://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 exactlyRELEASEorLATESTand keeps any classifier,@typeor@pomsuffix as is. Bothgradleifymethods (EditandExport) now run dependencies through it. Versions that onlycontain the word, such as Spring's
5.3.0.RELEASE, are left alone, and the match iscase-sensitive like Maven's own resolver. Maven export and dependency resolution are not
touched.
Tests:
DependencyResolverTest.testToGradleGavcovers the mapping, classifiers,@pomBOMs, andversions that merely contain
RELEASE.TestEdit.testEditDepsReleaseAndLatestandTestExport.testExportGradleProjectWithReleaseAndLatestgenerate a project from a scriptusing
RELEASE,LATESTand1.0.RELEASEagainst a small file-based Maven repo (newBaseTest.writeTestArtifacthelper), so they run offline. Without the fix they fail withimplementation 'example:rel:RELEASE'in the generatedbuild.gradle.I also checked the generated lines with Gradle 8.14.6 against a local repo: with
RELEASE/LATEST,gradle dependenciesshows them as FAILED, whilelatest.release,latest.integration,platform('...:latest.release')and'...:latest.release:linux@zip'all resolve, and
latest.integrationpicks up a SNAPSHOT wherelatest.releasedoes not.Summary by CodeRabbit
RELEASEandLATESTnow appear as Gradle-compatible selectors (latest.releaseandlatest.integration) in linked edits and exported projects.RELEASEorLATEST—remain unchanged. Classifiers and artifact types are preserved during conversion, so generated Gradle dependencies retain these details.