I'm trying to bump my gradle.kts file to use 1.7.2...
# gradle
m
I'm trying to bump my gradle.kts file to use 1.7.21 from 1.6.21. After bumping the kotlin version, this line is failing:
SourceSet with name 'jvmTestIntegration' not found.
It's strange because it worked before (and works again if I revert) the bump from kotlin 1.6 to 1.7. I saw in the "what's new in 1.7" that sourcesets and compiling both changed a bit, but I'm unable to understand how I could have broken things or what I need to do to fix it. FWIW
jvmTestIntegration
is meant to be a second test directory that contains slower running tests. Any tips or pointing in the right direction would be much appreciated. 🙂
Copy code
compilations {
            val main by getting
            val jvmTestIntegration by compilations.creating { //Breaks here
                defaultSourceSet {
                    dependencies {
                        implementation(main.compileDependencyFiles + main.output.classesDirs)
                        implementation(kotlin("test-junit"))
                    }
                }
                tasks.register<Test>("test-integration") {
                    group = "verification"
                    description = "Runs the integration tests."
                    classpath = compileDependencyFiles + runtimeDependencyFiles + output.allOutputs
                    testClassesDirs = output.classesDirs
                }
            }
Reviewing the docs I seem to be doing exactly what it's instructing, and that worked before updating my kotlin version. 🤔
v
In what you linked to, you have
Copy code
sourceSets {
    val jvmTestIntegration by creating {
and
Copy code
compilations {
    val testIntegration by compilations.creating {
In what you showed here you have
Copy code
compilations {
    val jvmTestIntegration by compilations.creating { //Breaks here
Is that intended?
m
Hey, thanks for the response! Sorry, I've been trying different permutations. FWIW I've tried each of those varients.
I was curious if dropping the
compilations
would make a difference, and I've been experimenting with the name of the
val
just to see if that makes any difference (matching or not matching a source set)
In the current working code (1.6) I both create a source set and a compilation with the same name. It seems like in 1.7 it doesn't look up the source set the same way, and I can't figure out how to pass in the source set for the compilation...
It seems that in 1.6 if I name my compilation
integrationTest2
then my sourceset must be named
jvmIntegrationTest2
. It seems that convention maybe changed in moving to 1.7?
In 1.7, with the same compilation name, the script fails to find
integrationTest2
. Renaming the sourceset to match doesn't fix the issue.
v
I wonder that it even needs one. From the docs I would have guessed that is optional.
m
Yeah, that's what I would think too. I'm struggling to figure out a better way than guessing and checking. I've got to imagine that multiplatform + gradle + custom source sets is common enough.
I wonder if I should repost in the multiplatform channel?
v
But I'd say the naming convention is the same. If I add
kotlin("multiplatform") version "1.7.21"
to my play project and then the example block from the docs you linked to and add a
println(name)
in
defaultSourceSet { ... }
it outputs
jvmIntegrationTest
and if I change the compilation to
jvmIntegrationTest
then it outputs
jvmJvmIntegrationTest
m
Interesting. I wonder why I don't seem to see the same behavior. Let me try to replicate / throw a println in there.
I see the conversion from
testIntegration
to
jvmTestIntegration
happening in 1.6 in the println but I can't get that far in 1.7 and it says it's unable to find
testIntegration
which obviously doesn't have the transformation...
Is it possible I'm somehow creating my sourceset incorrectly for 1.7? I'm currently trying it this way so I can explicitly pass the name:
Copy code
val testIntegrationSource = sourceSets.create("jvmTestIntegration") {
            dependsOn(sourceSets["jvmMain"])
        }
I also tried this for the heck of it:
Copy code
val testIntegration by compilations.creating {
                source(testIntegrationSource)
Wow, I'm getting some indications that it was because I needed to move the
compilations
block closer to the top of the
jvm
block.... testing...
If
withJava()
is used before my block, it fails, if it's after my block, my block passes (though my tests aren't running in current state). I need to see if I can get tests passing again and then possibly remove
withJava()
(I don't remember why I added it).
Removing
withJava
removes my test task and the build fails. Moving it below compilations makes the gradle happy on 1.7, but my integration tests seem to be missing
kotlin.test.*
Ok, moving java down below did in fact work. I'll do some cleanup and then post a diff in case anyone cares, but I appreciate you rubber ducking that with me. Thank you!