Files
kotlin-fork/samples/uikit/build.gradle
T
2019-03-12 18:01:59 +07:00

61 lines
1.8 KiB
Groovy

plugins {
id 'kotlin-multiplatform'
}
kotlin {
targets {
fromPreset(determinePreset(), 'ios') {
binaries {
executable {
entryPoint = 'sample.uikit.main'
}
}
}
}
}
// Special Gradle task that is called from Xcode.
// Two Gradle properties must be specified for this task:
// - uikit.configuration.name=[Release|Debug]
// - uikit.binary.location
task buildAppForXcode {
if (isCalledFromXcode()) {
dependsOn kotlin.targets.ios.binaries.getExecutable(getBuildTypeForXcode()).linkTask
}
doLast {
if (!isCalledFromXcode()) {
throw new Exception("Please run 'buildAppForXcode' task with all necessary properties!")
}
copy {
from file(kotlin.targets.ios.binaries.getExecutable(getBuildTypeForXcode()).outputFile)
into file(getBinaryLocationForXcode().parentFile)
rename {
getBinaryLocationForXcode().name
}
}
}
}
// If custom preset specified in 'uikit.preset.name' property, then use it for building.
// Otherwise build for iPhone simulator (by default).
private def determinePreset() {
String presetName = project.hasProperty('uikit.preset.name') ? project.properties['uikit.preset.name'] : 'iosX64'
def preset = project.kotlin.presets[presetName]
println("$project has been configured for $presetName platform.")
preset
}
private boolean isCalledFromXcode() {
project.hasProperty('uikit.configuration.name') && project.hasProperty('uikit.binary.location')
}
private String getBuildTypeForXcode() {
project.properties['uikit.configuration.name'] as String
}
private File getBinaryLocationForXcode() {
file(project.properties['uikit.binary.location'])
}