mirror of
https://github.com/InsanusMokrassar/KotlinMultiplatformProjectTemplate.git
synced 2024-12-03 15:30:16 +00:00
update android part
This commit is contained in:
parent
3de2e1ceb5
commit
8f716be674
18
README.md
18
README.md
@ -26,17 +26,21 @@ this case you must rename it in `settings.gradle` file.
|
||||
## JVM sources in Android target
|
||||
|
||||
By default JVM code is not included in Android target. In case you wish to include JVM sources in Android build, use
|
||||
next method in the end of your `build.gradle`:
|
||||
next method in the `sourceSets` section of your `build.gradle`:
|
||||
|
||||
```groovy
|
||||
enableIncludingJvmCodeInAndroidPart()
|
||||
kotlin {
|
||||
sourceSets {
|
||||
// Some other code
|
||||
androidMain {
|
||||
// Some other code (like dependencies)
|
||||
dependsOn jvmMain
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In case when you need to be sure that JVM sources are not included in Android part, use this snippet:
|
||||
|
||||
```groovy
|
||||
disableIncludingJvmCodeInAndroidPart()
|
||||
```
|
||||
In case when you need to be sure that JVM sources are not included in Android part, just remove line with `dependsOn jvmMain`
|
||||
|
||||
## Types of projects
|
||||
|
||||
|
@ -1,31 +1,6 @@
|
||||
apply plugin: 'com.getkeepsafe.dexcount'
|
||||
|
||||
android {
|
||||
ext {
|
||||
jvmKotlinFolderFile = {
|
||||
String sep = File.separator
|
||||
return new File("${project.projectDir}${sep}src${sep}jvmMain${sep}kotlin")
|
||||
}
|
||||
|
||||
enableIncludingJvmCodeInAndroidPart = {
|
||||
File jvmKotlinFolder = jvmKotlinFolderFile()
|
||||
if (jvmKotlinFolder.exists()) {
|
||||
android.sourceSets.main.java.srcDirs += jvmKotlinFolder.path
|
||||
}
|
||||
}
|
||||
|
||||
disableIncludingJvmCodeInAndroidPart = {
|
||||
File jvmKotlinFolder = jvmKotlinFolderFile()
|
||||
String[] oldDirs = android.sourceSets.main.java.srcDirs
|
||||
android.sourceSets.main.java.srcDirs = []
|
||||
for (oldDir in oldDirs) {
|
||||
if (oldDir != jvmKotlinFolder.path) {
|
||||
android.sourceSets.main.java.srcDirs += oldDir
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileSdkVersion libs.versions.android.compileSdk.get().toInteger()
|
||||
buildToolsVersion libs.versions.android.buildTools.get()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user