CLI command task discovery: configuration-cache compatibility and resolution scoping

Aperta
#16,008 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
42/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
groovy
Ambito
build-system, cli

Direzione di ricerca

Inizia dal codice del plugin CLI che registra i task Gradle per comando e analizza META-INF/grails-cli.factories nei jar di grailsCliClasspath risolti. Traccia la discovery dei componenti companion e le closure dei task, quindi esegui i test funzionali esistenti aggiungendo un caso per --configuration-cache. Il lavoro è completo quando è garantita la compatibilità con configuration-cache, viene eseguita una sola scansione del manifest per ogni set di artefatti risolto ed è stato deciso chiaramente un approccio per la modalità opzionale task-rule.

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

Descrizione

breaking-change design-required

Context

Follow-up from the CLI dependency split (#15948, review thread: https://github.com/apache/grails-core/pull/15948#discussion_r3605219281).

Per-command Gradle tasks (dbmUpdate, generate-*, ...) are registered from command names discovered in the META-INF/grails-cli.factories files of resolved grailsCliClasspath jars. Gradle requires task names to exist when the task graph is assembled, so this discovery currently resolves the CLI dependency graph at configuration time — every invocation pays it (including ./gradlew help), and Grails does not yet support the configuration cache, so the cost is never amortized.

There is no Gradle API for lazily-materialized task names: dynamically named tasks that are visible in gradle tasks/IDE sync require configuration-time resolution. The work below reduces or amortizes the cost within that constraint.

Tactical follow-ups

  1. Configuration-cache compatibility for the CLI plugins. Configuration-time resolution is supported under CC (the resolved result is serialized into the cache entry), so CC effectively becomes the caching mechanism: discovery is paid once and replayed until inputs change. The blockers in the current code are incidental rather than structural — cross-project findProject access during companion discovery, Project captures in task closures. Clean these up and add a --configuration-cache functional test to lock it in.
  2. Scope the resolution cost. Cache the manifest/factories scan per resolved artifact set so jars are not re-opened repeatedly within a single invocation.
  3. Optional task-rule mode. A tasks.addRule-based mode would defer discovery until an unmatched task name is actually requested, making unrelated builds pay nothing — at the cost of per-command tasks no longer being listed individually in gradle tasks/IDE task views. Consider offering it behind a flag for build-speed-sensitive projects, keeping eager registration (discoverability) as the default.

Strategic note

Much of this complexity exists because commands are surfaced as Gradle tasks. A fuller separation — tracking dependencies in grailsCli but resolving/using them in the Grails CLI itself — would decouple the build system from the CLI system entirely, but that is a redesign tied to the unresolved profile/forge restructuring discussion and is explicitly out of scope here. See the PR thread for details.

Lingua principale
Groovy
Stelle
2.9k
Fork
980
Merge medio
1g 17h
PR unite (30g)
192

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 apache/grails-core

Tutte le issue di apache/grails-core

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.