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

Support Spring Boot apps with no explicit version config

Aperta
#155 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
java, kotlin, spring-boot
Ambito
build-system

Direzione di ricerca

Inizia con il test Kotlin rewriteRun nell’issue ed esamina le recipes esistenti che aggiornano la proprietà java.version. Determina come devono essere gestiti i valori predefiniti di Spring Boot parent insieme alle altre configurazioni della versione di Java, quindi aggiungi la copertura per il comportamento scelto. Il lavoro è completato quando il test fornito passa senza rompere i casi di migrazione esistenti.

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

Descrizione

design-partner-3 enhancement

test case:

    @Test
    fun `adds java version property if not present if spring-like parent`() = rewriteRun(
        pomXml("""
            <?xml version="1.0" encoding="UTF-8"?>
            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
              <modelVersion>4.0.0</modelVersion>
              <groupId>org.sample</groupId>
              <artifactId>sample</artifactId>
              <version>1.0.0</version>
              
              <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.7.0</version>
              </parent>
              
            </project>
        """.trimIndent(),
            """
            <?xml version="1.0" encoding="UTF-8"?>
            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
              <modelVersion>4.0.0</modelVersion>
              <groupId>org.sample</groupId>
              <artifactId>sample</artifactId>
              <version>1.0.0</version>
              
              <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.7.0</version>
              </parent>
              <properties>
                <java.version>11</java.version>
              </properties>
              
            </project>
        """.trimIndent()
        ) // fails with no change
    )

Spring Boot declares a java.version property, pre-wired into the maven-compiler-plugin config. This is a convenient, common pattern to manage a project's Java version, and our recipes support updating that property if present.

But, because Spring Boot provides a default value (1.8) for java.version, it's feasible for a Spring Boot app to have no explicit configuration for its Java version in its pom.xml. And in that case, the upgrade recipe will do everything but actually update the build's Java version. The test case above shows this.

The tricky part here is deciding how generic the solution should be -- eg:

  • do we just check for the "hardcoded" spring-boot-starter-parent parent, or identify arbitrary (non-project) parents which declare java.version
  • should we validate that project pom isn't already managing its java version a different way (ie no explicit maven-compiler-plugin config)
  • should we enforce an opinion that projects with spring-like parents should only use the java.version property to manage the Java version
Lingua principale
Java
Stelle
156
Fork
129
Merge medio
14h 30m
PR unite (30g)
43

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 openrewrite/rewrite-migrate-java

Tutte le issue di openrewrite/rewrite-migrate-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.