This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.gradle
170 lines (148 loc) · 5.27 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
buildscript {
repositories {
mavenLocal()
google()
mavenCentral()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.37"
classpath("org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version") {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-gradle-plugin'
}
classpath "com.android.tools.build:gradle:$gradle_android_version"
classpath group: 'net.rubygrapefruit', name: 'native-platform', version: '0.10'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_plugin_version"
}
}
plugins {
id 'net.researchgate.release' version '2.6.0'
}
static def platformOf(project) {
if (project.name.endsWith("-common")) return "common"
if (project.name.endsWith("-ios")) return "native"
if (project.name.endsWith("-android")) return "android"
return "common"
}
allprojects {
repositories {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
maven { url 'https://kotlin.bintray.com/kotlinx' }
mavenCentral()
google()
jcenter()
mavenLocal()
}
def platform = platformOf(project)
if(platform.equals("android")){
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-platform-android'
} else {
apply plugin: "kotlin-platform-$platform"
}
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
def useExperimentalAnnotations = [
'kotlin.Experimental',
'kotlin.experimental.ExperimentalTypeInference'
//'kotlinx.io.core.internal.DangerousInternalIoApi',
//'kotlinx.io.core.ExperimentalIoApi'
]
def useExperimentalOptionString = "-Xuse-experimental=${useExperimentalAnnotations.join(",")}"
if (platform == 'native') {
sourceSets {
main {
component {
targets = [ 'ios_arm64', 'ios_x64', 'macos_x64' ]
// target 'ios_arm64', 'ios_arm32', 'ios_x64', 'macos_x64', 'linux_x64'
outputKinds = [KLIBRARY]
extraOpts useExperimentalOptionString
}
}
test {
component {
extraOpts useExperimentalOptionString
}
}
}
} else if (platform == 'common') {
compileKotlinCommon {
kotlinOptions.freeCompilerArgs += [useExperimentalOptionString]
}
compileTestKotlinCommon {
kotlinOptions.freeCompilerArgs += [useExperimentalOptionString]
}
} else if (platform == 'android') {
/*
compileKotlin {
kotlinOptions.freeCompilerArgs += [useExperimentalOptionString]
}
compileTestKotlin {
kotlinOptions.freeCompilerArgs += [useExperimentalOptionString]
}
*/
}
if (project.hasProperty('releaseVersion')) {
project.version = project.releaseVersion
}
apply plugin: 'maven'
task sourceJar(type: Jar, dependsOn: classes) {
classifier 'sources'
if (platform != 'native') {
if(platform == "android"){
from android.sourceSets.main.java.srcDirs
} else {
from sourceSets.main.kotlin
}
duplicatesStrategy DuplicatesStrategy.EXCLUDE
if(platform.equals("android")){
from android.sourceSets.main.java.srcDirs
} else {
def platformSrc = sourceSets.main.allSource
def commonSrc = rootProject.sourceSets.main.allSource
from(platformSrc + commonSrc)
}
}
}
task emptyJar(type: Jar) {
classifier 'javadoc'
}
tasks.build.dependsOn(['sourceJar', 'emptyJar'])
}
configure(allprojects) {
apply from: rootProject.file('pom.gradle')
apply from: rootProject.file('gradle/bintray.gradle')
publishing {
publications {
mavenProject(MavenPublication) {
if (!project.name.contains('ios') && !project.name.endsWith('android')) {
from components.java
}
groupId project.group
artifactId project.name
version project.version
if (project.name.endsWith('android')) {
artifact("$buildDir/outputs/aar/$project.name-debug.aar")
}
artifact sourceJar
artifact emptyJar {
classifier 'javadoc'
}
withPom(pom)
}
}
}
afterReleaseBuild.dependsOn bintrayUpload
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
}