Build failed due to genetared files
GautierLouis opened this issue · 3 comments
Hello,
Very nice lib, unfortunally I can't make it working
I build my module using ./gradlew :common:umbrella:build
@ExportedScopeProvider
class MainScopeProvider : ScopeProvider {
override val scope : CoroutineScope = MainScope()
}
@ToNativeClass(name = "GetServersUseCaseIos", launchOnScope = MainScopeProvider::class)
class GetServersUseCase(
private val serversRemoteSource: DiscoveryServersRemoteSource
) {
suspend fun executeWithUsername(username: String): List<Server> {
val domain = username.split('@').last()
val servers = serversRemoteSource.getServers(domain)
...
return servers
}
}
plugins {
kotlin("multiplatform")
kotlin("kapt")
id("com.android.library")
}
kotlin {
// Android target
android {
compilations.all {
kotlinOptions { jvmTarget = "1.8" }
}
}
// iOS target
ios {
binaries {
framework {
baseName = "discovery"
}
}
}
sourceSets {
val koruVersion = "0.4.0"
sourceSets["commonMain"].dependencies {
// our own libs
implementation(project(":common:api_models"))
implementation(project(":common:api_shared"))
implementation("com.futuremind:koru:$koruVersion")
configurations.get("kapt").dependencies.add(
org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency(
"com.futuremind", "koru-processor", koruVersion
)
)
}
sourceSets["commonTest"].dependencies {}
sourceSets["androidMain"].dependencies {
implementation(Ktor.clientOkHttp)
}
val androidAndroidTestRelease by getting
val androidTest by getting {
dependsOn(androidAndroidTestRelease)
dependencies {}
}
val iosMain by getting {
kotlin.srcDir("${buildDir.absolutePath}/generated/source/kaptKotlin/")
}
sourceSets["iosTest"].dependencies {}
}
}
When I look generated files I see two versions (one for debug, one for release) that cause a redeclaration error. Same for MainScopeProvider
What am I missing ?
had the same issue.
In your build.gradle.kts change the line
val iosMain by getting {
kotlin.srcDir("${buildDir.absolutePath}/generated/source/kaptKotlin/")
}
to either debug/or release
val iosMain by getting {
kotlin.srcDir("${buildDir.absolutePath}/generated/source/kaptKotlin/debug")
}
Does it fail at build or just in ide?
Seems like a good workaround @837, thanks.
I didn't have such an issue before, it builds fine with either debug or release. If its just ide issue, you might also try marking the appropriate folder as sources dir. Android studio is still a bit confused around kotlin multiplatform directories, I think.
Thanks for the help
It's working with either /debug oor /release :D
@micHar It's not just an IDE issue, because the build fails and the framework is not generated.
I wonder if I should use make it dynamic for debug and release mode, but for the moment it's seems to working as expected;
Thanks guys