Could not find method srcDirs() for arguments on S

2019-08-17 11:40发布

问题:

I'm trying to compile my Kotlin app and set of Kotlin libraries to JavaScript. I've got that working well, but when I try to run it, it can't find kotlin.js. To remedy this, I tried changing my build.gradle to be more like this example on GitHub.

In mine, I defined source sets like this: (which works but doesn't output kotlin.js)

sourceSets {
    main {
        kotlin {
            srcDirs 'src/main/kotlin'
        }
    }
}

to something like this: (which doesn't even sync)

sourceSets {
    main.kotlin.srcDirs += "src/main/kotlin"
}

which gives me this error:

Could not find method srcDirs() for arguments [lib/Blue-Base/src/main/kotlin] on SourceSet container of type org.gradle.api.internal.tasks.DefaultSourceSetContainer.

How do I resolve this error? I know one issue is I don't quite grok Groovy/Gradle, but I feel like what I did should at least sync...


Here's a link to the code and project in question: https://github.com/BlueHuskyStudios/Decision-Cruncher/blob/SO/53576840/build.gradle

回答1:

Looks like you have written srcDirs instead of main.kotlin.srcDirs.