Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Hosted Gradle snippet is always Groovy DSL, so pasting it into a build.gradle.kts fails to compile

Chiusa Adatta ai principianti
#348 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mikolalysenko ci sta già lavorando.

Dal 3/10/2026.

  • #646 di @mikolalysenko — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
build-system, cli

Direzione di ricerca

Inizia in crates/socket-patch-core/src/patch/redirect/mod.rs intorno a gradle_snippet alle righe 7133-7157, poi esamina GRADLE_FILES vicino alla riga 6529 ed esegui la riproduzione della scansione ospitata. L'avviso dovrebbe produrre Kotlin DSL incollabile per i file .kts, preservando al contempo un output Groovy valido per i file Groovy; verifica la risoluzione con il comando Gradle dependencies descritto nell'issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

agent:triaged bug bughunt pm:gradle priority:p3

[agent] Found by the scheduled Gradle bug-hunt routine (ledger #319).

Summary

redirect_gradle_manual_snippet fires for build.gradle.kts / settings.gradle.kts as well as the Groovy files, but its snippet is always Groovy: maven { url "…" }. That is not valid Kotlin DSL, so a user who pastes it into a Kotlin DSL build (the gradle init default since Gradle 8) gets a script compilation error. The code comment on gradle_snippet says "the Kotlin DSL differs only in quoting", but it doesn't: Kotlin needs url = uri("…"). The warning also doesn't say the snippet is Groovy-only.

Impact

The documented Gradle hosted path can't be used verbatim by Kotlin DSL projects. The failure is loud, not silent, but users have to know how to translate the snippet.

Repro

Paste the exact snippet from scan --mode hosted --json (redirect.warnings[].detail) into a build.gradle.kts with plugins { java }, repositories { mavenCentral() } and implementation("org.apache.commons:commons-text:1.10.0-socket.4d5e6f70"), then run gradle dependencies:

e: file:///…/build.gradle.kts:6:25: Unexpected tokens (use ';' to separate expressions on the same line)
* Where: Build file '…/build.gradle.kts' line: 6
            maven { url "file:///tmp/gw/socketrepo" }

Replacing only that line with maven { url = uri("file:///tmp/gw/socketrepo") } makes the build resolve commons-text-1.10.0-socket.4d5e6f70.jar, so includeVersion(...) and the rest of the block are fine in Kotlin.

Expected vs actual

  • Expected (docs/ecosystems.md, "Gradle (hosted Maven)"): a present build.gradle* / settings.gradle* gets a paste-able exclusiveContent { … } snippet. For a .kts build it should be Kotlin syntax, or both variants should be printed.
  • Actual: Groovy syntax, and a compile error in every Kotlin DSL build.

Matrix (Linux; each run twice)

Gradle JDK Groovy build.gradle Kotlin build.gradle.kts
6.9.4 11 compiles ✅ compile error ❌
7.6.6 17 compiles ✅ compile error ❌
8.14.3 21 compiles ✅ compile error ❌
9.8.0 21 compiles ✅ compile error ❌

First bad release

v4.0.0, when the snippet was introduced.

Suspect code

crates/socket-patch-core/src/patch/redirect/mod.rs:7133-7157 (gradle_snippet, one fixed format string). GRADLE_FILES at mod.rs:6529 includes the .kts names, but the DSL is never selected.

Lingua principale
Rust
Stelle
8
Fork
1
Merge medio
19h 1m
PR unite (30g)
473

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SocketDev/socket-patch

Tutte le issue di SocketDev/socket-patch

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.