Package 

Interface KotlinTargetHierarchyDsl

    • Constructor Detail

    • Method Detail

      • default

         abstract Unit default(Function1<KotlinTargetHierarchyBuilder, Unit> describeExtension)

        Set's up a 'natural'/'default' hierarchy withing KotlinTarget's in the project.

        kotlin {
            targetHierarchy.default() // <- position of this call is not relevant!
        
            iosX64()
            iosArm64()
            linuxX64()
            linuxArm64()
        }

        Will create the following SourceSets: `iosMain, iosTest, appleMain, appleTest, linuxMain, linuxTest, nativeMain, nativeTest

        Hierarchy:

                                                                                common
                                                                                   |
                                                                 +-----------------+-------------------+
                                                                 |                                     |
        
                                                               native                                 ...
        
                                                                |
                                                                |
                                                                |
                    +----------------------+--------------------+-----------------------+
                    |                      |                    |                       |
        
                  apple                  linux                mingw              androidNative
        
                    |
             +-----------+------------+------------+
             |           |            |            |
        
            macos       ios         tvos        watchos

        Let's imagine we would additionally like to share code between linux and apple (unixLike)

        kotlin {
            targetHierarchy.default { target ->
                group("native") { // <- we can re-declare already existing groups and connect children to it!
                    group("unixLike") {
                        withLinux()
                        withApple()
                    }
                }
            }
        }
        Parameters:
        describeExtension - : Additional groups can be described to extend the 'default'/'natural' hierarchy: