MPP Wizards: Clearer notation in generated build.gradle files
- Follow the same style as used in public documentation: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html - Use standard methods to get link task name, don't evaluate it manually
This commit is contained in:
+4
-4
@@ -75,9 +75,9 @@ class KotlinGradleNativeMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
|
|||||||
|
|
||||||
configure([$nativeTargetName]) {
|
configure([$nativeTargetName]) {
|
||||||
// Comment to generate Kotlin/Native library (KLIB) instead of executable file:
|
// Comment to generate Kotlin/Native library (KLIB) instead of executable file:
|
||||||
compilations.main.outputKinds('EXECUTABLE')
|
compilations.main.outputKinds 'EXECUTABLE'
|
||||||
// Change to specify fully qualified name of your application's entry point:
|
// Change to specify fully qualified name of your application's entry point:
|
||||||
compilations.main.entryPoint = 'sample.main'
|
compilations.main.entryPoint 'sample.main'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -91,8 +91,8 @@ class KotlinGradleNativeMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
|
|||||||
}
|
}
|
||||||
|
|
||||||
task runProgram {
|
task runProgram {
|
||||||
def buildType = 'release' // Change to 'debug' to run application with debug symbols.
|
def buildType = 'RELEASE' // Change to 'DEBUG' to run application with debug symbols.
|
||||||
dependsOn "link${'$'}{buildType.capitalize()}Executable${nativeTargetName.capitalize()}"
|
dependsOn kotlin.targets.$nativeTargetName.compilations.main.linkTaskName('EXECUTABLE', buildType)
|
||||||
doLast {
|
doLast {
|
||||||
def programFile = kotlin.targets.$nativeTargetName.compilations.main.getBinary('EXECUTABLE', buildType)
|
def programFile = kotlin.targets.$nativeTargetName.compilations.main.getBinary('EXECUTABLE', buildType)
|
||||||
exec {
|
exec {
|
||||||
|
|||||||
+9
-9
@@ -285,12 +285,12 @@ sdk.dir=PleaseSpecifyAndroidSdkPathHere
|
|||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.jetbrains.kotlin.mpp_app_android"
|
applicationId 'org.jetbrains.kotlin.mpp_app_android'
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName '1.0'
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@@ -312,7 +312,7 @@ sdk.dir=PleaseSpecifyAndroidSdkPathHere
|
|||||||
// This preset is for iPhone emulator
|
// This preset is for iPhone emulator
|
||||||
// Switch here to presets.iosArm64 (or iosArm32) to build library for iPhone device
|
// Switch here to presets.iosArm64 (or iosArm32) to build library for iPhone device
|
||||||
fromPreset(presets.iosX64, '$nativeTargetName') {
|
fromPreset(presets.iosX64, '$nativeTargetName') {
|
||||||
compilations.main.outputKinds('FRAMEWORK')
|
compilations.main.outputKinds 'FRAMEWORK'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -351,13 +351,13 @@ sdk.dir=PleaseSpecifyAndroidSdkPathHere
|
|||||||
// Before opening the project from iosApp directory in Xcode,
|
// Before opening the project from iosApp directory in Xcode,
|
||||||
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
|
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
|
||||||
task copyFramework {
|
task copyFramework {
|
||||||
def buildType = project.findProperty("kotlin.build.type") ?: "DEBUG"
|
def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
|
||||||
def target = project.findProperty("kotlin.target") ?: "ios"
|
def target = project.findProperty('kotlin.target') ?: 'ios'
|
||||||
dependsOn "link${"$"}{buildType.toLowerCase().capitalize()}Framework${"$"}{target.capitalize()}"
|
dependsOn kotlin.targets."${"$"}target".compilations.main.linkTaskName('FRAMEWORK', buildType)
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
def srcFile = kotlin.targets."${"$"}target".compilations.main.getBinary("FRAMEWORK", buildType)
|
def srcFile = kotlin.targets."${"$"}target".compilations.main.getBinary('FRAMEWORK', buildType)
|
||||||
def targetDir = getProperty("configuration.build.dir")
|
def targetDir = getProperty('configuration.build.dir')
|
||||||
copy {
|
copy {
|
||||||
from srcFile.parent
|
from srcFile.parent
|
||||||
into targetDir
|
into targetDir
|
||||||
|
|||||||
+1
-1
@@ -151,7 +151,7 @@ class KotlinGradleMobileSharedMultiplatformModuleBuilder : KotlinGradleAbstractM
|
|||||||
// This preset is for iPhone emulator
|
// This preset is for iPhone emulator
|
||||||
// Switch here to presets.iosArm64 to build library for iPhone device
|
// Switch here to presets.iosArm64 to build library for iPhone device
|
||||||
fromPreset(presets.iosX64, '$nativeTargetName') {
|
fromPreset(presets.iosX64, '$nativeTargetName') {
|
||||||
compilations.main.outputKinds('FRAMEWORK')
|
compilations.main.outputKinds 'FRAMEWORK'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
Reference in New Issue
Block a user