Skip to content

[ksp] java.lang.IllegalArgumentException: this and base files have different roots #1079

@mtrakal

Description

@mtrakal

KSP didn't respect gradle buildDir variable.

Using RAM disk (Z: drive) for build folders:

USER_HOME/.gradle/init.gradle

allprojects {
    buildDir="Z:/build/$group/$name/"
}

app/build.gradle

android {
    sourceSets {
        androidTest.assets.srcDirs += files("$projectDir/schemas".toString())

        main.kotlin.srcDirs += '$buildDir/generated/ksp/$name/kotlin/'
        test.kotlin.srcDirs += '$buildDir/generated/ksp/$name/kotlin/'
    }

    buildTypes {
       // https://github.com/InsertKoinIO/koin-annotations
        applicationVariants.all { variant ->
            variant.sourceSets.java.each {
                it.srcDirs += "$buildDir/generated/ksp/${variant.name}/kotlin/"
            }
        }
   }
}

But build failed with:

e: [ksp] java.lang.IllegalArgumentException: this and base files have different roots: Z:\build\ProjectX\app\generated\ksp\stagingDebug\java\cz\packagename\data\database\dao\UserOauthDao_Impl.java and D:\Projects\company\ProjectX\app.
	at kotlin.io.FilesKt__UtilsKt.toRelativeString(Utils.kt:117)
	at kotlin.io.FilesKt__UtilsKt.relativeTo(Utils.kt:128)
	at com.google.devtools.ksp.processing.impl.CodeGeneratorImpl.associate(CodeGeneratorImpl.kt:119)
	at com.google.devtools.ksp.processing.impl.CodeGeneratorImpl.createNewFile(CodeGeneratorImpl.kt:92)
	at androidx.room.compiler.processing.ksp.KspFiler.createNewFile(KspFiler.kt:106)
	at androidx.room.compiler.processing.ksp.KspFiler.write(KspFiler.kt:41)
	at androidx.room.compiler.processing.XFilerKt.writeTo(XFiler.kt:44)
	at androidx.room.compiler.processing.XFilerKt.writeTo$default(XFiler.kt:43)
	at androidx.room.writer.ClassWriter.write(ClassWriter.kt:75)
	at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:111)
	at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:42)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions