~I'm using `applyDefaultHierarchyTemplate` to crea...
# gradle
e
I'm using
applyDefaultHierarchyTemplate
to create
commonJs
source sets for
js
and
wasmJs
. I want to create a task that uses the
commonJsMain
and
commonJsTest
source sets , but I get an error saying that those source sets don't exist. I'm guessing that
applyDefaultHierarchyTemplate
doesn't create them synchronously, so is the best approach to do something like this:
Turns out you actually have to call the function where this code is in order for it to actually run 😬
Copy code
applyDefaultHierarchyTemplate {
      group("commonJs") {
        withJs()
        withWasm()
      }
    }

    sourceSets.register("commonJsMain")
    sourceSets.register("commonJsTest")
🤔 1
m
I guess
Copy code
kotlin.sourceSets.all { 
  // react to sourceSets being added
}
?
Or the good old
afterEvaluate {}
🙈 😬
e
Or call the function that calls it 🙈
m
Ah, didn't see that! That works too!
t
Could you open an issue with your use-case?
e
@tapchicoma sorry it wasn't clear from my edit, it was my fault because I wasn't calling my function that was calling
applyDefaultHierarchyTemplate
👍 1