This repository has been archived by the owner on Jun 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuild.gradle.kts
177 lines (150 loc) · 4.52 KB
/
build.gradle.kts
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
174
175
176
177
import org.jetbrains.intellij.tasks.PublishTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.api.internal.HasConvention
import org.gradle.api.tasks.SourceSet
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.gradle.api.JavaVersion.VERSION_1_8
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.jvm.tasks.Jar
import java.net.HttpURLConnection
import java.net.URL
import java.nio.file.Path
import kotlin.concurrent.thread
val kotlin_version: String by extra
buildscript {
var kotlin_version: String by extra
kotlin_version = "1.2.31"
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath(kotlinModule("gradle-plugin", kotlin_version))
}
}
val CI = System.getenv("CI") != null
plugins {
idea
kotlin("jvm") version "1.2.31"
id("org.jetbrains.intellij") version "0.3.1"
}
apply {
plugin("kotlin")
}
idea {
module {
// https://github.com/gradle/kotlin-dsl/issues/537/
excludeDirs = excludeDirs + file("testData") + file("deps")
}
}
allprojects {
apply {
plugin("idea")
plugin("kotlin")
plugin("org.jetbrains.intellij")
}
repositories {
mavenCentral()
jcenter()
}
idea {
module {
generatedSourceDirs.add(file("src/gen"))
}
}
intellij {
version = prop("ideaVersion")
downloadSources = !CI
updateSinceUntilBuild = false
instrumentCode = false
ideaDependencyCachePath = file("deps").absolutePath
setPlugins("properties", "maven", "junit", "Kotlin", "android", "gradle", "Groovy", "smali")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
languageVersion = "1.2"
apiVersion = "1.2"
}
}
configure<JavaPluginConvention> {
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
}
java.sourceSets {
getByName("main").java.srcDirs("src/gen")
}
}
val pluginVersion = System.getenv("pluginVersion") ?: prop("pluginVersion")
project(":") {
version = pluginVersion
intellij {
pluginName = "intellij-lsp-server"
}
dependencies {
compile("org.jetbrains.kotlin:kotlin-reflect:1.2.31")
compile("org.eclipse.lsp4j:org.eclipse.lsp4j:0.4.0")
testCompile("org.jetbrains.kotlin:kotlin-test:1.2.31")
}
tasks.withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
}
// Prevent "File access outside allowed roots" in multi module tests, because modules each have an .iml
environment("NO_FS_ROOTS_ACCESS_CHECK", "1")
}
task("resolveDependencies") {
doLast {
rootProject.allprojects
.map { it.configurations }
.flatMap { listOf(it.compile, it.testCompile) }
.forEach { it.resolve() }
}
}
}
fun prop(name: String): String =
extra.properties[name] as? String
?: error("Property `$name` is not defined in gradle.properties")
inline operator fun <T : Task> T.invoke(a: T.() -> Unit): T = apply(a)
val SourceSet.kotlin: SourceDirectorySet
get() =
(this as HasConvention)
.convention
.getPlugin(KotlinSourceSet::class.java)
.kotlin
fun SourceSet.kotlin(action: SourceDirectorySet.() -> Unit) =
kotlin.action()
fun String.execute(wd: String? = null, ignoreExitCode: Boolean = false): String =
split(" ").execute(wd, ignoreExitCode)
fun List<String>.execute(wd: String? = null, ignoreExitCode: Boolean = false): String {
val process = ProcessBuilder(this)
.also { pb -> wd?.let { pb.directory(File(it)) } }
.start()
var result = ""
val errReader = thread { process.errorStream.bufferedReader().forEachLine { println(it) } }
val outReader = thread {
process.inputStream.bufferedReader().forEachLine { line ->
println(line)
result += line
}
}
process.waitFor()
outReader.join()
errReader.join()
if (process.exitValue() != 0 && !ignoreExitCode) error("Non-zero exit status for `$this`")
return result
}
dependencies {
compile(kotlinModule("stdlib-jdk8", kotlin_version))
}
repositories {
mavenCentral()
}
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "1.8"
}
val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
jvmTarget = "1.8"
}