diff --git a/.idea/dictionaries/sebastiansellmair.xml b/.idea/dictionaries/sebastiansellmair.xml
index 788e7cf8227..ef613c08528 100644
--- a/.idea/dictionaries/sebastiansellmair.xml
+++ b/.idea/dictionaries/sebastiansellmair.xml
@@ -3,6 +3,7 @@
cinterops
interops
+ klibrary
-
+
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CommonizerHierarchicalIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CommonizerHierarchicalIT.kt
new file mode 100644
index 00000000000..2ce20056284
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CommonizerHierarchicalIT.kt
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.gradle
+
+import org.gradle.internal.os.OperatingSystem
+import org.junit.Test
+
+class CommonizerHierarchicalIT : BaseGradleIT() {
+ override val defaultGradleVersion: GradleVersionRequired = GradleVersionRequired.FOR_MPP_SUPPORT
+
+ @Test
+ fun `test commonizeHierarchically metadata compilations`() {
+ with(Project("commonizeHierarchically")) {
+ if (Os.canCompileApple) {
+ build(":p1:compileIosMainKotlinMetadata") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/metadata/iosMain/klib/p1_iosMain.klib")
+ }
+
+ build(":p1:compileAppleMainKotlinMetadata") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/metadata/appleMain/klib/p1_appleMain.klib")
+ }
+ }
+
+ if (Os.canCompileLinux) {
+ build(":p1:compileLinuxMainKotlinMetadata") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/metadata/linuxMain/klib/p1_linuxMain.klib")
+ }
+ }
+
+ if (Os.canCompileWindows) {
+ build(":p1:compileWindowsMainKotlinMetadata") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/metadata/windowsMain/klib/p1_windowsMain.klib")
+ }
+ }
+
+ if (Os.canCompileApple || Os.canCompileLinux) {
+ build(":p1:compileAppleAndLinuxMainKotlinMetadata") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/metadata/appleAndLinuxMain/klib/p1_appleAndLinuxMain.klib")
+ }
+ }
+
+ if (Os.canCompileApple || Os.canCompileLinux || Os.canCompileWindows) {
+ build(":p1:compileNativeMainKotlinMetadata") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/metadata/nativeMain/klib/p1_nativeMain.klib")
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `test commonizeHierarchically Klibrary compilations`() {
+ with(Project("commonizeHierarchically")) {
+ if (Os.canCompileApple) {
+ build(":p1:iosArm64MainKlibrary", ":p1:iosX64MainKlibrary", ":p1:macosMainKlibrary") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/iosArm64/main/klib/p1.klib")
+ assertFileExists("p1/build/classes/kotlin/iosX64/main/klib/p1.klib")
+ assertFileExists("p1/build/classes/kotlin/macos/main/klib/p1.klib")
+ }
+ }
+
+ if (Os.canCompileLinux) {
+ build(":p1:linuxX64MainKlibrary", ":p1:linuxArm64MainKlibrary") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/linuxX64/main/klib/p1.klib")
+ assertFileExists("p1/build/classes/kotlin/linuxArm64/main/klib/p1.klib")
+ }
+ }
+
+ if (Os.canCompileWindows) {
+ build(":p1:windowsX64MainKlibrary", ":p1:windowsX86MainKlibrary") {
+ assertSuccessful()
+ assertFileExists("p1/build/classes/kotlin/windowsX64/main/klib/p1.klib")
+ assertFileExists("p1/build/classes/kotlin/windowsX86/main/klib/p1.klib")
+ }
+ }
+ }
+ }
+
+ private object Os {
+ private val os = OperatingSystem.current()
+ val canCompileApple get() = os.isMacOsX
+ val canCompileLinux get() = os.isLinux || os.isMacOsX
+ val canCompileWindows get() = os.isWindows
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/build.gradle.kts
new file mode 100644
index 00000000000..448f4930cb0
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/build.gradle.kts
@@ -0,0 +1,10 @@
+plugins {
+ kotlin("multiplatform") apply false
+}
+
+allprojects {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/gradle.properties
new file mode 100644
index 00000000000..f4feb98d8a6
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/gradle.properties
@@ -0,0 +1,7 @@
+kotlin.code.style=official
+org.gradle.debug=false
+
+kotlin.mpp.enableGranularSourceSetsMetadata=true
+kotlin.native.enableDependencyPropagation=false
+kotlin.mpp.enableCInteropCommonization=true
+kotlin.mpp.enableHierarchicalCommonization=true
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/build.gradle.kts
new file mode 100644
index 00000000000..6252242da0c
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/build.gradle.kts
@@ -0,0 +1,79 @@
+import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
+import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
+
+operator fun KotlinSourceSet.invoke(builder: SourceSetHierarchyBuilder.() -> Unit): KotlinSourceSet {
+ SourceSetHierarchyBuilder(this).builder()
+ return this
+}
+
+class SourceSetHierarchyBuilder(private val node: KotlinSourceSet) {
+ operator fun KotlinSourceSet.unaryMinus() = this.dependsOn(node)
+}
+
+plugins {
+ kotlin("multiplatform")
+}
+
+kotlin {
+ js()
+ jvm()
+
+ linuxX64()
+ linuxArm64()
+
+ macosX64("macos")
+ ios()
+
+ mingwX64("windowsX64")
+ mingwX86("windowsX86")
+
+ val commonMain by sourceSets.getting
+ val concurrentMain by sourceSets.creating
+ val jvmMain by sourceSets.getting
+ val jsMain by sourceSets.getting
+ val nativeMain by sourceSets.creating
+ val appleAndLinuxMain by sourceSets.creating
+ val linuxMain by sourceSets.creating
+ val linuxX64Main by sourceSets.getting
+ val linuxArm64Main by sourceSets.getting
+ val appleMain by sourceSets.creating
+ val macosMain by sourceSets.getting
+ val iosMain by sourceSets.getting
+ val windowsMain by sourceSets.creating
+ val windowsX64Main by sourceSets.getting
+ val windowsX86Main by sourceSets.getting
+
+ commonMain {
+ -jsMain
+ -concurrentMain {
+ -jvmMain
+ -nativeMain {
+ -appleAndLinuxMain {
+ -appleMain {
+ -iosMain
+ -macosMain
+ }
+ -linuxMain {
+ -linuxArm64Main
+ -linuxX64Main
+ }
+ }
+ -windowsMain {
+ -windowsX64Main
+ -windowsX86Main
+ }
+ }
+ }
+ }
+
+
+ sourceSets.all {
+ languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
+ }
+
+ targets.withType().forEach { target ->
+ target.compilations.getByName("main").cinterops.create("withPosix") {
+ header(file("libs/withPosix.h"))
+ }
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/libs/withPosix.h b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/libs/withPosix.h
new file mode 100644
index 00000000000..d71048f7049
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/libs/withPosix.h
@@ -0,0 +1,43 @@
+#include
+#include
+#include
+
+struct stat getStructFromPosix();
+
+struct stat* getStructPointerFromPosix();
+
+struct MyStruct getMyStruct();
+
+struct MyStruct* getMyStructPointer();
+
+struct MyStruct {
+ struct stat posixProperty;
+
+ #if _WIN32
+ long long longProperty;
+ #else
+ long longProperty;
+ #endif
+
+ double doubleProperty;
+
+ int32_t int32tProperty;
+
+ int64_t int64tProperty;
+
+ #if __linux__
+ bool linuxOnlyProperty;
+ #endif
+
+ #if __APPLE__
+ bool appleOnlyProperty;
+ #include "TargetConditionals.h"
+ #if TARGET_OS_IPHONE
+ bool iosOnlyProperty;
+ #endif
+ #endif
+
+ #if _WIN32
+ bool windowsOnlyProperty;
+ #endif
+};
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/appleAndLinuxMain/kotlin/AppleAndLinuxMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/appleAndLinuxMain/kotlin/AppleAndLinuxMain.kt
new file mode 100644
index 00000000000..d6b2954179d
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/appleAndLinuxMain/kotlin/AppleAndLinuxMain.kt
@@ -0,0 +1,21 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object AppleAndLinuxMain {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/appleMain/kotlin/AppleMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/appleMain/kotlin/AppleMain.kt
new file mode 100644
index 00000000000..b2119df24b4
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/appleMain/kotlin/AppleMain.kt
@@ -0,0 +1,22 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object AppleMain {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ val appleOnlyProperty: Boolean = struct.appleOnlyProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/commonMain/kotlin/CommonMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/commonMain/kotlin/CommonMain.kt
new file mode 100644
index 00000000000..654793fae33
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/commonMain/kotlin/CommonMain.kt
@@ -0,0 +1,2 @@
+class CommonMain {
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/iosMain/kotlin/IosMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/iosMain/kotlin/IosMain.kt
new file mode 100644
index 00000000000..e4afdb6e07f
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/iosMain/kotlin/IosMain.kt
@@ -0,0 +1,23 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object IosMain {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ val appleOnly: Boolean = struct.appleOnlyProperty
+ val iosOnly: Boolean = struct.iosOnlyProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxArm64Main/kotlin/LinuxArm64Main.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxArm64Main/kotlin/LinuxArm64Main.kt
new file mode 100644
index 00000000000..f88f2b7e01c
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxArm64Main/kotlin/LinuxArm64Main.kt
@@ -0,0 +1,22 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object LinuxArm64Main {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ val linuxOnlyProperty: Boolean = struct.linuxOnlyProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxMain/kotlin/LinuxMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxMain/kotlin/LinuxMain.kt
new file mode 100644
index 00000000000..693a14477b6
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxMain/kotlin/LinuxMain.kt
@@ -0,0 +1,22 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object LinuxMain {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ val linuxOnlyProperty: Boolean = struct.linuxOnlyProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxX64Main/kotlin/LinuxX64Main.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxX64Main/kotlin/LinuxX64Main.kt
new file mode 100644
index 00000000000..0bf119cfe88
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/linuxX64Main/kotlin/LinuxX64Main.kt
@@ -0,0 +1,22 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object LinuxX64Main {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ val linuxOnlyProperty: Boolean = struct.linuxOnlyProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/macosMain/kotlin/MacosMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/macosMain/kotlin/MacosMain.kt
new file mode 100644
index 00000000000..84d01735d9a
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/macosMain/kotlin/MacosMain.kt
@@ -0,0 +1,22 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object MacosMain {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ val appleOnlyProperty: Boolean = struct.appleOnlyProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/nativeInterop/cinterop/withPosix.def b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/nativeInterop/cinterop/withPosix.def
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/nativeMain/kotlin/NativeMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/nativeMain/kotlin/NativeMain.kt
new file mode 100644
index 00000000000..148942f4698
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/nativeMain/kotlin/NativeMain.kt
@@ -0,0 +1,19 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object NativeMain {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/windowsMain/kotlin/WindowsMain.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/windowsMain/kotlin/WindowsMain.kt
new file mode 100644
index 00000000000..2c442617931
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/p1/src/windowsMain/kotlin/WindowsMain.kt
@@ -0,0 +1,22 @@
+@file:Suppress("unused")
+
+import kotlinx.cinterop.pointed
+import platform.posix.stat
+import withPosix.getMyStructPointer
+import withPosix.getStructFromPosix
+import withPosix.getStructPointerFromPosix
+
+object WindowsMain {
+ val structFromPosix = getStructFromPosix()
+ val structPointerFromPosix = getStructPointerFromPosix()
+
+ object MyStruct {
+ val struct = getMyStructPointer()?.pointed ?: error("Missing my struct")
+ val posixProperty: stat = struct.posixProperty
+ val longProperty: Long = struct.longProperty
+ val doubleProperty: Double = struct.doubleProperty
+ val int32tProperty: Int = struct.int32tProperty
+ val int64TProperty: Long = struct.int64tProperty
+ val windowsOnly: Boolean = struct.windowsOnlyProperty
+ }
+}
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/settings.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/settings.gradle.kts
new file mode 100644
index 00000000000..629f9fe9ecb
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeHierarchically/settings.gradle.kts
@@ -0,0 +1,12 @@
+pluginManagement {
+ repositories {
+ mavenLocal()
+ gradlePluginPortal()
+ }
+ val kotlin_version: String by settings
+ plugins {
+ kotlin("multiplatform").version(kotlin_version)
+ }
+}
+
+include(":p1")