Gradle 5.0 upgrade task javacompile No value has been specified for property '$1'

Gradle upgrade from 4.10.2 to gradle 5.0 makes this block of code not work and gives error:

org.gradle.api.tasks.TaskValidationException: Some problems were found with the configuration of task querymodels

Cause 1: org.gradle.api.InvalidUserDataException: No value has been specified for property ‘$1’
Cause 2: org.gradle.api.InvalidUserDataException: No value has been specified for property ‘$1’

any idea what is missing?

buildscript {
	ext {
		querydslVersion    = "4.1.4"
		interceptorVersion    = '1.2.2'
		metaModelsSourcesDir = file("$buildDir/metamodels")   
		
	}
}


task querymodels(type: JavaCompile, group: 'build') {
	outputs.dir(metaModelsSourcesDir)
    doFirst {
        delete metaModelsSourcesDir;
        metaModelsSourcesDir.mkdirs();
    }

    classpath = configurations.runtimeClasspath + configurations.querydslapt
    destinationDir metaModelsSourcesDir

    source(sourceSets.main.java)
    options.compilerArgs = [
            "-proc:only",
            "-processor", "com.querydsl.apt.jpa.JPAAnnotationProcessor",
            "-s", metaModelsSourcesDir
    ]
}

compileJava.dependsOn {
	querymodels
}

What is the stacktrace of the error?