forked from ktorio/ktor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
173 lines (145 loc) · 5.85 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
171
172
173
buildscript {
/*
* These property group is used to build against Kotlin compiler snapshot.
* How does it work:
* When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version,
* atomicfu_version, coroutines_version, serialization_version and kotlinx_io_version are overwritten by TeamCity environment.
* Additionally, mavenLocal and Sonatype snapshots are added to repository list and stress tests are disabled.
* DO NOT change the name of these properties without adapting kotlinx.train build chain.
*/
def prop = rootProject.properties['build_snapshot_train']
ext.build_snapshot_train = prop != null && prop != ""
if (build_snapshot_train) {
ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
if (kotlin_version == null) {
throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
}
repositories {
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
configurations.classpath {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.jetbrains.kotlin') {
details.useVersion kotlin_version
}
}
}
}
repositories {
jcenter()
google()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven {
url "https://kotlin.bintray.com/kotlin-dev"
credentials {
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') ?: ""
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') ?: ""
}
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:$android_build_tools"
}
}
// --------------------------
/*
This file is intentionally empty so that all individual samples are standalone gradle project that
can be cut-and-pasted to get started.
*/
def check(Object version, String libVersion, String libName) {
if (version != libVersion) {
throw new IllegalStateException("Current deploy version is $version, but $libName version is not overridden ($libVersion)")
}
}
allprojects {
if (build_snapshot_train) {
ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
println "Using Kotlin $kotlin_version for project $it"
def deployVersion = properties['DeployVersion']
if (deployVersion != null) version = deployVersion
def skipSnapshotChecks = rootProject.properties['skip_snapshot_checks'] != null
if (!skipSnapshotChecks) {
check(version, atomicfu_version, "atomicfu")
check(version, coroutines_version, "coroutines")
check(version, serialization_version, "serialization")
check(version, ktor_version, "ktor")
}
kotlin_version = rootProject.properties['kotlin_snapshot_version']
repositories {
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
repositories {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
// Here we inject maven local repository that is used for integration testing on CI
def ktorRepositoryDir = file("$buildDir/m2")
if (ktorRepositoryDir.exists()) {
allprojects {
repositories {
maven { url ktorRepositoryDir.absolutePath }
}
}
} else {
allprojects {
repositories {
mavenLocal()
}
}
}
// --------------------------
// Here we invoke configure all the maven samples so that doing "gradlew build" builds all the samples
// including Maven ones and "gradlew :<sample-name>:run" works for all of them, while still keeping Maven
// sample directories fully standalone
def mavenSettings = file("settings.xml")
configure(subprojects.findAll { it.name.startsWith("maven-") }) {
def mvnw = System.getProperty('os.name').toLowerCase(Locale.US).contains('windows') ?
[ 'cmd', '/c', 'mvnw.cmd' ] : [ './mvnw' ]
mvnw += "-Dkotlin.version=$kotlin_version"
mvnw += "-Dktor.version=$ktor_version"
if (ktorRepositoryDir.exists()) {
mvnw += "-Dktor.repository.url=file:///${ktorRepositoryDir.absolutePath}"
mvnw += ['-s', mavenSettings.absolutePath]
}
task build(type: Exec) {
commandLine mvnw + [ 'package' ]
}
task clean(type: Exec) {
commandLine mvnw + [ 'clean' ]
}
println("Starting maven with command: $mvnw")
if (it.name.contains("appengine")) {
task run(type: Exec) {
commandLine mvnw + [ 'appengine:run' ]
}
} else {
task run(type: Exec) {
commandLine mvnw + [ 'compile', 'exec:java' ]
}
}
}
if (build_snapshot_train) {
println "Hacking test tasks, removing stress and flaky tests"
allprojects {
tasks.withType(Test).all {
// Add: exclude '**/*TestName*' here
}
}
println "Manifest of kotlin-compiler-embeddable.jar for coroutines"
configure(subprojects.findAll { it.name == "kotlinx-coroutines-core" }) {
configurations.matching { it.name == "kotlinCompilerClasspath" }.all {
resolvedConfiguration.getFiles().findAll { it.name.contains("kotlin-compiler-embeddable") }.each {
def manifest = zipTree(it).matching {
include 'META-INF/MANIFEST.MF'
}.getFiles().first()
manifest.readLines().each {
println it
}
}
}
}
}