update android part

This commit is contained in:
InsanusMokrassar 2022-11-21 21:21:05 +06:00
parent 3de2e1ceb5
commit 8f716be674
2 changed files with 11 additions and 32 deletions

View File

@ -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

View File

@ -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()