2
0

build.gradle.kts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. @file:Suppress("UNUSED_VARIABLE")
  2. plugins {
  3. kotlin("multiplatform")
  4. id("kotlinx-atomicfu")
  5. id("kotlinx-serialization")
  6. `maven-publish`
  7. id("com.jfrog.bintray") version "1.8.4-jetbrains-3"
  8. }
  9. val kotlinVersion: String by rootProject.ext
  10. val atomicFuVersion: String by rootProject.ext
  11. val coroutinesVersion: String by rootProject.ext
  12. val coroutinesIoVersion: String by rootProject.ext
  13. val klockVersion: String by rootProject.ext
  14. val ktorVersion: String by rootProject.ext
  15. val serializationVersion: String by rootProject.ext
  16. fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
  17. fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
  18. description = "QQ protocol library"
  19. val isAndroidSDKAvailable: Boolean by project
  20. kotlin {
  21. if (isAndroidSDKAvailable) {
  22. apply(from = rootProject.file("gradle/android.gradle"))
  23. android("android") {
  24. publishAllLibraryVariants()
  25. }
  26. } else {
  27. println(
  28. """Android SDK 可能未安装.
  29. $name 的 Android 目标编译将不会进行.
  30. 这不会影响 Android 以外的平台的编译.
  31. """.trimIndent()
  32. )
  33. println(
  34. """Android SDK might not be installed.
  35. Android target of $name will not be compiled.
  36. It does no influence on the compilation of other platforms.
  37. """.trimIndent()
  38. )
  39. }
  40. jvm("jvm") {
  41. }
  42. sourceSets {
  43. all {
  44. languageSettings.enableLanguageFeature("InlineClasses")
  45. languageSettings.useExperimentalAnnotation("kotlin.Experimental")
  46. dependencies {
  47. api(kotlin("stdlib", kotlinVersion))
  48. api(kotlin("serialization", kotlinVersion))
  49. api("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
  50. api(kotlinx("coroutines-io", coroutinesIoVersion))
  51. api(kotlinx("coroutines-core", coroutinesVersion))
  52. }
  53. }
  54. commonMain {
  55. dependencies {
  56. api(kotlin("reflect", kotlinVersion))
  57. api(kotlin("serialization", kotlinVersion))
  58. api(kotlinx("coroutines-core-common", coroutinesVersion))
  59. api(kotlinx("serialization-runtime-common", serializationVersion))
  60. api(ktor("http-cio", ktorVersion))
  61. api(ktor("http", ktorVersion))
  62. api(ktor("client-core-jvm", ktorVersion))
  63. api(ktor("client-cio", ktorVersion))
  64. api(ktor("client-core", ktorVersion))
  65. api(ktor("network", ktorVersion))
  66. //implementation("io.ktor:ktor-io:1.3.0-beta-1")
  67. //runtimeOnly(files("build/classes/kotlin/metadata/main")) // classpath is not properly set by IDE
  68. }
  69. }
  70. commonTest {
  71. dependencies {
  72. implementation(kotlin("test-annotations-common"))
  73. implementation(kotlin("test-common"))
  74. //runtimeOnly(files("build/classes/kotlin/metadata/test")) // classpath is not properly set by IDE
  75. }
  76. }
  77. if (isAndroidSDKAvailable) {
  78. val androidMain by getting {
  79. dependencies {
  80. api(kotlin("reflect", kotlinVersion))
  81. api(kotlinx("serialization-runtime", serializationVersion))
  82. api(kotlinx("coroutines-android", coroutinesVersion))
  83. api(ktor("client-android", ktorVersion))
  84. }
  85. }
  86. val androidTest by getting {
  87. dependencies {
  88. implementation(kotlin("test", kotlinVersion))
  89. implementation(kotlin("test-junit", kotlinVersion))
  90. implementation(kotlin("test-annotations-common"))
  91. implementation(kotlin("test-common"))
  92. }
  93. }
  94. }
  95. val jvmMain by getting {
  96. dependencies {
  97. //api(kotlin("stdlib-jdk8", kotlinVersion))
  98. //api(kotlin("stdlib-jdk7", kotlinVersion))
  99. api(kotlin("reflect", kotlinVersion))
  100. api(ktor("client-core-jvm", ktorVersion))
  101. api(kotlinx("serialization-runtime", serializationVersion))
  102. api(kotlinx("coroutines-io", coroutinesIoVersion))
  103. api(kotlinx("coroutines-io-jvm", coroutinesIoVersion))
  104. api(kotlinx("io-jvm", coroutinesIoVersion))
  105. api("org.bouncycastle:bcprov-jdk15on:1.64")
  106. runtimeOnly(files("build/classes/kotlin/jvm/main")) // classpath is not properly set by IDE
  107. }
  108. }
  109. val jvmTest by getting {
  110. dependencies {
  111. implementation(kotlin("test", kotlinVersion))
  112. implementation(kotlin("test-junit", kotlinVersion))
  113. implementation("org.pcap4j:pcap4j-distribution:1.8.2")
  114. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  115. }
  116. }
  117. }
  118. }
  119. //
  120. //tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
  121. // kotlinOptions.jvmTarget = "1.8"
  122. //}
  123. apply(from = rootProject.file("gradle/publish.gradle"))