Jar plugin seems not honouring custom sourceSet configuration

Hi. I am building a Spring boot application and trying to deploy different resources on compilation.
So I made my project’s directory structure as follows:

src
 + local
 |  +    resources
 + main
 |  +    kotlin
 |  +    resources   
 + prod
    +    resources

And below is my gradle snippet:

sourceSets {
    def buildTarget = project.properties["buildTarget"].toString().toLowerCase(Locale.US)

    main {
        resources {
            srcDirs = [srcDirs, "$buildTarget/resources"]
        }
    }

    // Seems working as intended, prints as follows when building with -PbuildTarget=local:
    // [src/main/resources, src/local/resources]
    println sourceSets.main.resources.srcDirs
}

jar {
    baseName = "my-springboot-application"
    version = "0.0.1-SNAPSHOT"
    from sourceSets.main.output
}

The problem is, when I was trying to build my app by using following command

./gradlew clean assemble -PbuildTarget=local

compiles without any error but inside of the output JAR file there are only files located on src/main/**. How can I fix this? Please help.

Oh stupid me. Just change this line

srcDirs = [srcDirs, "$buildTarget/resources"]

as follows:

srcDirs = [srcDirs, "src/$buildTarget/resources"]

to solve my problem.