How to make properties in the gradle.properties file of a custom Gradle plugin available in the consuming project

I am writing a custom Gradle plugin in Java. Internally, it sets some fundamental properties in the gradle.properties file, e.g., the Kotlin version to apply.

gradle.properties

versionKotlin = 1.4.10

build.gradle

plugins {
    id 'java-gradle-plugin'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$versionKotlin"
}

Then, within the code of the custom plugin, Kotlin plugin is first applied, and then configured:

public class CustomPlugin implements Plugin<Project> {

    private static final String VERSION_KOTLIN = "1.4.10";

    @Override
    public void apply(@NotNull Project project) {
        project.getPluginManager().apply(KotlinPluginWrapper.class);
        project.getTasks().withType(KotlinCompile.class, task -> {
            task.getKotlinOptions().setApiVersion(extractKotlinApiVersion(VERSION_KOTLIN));
        });
    }

    private String extractKotlinApiVersion(String versionKotlin) {
        return versionKotlin.substring(0, versionKotlin.indexOf('.', versionKotlin.indexOf('.') + 1));
    }
}

Now, the VERSION_KOTLIN constant in the code of the custom plugin is duplicated information. Is there a more-or-less elegant way to pass the properties from the gradle.properties file to the code that is executed by the consuming project?

You can directly try accessing project.versionKotlin. It should work