Gradle: check the Java target in build.gradle

Open
#62 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
java, python
Domain
build-system, cli

Research direction

Start with the Java rows and the literal-pin extractors in checks/runtimes.py, then mirror the Gemfile-style pattern for build.gradle and build.gradle.kts. Add the new id project.java.gradle to explain.py, docs/checks.md and the CHANGELOG, and cover both DSLs plus a hostile file in unit tests. Done when a sourceCompatibility of 17 on Java 11 yields one fail, a Gradle file with no literal target yields no result, and pytest and ruff pass.

Written by the indexing model from the issue text.

Description

enhancement

Problem: Gradle projects declare their Java target in build.gradle or build.gradle.kts, not in .java-version. DevReady currently has no way to warn when the installed JDK is older than the target the build requires.

Do:

  • Add a literal pin extractor for build.gradle and build.gradle.kts in checks/runtimes.py, next to the Java rows.
  • Recognize, in a line-based parse:
    • sourceCompatibility = JavaVersion.VERSION_17
    • sourceCompatibility = 17 / sourceCompatibility = "17"
    • java { toolchain { languageVersion = JavaLanguageVersion.of(17) } } (Groovy) and .set(JavaLanguageVersion.of(17)) / languageVersion.set(...) (Kotlin)
    • targetCompatibility with the same shapes
  • Never evaluate Groovy or Kotlin. First literal match wins; variables, project.property(...), and computed values stay skip.
  • New id project.java.gradle; title like Java (Gradle); a mismatch is a fail.
  • Add explain.py and docs/checks.md rows, a CHANGELOG line, and unit tests for both DSLs and a hostile file.

Done when:

  • A build.gradle with sourceCompatibility = JavaVersion.VERSION_17 on Java 11 reports one fail.
  • build.gradle.kts with languageVersion.set(JavaLanguageVersion.of(17)) behaves the same.
  • A Gradle file with no literal Java target adds no result.
  • pytest, ruff check and ruff format --check pass.

Notes:

  • Follows the existing rule for Gradle/Gemfile-style files: literal declarations only, no execution.
  • If both pom.xml and build.gradle exist, the Maven result wins (one Java target per project); say so in the docs.
Dominant language
Python
Stars
2
Forks
3
Avg merge
10h 51m
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Evalogical-Inc/devReady

All issues in Evalogical-Inc/devReady

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.