russhwolf
02/11/2019, 4:26 AMcommonMain
and commonTest
will be present in project.kotlin.sourceSets
? If not, is there a way to dynamically detect the common sources? I was looking at the metadata
target but it only has a main
compilation and no test
.josephivie
02/11/2019, 7:11 AMGarouDan
02/11/2019, 10:31 AMThese are the default source set names for the production and test sources for the targets configured above. The source sets commonMain and commonTest are included into production and test compilations, respectively, of all targets. Note that the dependencies for common source sets commonMain and commonTest are the common artifacts, and the platform libraries go to the source sets of the specific targets.
Also you can do something like:
js().compilations.main.defaultSourceSet { /* ... */ }
js().compilations.test.defaultSourceSet { /* ... */ }
I don’t know what about using project.kotlin.sourceSets, but I think it should work.kotlin.targets."$target".compilations.main
where I got this from:
task copyFramework {
def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
def target = project.findProperty('kotlin.target') ?: 'ios'
dependsOn kotlin.targets."$target".compilations.main.linkTaskName('FRAMEWORK', buildType)
doLast {
def srcFile = kotlin.targets."$target".compilations.main.getBinary('FRAMEWORK', buildType)
def targetDir = getProperty('configuration.build.dir')
copy {
from srcFile.parent
into targetDir
include 'app.framework/**'
include 'app.framework.dSYM'
}
}
}
h0tk3y
02/11/2019, 12:25 PMcommonMain
and commonTest
source sets are always created by the kotlin-multiplatform
plugin, you can expect them to be there if that plugin is applied. However, other plugins that create the kotlin
extension don't create these source sets, so you should check if they are present unless you are targeting MPP only.russhwolf
02/11/2019, 2:25 PM