1
1
import java.net.URL
2
+ import java.util.Locale
2
3
import javax.xml.parsers.DocumentBuilderFactory
3
4
4
5
plugins {
@@ -86,9 +87,12 @@ kotlin {
86
87
}
87
88
88
89
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" }
89
93
// 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" } " )
92
96
languageSettings.apply {
93
97
// progressiveMode = true
94
98
useExperimentalAnnotation(" kotlin.Experimental" )
@@ -98,10 +102,10 @@ kotlin {
98
102
targets.withType< org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget > {
99
103
compilations[" main" ].cinterops {
100
104
create(" date" ) {
101
- val cinteropDir = " $projectDir /nativeMain /cinterop"
105
+ val cinteropDir = " $projectDir /native /cinterop"
102
106
val dateLibDir = " ${project(" :" ).projectDir} /thirdparty/date"
103
107
headers(" $cinteropDir /public/cdate.h" )
104
- defFile(" nativeMain /cinterop/date.def" )
108
+ defFile(" native /cinterop/date.def" )
105
109
// common options
106
110
extraOpts(" -Xsource-compiler-option" , " -std=c++17" )
107
111
extraOpts(" -Xsource-compiler-option" , " -I$cinteropDir /public" )
@@ -118,7 +122,7 @@ kotlin {
118
122
}
119
123
}
120
124
compilations[" main" ].defaultSourceSet {
121
- kotlin.srcDir(" nativeMain /cinterop_actuals" )
125
+ kotlin.srcDir(" native /cinterop_actuals" )
122
126
}
123
127
compilations[" test" ].kotlinOptions {
124
128
freeCompilerArgs + = listOf (" -trw" )
0 commit comments