Interface KotlinHierarchyDsl

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Unit applyHierarchyTemplate(KotlinHierarchyTemplate template) Will apply the given template to the project.
      abstract Unit applyHierarchyTemplate(KotlinHierarchyTemplate template, Function1<KotlinHierarchyBuilder.Root, Unit> extension) Similar to applyHierarchyTemplate, but allows to extend the provided templateLet's imagine we would additionally like to share code between linux and apple (unixLike)
      kotlin {
          applyHierarchyTemplate(KotlinHierarchyTemplate.default) {
              group("native") { // <- we can re-declare already existing groups and connect children to it!
                  group("unixLike") {
                      withLinux()
                      withApple()
                  }
              }
          }
      }
      abstract Unit applyHierarchyTemplate(Function1<KotlinHierarchyBuilder.Root, Unit> template) Allows to create a fully custom hierarchy (no defaults applied) Note: Using the custom hierarchy will also require to set the edges to 'commonMain' and 'commonTest' SourceSets by using the common group.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • applyHierarchyTemplate

         abstract Unit applyHierarchyTemplate(KotlinHierarchyTemplate template)

        Will apply the given template to the project.

        (see KotlinMultiplatformExtension.applyDefaultHierarchyTemplate)

        kotlin {
            applyHierarchyTemplate(KotlinHierarchyTemplate.default)
            iosX64()
            iosArm64()
            iosSimulatorArm64()
            linuxX64()
            // ...
        }
      • applyHierarchyTemplate

         abstract Unit applyHierarchyTemplate(KotlinHierarchyTemplate template, Function1<KotlinHierarchyBuilder.Root, Unit> extension)

        Similar to applyHierarchyTemplate, but allows to extend the provided template

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

        kotlin {
            applyHierarchyTemplate(KotlinHierarchyTemplate.default) {
                group("native") { // <- we can re-declare already existing groups and connect children to it!
                    group("unixLike") {
                        withLinux()
                        withApple()
                    }
                }
            }
        }
      • applyHierarchyTemplate

         abstract Unit applyHierarchyTemplate(Function1<KotlinHierarchyBuilder.Root, Unit> template)

        Allows to create a fully custom hierarchy (no defaults applied) Note: Using the custom hierarchy will also require to set the edges to 'commonMain' and 'commonTest' SourceSets by using the common group.

        Sharing code between iOS and a jvmTarget:

        applyHierarchyTemplate {
            common {
                withJvm()
                group("ios") {
                    withIos()
                }
            }
        }

        Will create two KotlinSourceSetTree using the 'common' and 'ios' groups, applied on the "test" and "main" compilations: When the following targets are specified:

        • jvm()

        • iosX64()

        • iosArm64()

                               "main"                               "test"
                             commonMain                           commonTest
                                 |                                    |
                                 |                                    |
                      +----------+----------+              +----------+----------+
                      |                     |              |                     |
                    iosMain               jvmMain        iosTest               jvmTest
                      |                                    |
                 +----+-----+                         +----+-----+
                 |          |                         |          |
            iosX64Main   iosArm64Main            iosX64Test   iosArm64Test
        applyHierarchyTemplate {
            common {
                group("ios") {
                    withIos()
                }
        
                group("frontend") {
                    withJvm()
                    group("ios") // <- ! We can again reference the 'ios' group
                }
        
                group("apple") {
                    withMacos()
                    group("ios") // <- ! We can again reference the 'ios' group
                }
            }
        }

        In this case, the group "ios" can be created with 'group("ios")' and later referenced with the same construction to build the tree. Applying the descriptor from the example to the following targets:

        • iosX64()

        • iosArm64()

        • macosX64()

        • jvm()

        will create the following 'main' KotlinSourceSetTree:

                                 commonMain
                                      |
                         +------------+----------+
                         |                       |
                     frontendMain            appleMain
                         |                        |
               +---------+------------+-----------+----------+
               |                      |                      |
            jvmMain                iosMain               macosX64Main
                                      |
                                      |
                                 +----+----+
                                 |         |
                           iosX64Main   iosArm64Main