Nikolai
07/16/2019, 12:46 AMkotlin {
android("android")
....
}
But I don't understand what exactly it doing, what means "android" as parameter, what we have as output? And as result how common module code goes to android part?
P.S. Also, is where any place I can found docs to understand that closures have this plugin (kotlin-multiplatform), plugin tasks, what they do and how they works?ribesg
07/16/2019, 8:34 AMKris Wong
07/16/2019, 12:57 PMNikolai
07/16/2019, 2:14 PMapply plugin: 'com.android.application'
in same build.gradle plugin able to build a android app from this source set using all android.application closures ('android', 'dependencies'). The only question is how common module applied to this source set. As separate library or as part of the codebase or something else?plugins {
id 'kotlin-multiplatform' version '1.3.30'
}
repositories {
google()
jcenter()
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId 'org.jetbrains.kotlin.mpp_app_android'
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName '1.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
}
kotlin {
android("android")
// This is for iPhone emulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("ios") {
binaries {
framework()
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
androidMain {
dependencies {
implementation kotlin('stdlib')
}
}
androidTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
iosMain {
}
iosTest {
}
}
}
// This task attaches native framework built from ios module to Xcode project
// (see iosApp directory). Don't run this task directly,
// Xcode runs this task itself during its build process.
// Before opening the project from iosApp directory in Xcode,
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
task copyFramework {
def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
def target = project.findProperty('kotlin.target') ?: 'ios'
dependsOn kotlin.targets."$target".binaries.getFramework(buildType).linkTask
doLast {
def srcFile = kotlin.targets."$target".binaries.getFramework(buildType).outputFile
def targetDir = getProperty('configuration.build.dir')
copy {
from srcFile.parent
into targetDir
include 'app.framework/**'
include 'app.framework.dSYM'
}
}
}
ribesg
07/16/2019, 2:15 PMplugins { }
block and apply plugin
, unless you know that you need to. apply plugin
is the old way of doing itNikolai
07/16/2019, 2:17 PMKris Wong
07/16/2019, 2:21 PMNikolai
07/16/2019, 2:36 PM