Closed andyburris closed 3 years ago
It seems to be looking for an artifact with a samplessources
classifier, which I've never heard of or seen produced. Not sure about this.
Something else to note, what targets have you specified for your mpp build?
You mentioned a project/module called :web:
Should be mentioned that while kotlin-result is now an mpp project it currently only builds artifacts for jvm based mpp projects (so jvm and android). There is currently no js target - if thats something you want you could open an issue requesting it or a pull request.
I have been getting similar issue with one of my own projects... as best I can tell this is an issue when the Multiplatform project has a target for android()
. The functionality was added to the Jetbrains/android project back in Feb 2020, see https://github.com/JetBrains/android/commit/d311db0523c2f04c10a0e9386e4256406f5f29ab
I have the same issue in my MPP. Sometimes when I add a library to commonMain {} it gives me this error (sample sources.jar not found)...
Do you guys have some solution for this problem?
I don't know what samplesources.jar
is or should be, nor why we would want to publish it, so until somebody can shed some light on what that is I can't give an answer
I wonder would this be solved by simply adding the android()
target to the mpp build as suggested above.
It could be because we are only providing a jvm()
target and there is some weird compatibility with mpp/kmm builds. I would imagine there is some gradle magic to get the jvm target to be recognized correctly, but maybe these projects just expects some metadata included with the android target.
We've now got released automatically building artifacts for the JS targets, so maybe it's worth just trying the android ones too and seeing if that fixes this problem for people
So I had a little investigation into adding the android target. Basically it would mean we could output an aar artifact (android library) that can contain android sdk specific code and resources.
Unfortunately to do it seems like a real pita as you have to add a whole bunch of android sdk configuration to get it to work (due to requiring the android plugin to be added to the build which doesnt exactly play nice with the mpp plugin). Managed to only find two articles that kind of detail the steps needed: https://medium.com/vmware-end-user-computing/adding-an-android-target-to-a-kotlin-multiplatform-project-8da72353be14 https://www.desnav.com/how-to-target-ios-android-with-kotlin-for-multi-platform
Still skeptical as to whether this would solve the issue documented here - baffled as to why the jvm target we already provide wouldn't be enough. Also why I'm now reluctant to go down the route of adding this target for all this overhead/boilerplate.
Could someone who has experienced the issue post a link to their affected project?
If it is only happening when you are depending on the kotlin-result lib in an mpp project with an android()
target, how do you have the kotlin-result dependency defined? I wonder if its an issue if you have the dependency set to api
instead of implementation
🤔
Any projects you can point to here would be a great help @mattmook @TomWayne98 @andb3
just to back up this issue. I'm also seeing this.
The error, on android, is:
Failed to resolve: kmmsharedmodule-0.0.1-SNAPSHOT-samplessources
I have tried to import my library as implementation
and as api
without any success.
The kmmsharedmodule
's gradle file has this for kotlin and android:
kotlin {
android()
ios {
binaries {
framework {
baseName = "kmmsharedmodule"
}
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
}
}
val iosMain by getting
val iosTest by getting
}
}
I tried changing android
to this, but it didn't help either:
android {
publishLibraryVariantsGroupedByFlavor = true
}
I'm currently trying to make this work using the gradle task of publishToMavenLocal
any suggestions? Thank you!
@toomanyeduardos as posted by @Munzey, providing an example repository in which you depend on kotlin-result
and encounter the missing artifact exception will help us get one step closer as we can then reliably reproduce it.
also we havent published the iOS artifact yet (see #23 ) so trying to use kotlin-result in common dependencies in a kmm project where you have iOS target defined is going to fail.
I am facing the same samplesources.jar issue.
Can you provide a reproducible example?
@michaelbull OOPS...., commented at the wrong place, Actually, I am also trying to use my own library and It is also looking for samplesources.jar. Don't Know what it is or how to generate one..... Still Figuring like you
@michaelbull Hey as I said earlier , I was facing same issue with my library and today I fixed it , So I tried to test your project too as I hoped I could maybe help.
But after adding a dependency on this Lib it compiled successfully. I have jvm,js,androidTarget as of now in my project where I tested.
If Anybody could share a reproducer , I am more than happy to help and even create a PR if i could fix the issue
PS: if you want to add an Android Target too , I can do that and then maybe those who are facing the issue can test again, adding android target in my project fixed the Issue too
Thanks @Shabinder - knowing that you can depend on this library from an android project without problems is very useful to know 👍. I am tempted to close this issue going forward until somebody submits a reproducible case, as I still can't exactly diagnose the issue reported in the OP on my own computer nor can I find any information as to what this "sourcesjar" thing is.
I can confirm one more thing sourcesjar issue happens if the lib doesn't have all targets which your projects targets.
I ran into this issue with mockk also. FYI, I created https://youtrack.jetbrains.com/issue/KTIJ-10769.
Anyone found a solution for this problem? I'm having the same problem trying to import my kmm library into my android project!
@moeindev this is a general Kotlin MPP problem, see: https://youtrack.jetbrains.com/issue/KTIJ-10769
I'm trying to import
com.michael-bull.kotlin-result:kotlin-result:1.1.8
in thecommonMain
source set in a multiplatform project, but the gradle build is failing with this stacktrace:Gradle import errors project ':web': Unable to build Kotlin project configuration Details: org.gradle.internal.operations.BuildOperationQueueFailure: There was a failure while populating the build operation queue: Could not find kotlin-result-1.1.8-samplessources.jar (com.michael-bull.kotlin-result:kotlin-result:1.1.8). Searched in the following locations: https://repo.maven.apache.org/maven2/com/michael-bull/kotlin-result/kotlin-result/1.1.8/kotlin-result-1.1.8-samplessources.jar Caused by: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find kotlin-result-1.1.8-samplessources.jar (com.michael-bull.kotlin-result:kotlin-result:1.1.8).Searched in the following locations:
https://repo.maven.apache.org/maven2/com/michael-bull/kotlin-result/kotlin-result/1.1.8/kotlin-result-1.1.8-samplessources.jar
I'm using the same dependency in another (JVM-only) project and it works perfectly. Is there something I'm missing with multiplatform configuration that will solve this? Thanks!