Kotlin / kotlin-frontend-plugin

Gradle Kotlin (http://kotlinlang.org) plugin for frontend development
Apache License 2.0
561 stars 69 forks source link

build.gradle.kts with sourceSets in android project #160

Open Merseyside opened 4 years ago

Merseyside commented 4 years ago

I use kotlin gradle build in my android project. I need to separate my xml files, so I write something like this:

sourceSets.getByName("main") {

        java.srcDir("src/main/res/")
        java.srcDir("src/main/res/layouts/fragment")
        java.srcDir("src/main/res/layouts/activity")
        java.srcDir("src/main/res/layouts/dialog")
        java.srcDir("src/main/res/layouts/view")
        java.srcDir("src/main/res/value/values-light")
        java.srcDir("src/main/res/value/values-night")
    }

Every folder (activity, fragment, etc.) contains layout folder as expected. But when i try to compile it, I got an error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android-app:generateUnitsClasses'.
> org.xml.sax.SAXParseException; systemId: file:/.../Workspace/moko-template/android-app/src/main/res/layouts/activity/; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

I using Studio 3.6.3 and in IDE this folders are blue(includes). Also xmlns:android value highlighted red and says "URI is not registered".

How can I compile project using kts?

Merseyside commented 4 years ago

I changed java -> res. Now xml looks nice. But i still getting this error.