Skolson5903
07/09/2020, 8:37 PMsrc
androidMain
androidTest
commonMain
commonTest
iosMain
iosTest
I manually added a buildSrc setup, just an FYI, don't think it's relevant to the question.
In order to add dependencies for each of the environments, I ended up having to add this snippet to the kotlin sourceSets definition to add these as sourceSets:
val androidMain by creating {
dependsOn(commonMain)
dependencies {
...
}
}
val androidTest by creating {
dependsOn(commonMain) dependencies {
...
}
}
commonMain and commonTest were already sourceSets, so I could use the "by getting" clause to work with those. But androidMain and androidTest were not according to gradle, so "by creating" was required. Once I did this, after resync Idea and gradle both show them as sourceSets, but not quite identically. See attached file to see what the Idea project window shows after the above.
Is this expected behavior? Seems like if these dirs gets created by the wizard, the android directories should also be configured as sourcesets like the common and IOS stuff is. Also my gradle skills are poor, so I'm having trouble getting androidTest to be treated as a unit test sourceSet. I'm using Kotest 4.1.1 in the ioCommon.androidTest directory (testing code in commonMain) and am having trouble running unit tests in debug from the IDE
because of various gradle-related classpath issues. So my build.gradle.kts is still not correct for what I need.
I'd appreciate any info if I'm doing something wrong. Am also willing to send whatever would be helpful if this really is an actual issue. The project has very little source in it as of yet, so it is easy to try changes until the setup is correct. So if anyone has suggestions of stuff to try, I can also
do those.
Thanks in advance forr any info...r4zzz4k
07/09/2020, 10:15 PMSkolson5903
07/11/2020, 6:43 PMSkolson5903
07/11/2020, 6:44 PMSkolson5903
07/11/2020, 6:57 PMIOException prevents gradle sync
I had to edit the generated local.properties line:
D:\Android\sdk to D:\\Android\\sdk
The generated one did not escape "\" properly (I'm on windows). After that sync works, except then I did these steps (mostly minor)
```
• Changed dependency on jdk7 to jdk8
• updated androidx.core:core-ktx:1.3.0 from 1.2.0 in shared
• inserted these in shard androidTest kotlin sourceSet
dependencies {
implementation("io.kotestkotest core jvm4.1.1")
implementation("io.kotestkotest assertions core jvm4.1.1")
implementation("io.kotestkotest runner console jvm4.1.1")
runtimeOnly("org.junit.jupiterjunit jupiter engine5.6.2")
}```
sync resulted with this:
11:30 AM The IDE modules below were removed by the Gradle project reload:
shared.iosMain
shared.iosTest
shared.commonMain...
Do you know why this happens? I chose to open dialog and recover all 4. which created .iml files for the various shared modules - seems like an error. Anyway, forging ahead
• Copied in three source files
2 kotlin files in commonMain
1 kotlin file in androidTest (BasicsTest)
At this point the source files look like they will build fine - no syntax errors
• Installed the newest Kotest plugin from the marketplace
• Attempted to use Kotest plugin to run the one test in debug. Result:
Exception in thread "main" java.lang.ClassNotFoundException: BasicsTest
So maybe this is a Kotest plugin issue? As far as I can see the Gradle build triggered by the plugin doesn't compile the BasicsTest class, so it isn't on the classpath. Anyway I'm still experimenting. If you think this sounds more appropriate for posting in the kotest channel, lemme know...r4zzz4k
07/11/2020, 7:05 PM./gradlew
via terminal to check whether the project can be built and tests can be run by Gradle -- so it this IDE-only issue or not.
It's also probably more logical to move to either #kotest or #multiplatform depending on the outcome.Skolson5903
07/11/2020, 7:05 PMSkolson5903
07/11/2020, 7:06 PMSkolson5903
07/19/2020, 6:43 PMimport kotlin.test.Test
import kotlin.test.assertTrue
class AnyTest {
@Test
fun failingTest() {
assertTrue(false)
}
}
• Build project. This succeeds with the default gradle 6.3 and also 6.4.1. Fails on 6.5.1 so I left mine on 6.4.1, but 6.3 acts the same as 6.4.1
• Run check task. The project level "check", and the shared level "check" both fail with the same compile error:
> Task :shared:compileReleaseJavaWithJavac
> Task :shared:compileReleaseUnitTestKotlinAndroid FAILED
e: D:\WorkingIntelliJ\untitled\shared\src\commonTest\kotlin\FooTest.kt: (1, 20): Unresolved reference: Test
e: D:\WorkingIntelliJ\untitled\shared\src\commonTest\kotlin\FooTest.kt: (2, 20): Unresolved reference: assertTrue
e: D:\WorkingIntelliJ\untitled\shared\src\commonTest\kotlin\FooTest.kt: (5, 6): Unresolved reference: Test
e: D:\WorkingIntelliJ\untitled\shared\src\commonTest\kotlin\FooTest.kt: (7, 9): Unresolved reference: assertTrue
So despite gradle being able to build the project ok, and the IDE showing the test source buildable with no problem, for some reason gradle isn't seeing the "kotlin.test" classes during the test tasks. It looks to me like the wizard generates the correct dependencies in the commonTest sourceset:
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
I'm unsure what can cause gradle to fail with a missing dependency running tests that it can compile/build just fine. Any suggestions where I should take this next?Skolson5903
07/19/2020, 6:59 PM:shared:compileDebugAndroidTestSources
:shared:compileDebugUnitTestKotlinAndroid
I was forgetting that project builds don't build tests. Sorry. Anyway, somehow the test builds are not using the commonTest dependencies for source in the commonTest sourceset.r4zzz4k
07/19/2020, 7:12 PMSkolson5903
07/21/2020, 6:36 PMval androidTest by getting
val iosMain by getting
val iosTest by getting
I've got a base git commit of this guinea pig project that is all the files from the wizard without changes, I'm going to just focus on getting the one bogus multiplatform test to run next, and will commit useful changes, if I find any. If I find useful changes, I'll do granular commits with comments on each until (hopefully) I get a successful run of the shared:test task.Skolson5903
07/21/2020, 7:01 PMgradle.taskGraph.whenReady(closureOf<TaskExecutionGraph> {
println("Found task graph: $this")
println("Found " + allTasks.size + " tasks.")
allTasks.forEach { task ->
println(task)
task.dependsOn.forEach { dep ->
println(" - $dep")
}
task.inputs.files.forEach {
println("Input - ${it.absolutePath}")
}
}
})
And running shard:test gradle task produced this for the failing subtask:Skolson5903
07/21/2020, 7:01 PMtask ':shared:compileDebugUnitTestKotlinAndroid'
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.4-M3\3d648cd3e9ac8cea2febc25dccd42fa2667fac75\kotlin-stdlib-jdk7-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\transforms-2\files-2.1\656cf8328a1f1d2fa1bdeb986a444437\core-ktx-1.2.0-api.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-test-common\1.4-M3\7b9619fe019c49b8d6991a348e9a84af7102e11b\kotlin-test-common-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-test-annotations-common\1.4-M3\23cc8a186707afc74a144ad3acd1ec840a6d0490\kotlin-test-annotations-common-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-android-extensions-runtime\1.4-M3\fba99da6f19ee1bf749fe1e32b26612ddd0bbca3\kotlin-android-extensions-runtime-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.4-M3\d434fee0dcf45da74fbb897d7db3e24993e6be2c\kotlin-stdlib-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.4-M3\9f0db946b8160929e99f26df2ae3e65356978141\kotlin-stdlib-common-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar
Input - C:\Users\skols\.gradle\caches\transforms-2\files-2.1\61e1b3b81ccbb7a0671a1bba91af7b93\core-1.2.0-api.jar
Input - C:\Users\skols\.gradle\caches\transforms-2\files-2.1\bccb0d8a706b37d7233824b303cf1493\lifecycle-runtime-2.0.0-api.jar
Input - C:\Users\skols\.gradle\caches\transforms-2\files-2.1\b7c02a65a494426908f214e4c4207d13\versionedparcelable-1.1.0-api.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\androidx.lifecycle\lifecycle-common\2.0.0\e070ffae07452331bc5684734fce6831d531785c\lifecycle-common-2.0.0.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\androidx.arch.core\core-common\2.0.0\bb21b9a11761451b51624ac428d1f1bb5deeac38\core-common-2.0.0.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\androidx.collection\collection\1.0.0\42858b26cafdaa69b6149f45dfc2894007bc2c7a\collection-1.0.0.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.1.0\e3a6fb2f40e3a3842e6b7472628ba4ce416ea4c8\annotation-1.1.0.jar
Input - D:\WorkingIntelliJ\Mpp2\shared\build\intermediates\javac\debug\classes
Input - D:\WorkingIntelliJ\Mpp2\shared\build\tmp\kotlin-classes\debug
Input - D:\WorkingIntelliJ\Mpp2\shared\build\intermediates\compile_only_not_namespaced_r_class_jar\debug\R.jar
Input - D:\Android\sdk\platforms\android-29\android.jar
Input - D:\WorkingIntelliJ\Mpp2\shared\src\commonTest\kotlin\FooTest.kt
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-compiler-embeddable\1.4-M3\67dfdd73f5fdc275f857d9aab325bd205003fdd6\kotlin-compiler-embeddable-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.4-M3\a00dc5d9fe4c80832afd33c61310e9ad69d7af16\kotlin-reflect-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-script-runtime\1.4-M3\f41bf9bc6b35b83040eedcdd482651d2f843e12f\kotlin-script-runtime-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-daemon-embeddable\1.4-M3\b214990d2189e8eb24f79b4564f834023f8f7192\kotlin-daemon-embeddable-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.intellij.deps\trove4j\1.0.20181211\216c2e14b070f334479d800987affe4054cd563f\trove4j-1.0.20181211.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-compiler-embeddable\1.4-M3\4883c12980036982b3bf069c7fa4ab693befe237\kotlin-scripting-compiler-embeddable-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-android-extensions\1.4-M3\fcb9dabe0c5e505d2fe2d147e0ed005db31a279f\kotlin-android-extensions-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-compiler-impl-embeddable\1.4-M3\8b3469ce9d46ec8cc68e5ba1154b757df6527102\kotlin-scripting-compiler-impl-embeddable-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-jvm\1.4-M3\766489c2c88ab457ccd7b246163b35baad8feb97\kotlin-scripting-jvm-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-common\1.4-M3\b1e0404ba3ecbc27b5fab4a2a2008ba827405e21\kotlin-scripting-common-1.4-M3.jar
Input - C:\Users\skols\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlinx\kotlinx-coroutines-core\1.3.7\8e2eb78158638b33793d204ffef0b65c4a578e1c\kotlinx-coroutines-core-1.3.7.jar
Skolson5903
07/21/2020, 7:01 PMSkolson5903
07/21/2020, 7:38 PMSkolson5903
07/23/2020, 5:00 PM