elastic/elasticsearch · error · GradleException

Cannot read java properties file.

Error message

Cannot read java properties file.

What it means

Thrown by BwcSetupExtension.JavaHomeValueSource.readFromFile when reading the minimum-compiler-version properties file fails with an IOException. The ValueSource reads a checked-in file (build-tools-internal/minimumCompilerVersion... or the buildSrc variant, chosen by bwc version) from the bwc checkout directory to determine the minimum Java compiler for a backward-compatibility build.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcSetupExtension.java:278

        public interface Params extends ValueSourceParameters {
            Property<String> getJdksDir();
        }
    }

    public abstract static class JavaHomeValueSource implements ValueSource<String, JavaHomeValueSource.Params> {

        private String minimumCompilerVersionPath(Version bwcVersion) {
            return (bwcVersion.onOrAfter(BUILD_TOOL_MINIMUM_VERSION))
                ? "build-tools-internal/" + MINIMUM_COMPILER_VERSION_PATH
                : "buildSrc/" + MINIMUM_COMPILER_VERSION_PATH;
        }

        private static String readFromFile(File file) {
            try {
                return FileUtils.readFileToString(file).trim();
            } catch (IOException ioException) {
                throw new GradleException("Cannot read java properties file.", ioException);
            }
        }

        @Override
        public String obtain() {
            return readFromFile(
                new File(getParameters().getCheckoutDir().get(), minimumCompilerVersionPath(getParameters().getVersion().get()))
            );
        }

        public interface Params extends ValueSourceParameters {
            Property<Version> getVersion();

            Property<File> getCheckoutDir();
        }
    }

    public abstract class BwcThrottle implements BuildService<BuildServiceParameters.None> {}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Verify the bwc checkout directory exists and contains build-tools-internal/<minimumCompilerVersion path>.
  2. Ensure getCheckoutDir() ValueSource parameter is set to the correct checkout root.
  3. Re-create or refresh the bwc checkout used by the build.
  4. Check read permissions on the target file.
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(checkoutDir, minimumCompilerVersionPath);
if (f.exists() == false || f.canRead() == false) {
    throw new GradleException("Cannot read java properties file at " + f.getAbsolutePath());
}

Try / catch

try {
    return FileUtils.readFileToString(file).trim();
} catch (IOException ioException) {
    throw new GradleException("Cannot read java properties file.", ioException);
}

Prevention

When it happens

Trigger: The minimum-compiler-version file is missing, unreadable, or the checkout directory parameter points at a non-existent or incomplete path; FileUtils.readFileToString throws IOException.

Common situations: Incomplete bwc git checkout; the checkoutDir ValueSource parameter was never set or points at a stale path; file permissions block read; the file was moved/renamed in a branch mismatch.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/564b16fdb123dfc0. Report an issue: GitHub.