Deprecation warning when using `properties`

I have the following in my build.gradle file:

ext.tomcatVersion = properties.tomcat9Version

And in gradle.properties:

tomcat9Version = 9.0.22

Running any Gradle command causes:

The libsDir method has been deprecated. This is scheduled to be removed in Gradle 6.0.
        at build_5umbho083f2juapuczrehnny6.run(/home/boris/code/project/build.gradle:18)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The distsDir method has been deprecated. This is scheduled to be removed in Gradle 6.0.
        at build_5umbho083f2juapuczrehnny6.run(/home/boris/code/project/build.gradle:18)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

Line 18 is the one where I use properties. If I hardcode the version, the warning goes away. So the issue is somewhere in using properties. Am I doing it wrong?

P.S. Using Gradle 5.5.1.