Skip to content

Commit db3b063

Browse files
committed
Configure new project file structure
1 parent 9b4d47d commit db3b063

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/build.gradle.kts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import java.net.URL
2+
import java.util.Locale
23
import javax.xml.parsers.DocumentBuilderFactory
34

45
plugins {
@@ -86,9 +87,12 @@ kotlin {
8687
}
8788

8889
sourceSets.all {
90+
val suffixIndex = name.indexOfLast { it.isUpperCase() }
91+
val targetName = name.substring(0, suffixIndex)
92+
val suffix = name.substring(suffixIndex).toLowerCase(Locale.ROOT).takeIf { it != "main" }
8993
// println("SOURCE_SET: $name")
90-
kotlin.setSrcDirs(listOf("$name/src"))
91-
resources.setSrcDirs(listOf("$name/resources"))
94+
kotlin.srcDir("$targetName/${suffix ?: "src"}")
95+
resources.srcDir("$targetName/${suffix?.let { it + "Resources "} ?: "resources"}")
9296
languageSettings.apply {
9397
// progressiveMode = true
9498
useExperimentalAnnotation("kotlin.Experimental")
@@ -98,10 +102,10 @@ kotlin {
98102
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
99103
compilations["main"].cinterops {
100104
create("date") {
101-
val cinteropDir = "$projectDir/nativeMain/cinterop"
105+
val cinteropDir = "$projectDir/native/cinterop"
102106
val dateLibDir = "${project(":").projectDir}/thirdparty/date"
103107
headers("$cinteropDir/public/cdate.h")
104-
defFile("nativeMain/cinterop/date.def")
108+
defFile("native/cinterop/date.def")
105109
// common options
106110
extraOpts("-Xsource-compiler-option", "-std=c++17")
107111
extraOpts("-Xsource-compiler-option", "-I$cinteropDir/public")
@@ -118,7 +122,7 @@ kotlin {
118122
}
119123
}
120124
compilations["main"].defaultSourceSet {
121-
kotlin.srcDir("nativeMain/cinterop_actuals")
125+
kotlin.srcDir("native/cinterop_actuals")
122126
}
123127
compilations["test"].kotlinOptions {
124128
freeCompilerArgs += listOf("-trw")

0 commit comments

Comments
 (0)