Skip to content

Commit c464055

Browse files
author
Henry Fraser
committed
Migrate gradle from groovy to kotlin dsl
1 parent 0a56af3 commit c464055

File tree

10 files changed

+222
-221
lines changed

10 files changed

+222
-221
lines changed

build.gradle

Lines changed: 0 additions & 39 deletions
This file was deleted.

build.gradle.kts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// TODO: change the hardcoded 1.6.10 to kotlinVeresion that lives in project props
2+
// We could use a buildSrc script for this.
3+
// See: https://github.com/gradle/kotlin-dsl-samples/issues/802
4+
plugins {
5+
kotlin("jvm") version "1.6.10"
6+
`maven-publish`
7+
}
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
configure(subprojects.filter { it.name != "grammars" }) {
14+
apply(plugin = "kotlin")
15+
apply(plugin = "maven-publish")
16+
17+
publishing {
18+
repositories {
19+
maven {
20+
name = "GitHubPackages"
21+
url = uri("https://maven.pkg.github.com/fwcd/kotlin-language-server")
22+
credentials {
23+
username = project.findProperty("gpr.user") as String? ?: System.getenv("GPR_USERNAME")
24+
password = project.findProperty("gpr.key") as String? ?: System.getenv("GPR_PASSWORD")
25+
}
26+
}
27+
}
28+
29+
publications {
30+
register("gpr", MavenPublication::class) {
31+
from(components["java"])
32+
}
33+
}
34+
}
35+
}

grammars/build.gradle

Lines changed: 0 additions & 7 deletions
This file was deleted.

grammars/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tasks.register<Zip>("distZip") {
2+
from(projectDir) {
3+
include("*.json")
4+
}
5+
archiveFileName.set("${project.name}.zip")
6+
destinationDirectory.set(file("$buildDir/distributions"))
7+
}

server/build.gradle

Lines changed: 0 additions & 143 deletions
This file was deleted.

server/build.gradle.kts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
plugins {
2+
kotlin("jvm")
3+
id("maven-publish")
4+
id("application")
5+
id("com.github.jk1.tcdeps") version "1.2"
6+
id("com.jaredsburrows.license") version "0.8.42"
7+
}
8+
9+
val projectVersion = project.property("projectVersion").toString()
10+
val kotlinVersion = project.property("kotlinVersion").toString()
11+
val exposedVersion = project.property("exposedVersion").toString()
12+
val lsp4jVersion = project.property("lsp4jVersion").toString()
13+
val javaVersion = project.property("javaVersion").toString()
14+
val debugPort = 8000
15+
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
16+
17+
version = projectVersion
18+
19+
val serverMainClassName = "org.javacs.kt.MainKt"
20+
val applicationName = "kotlin-language-server"
21+
22+
application {
23+
mainClassName = serverMainClassName
24+
description = "Code completions, diagnostics and more for Kotlin"
25+
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$projectVersion")
26+
applicationDistribution.into("bin") {
27+
fileMode = 755
28+
}
29+
}
30+
31+
repositories {
32+
maven(url = "https://repo.gradle.org/gradle/libs-releases")
33+
maven { url = uri("$projectDir/lib") }
34+
maven(uri("$projectDir/lib"))
35+
maven("https://jitpack.io")
36+
mavenCentral()
37+
}
38+
39+
dependencies {
40+
implementation(project(":shared"))
41+
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:$lsp4jVersion")
42+
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:$lsp4jVersion")
43+
implementation(kotlin("compiler", version = kotlinVersion))
44+
implementation(kotlin("scripting-compiler", version = kotlinVersion))
45+
implementation(kotlin("scripting-jvm-host-unshaded", version = kotlinVersion))
46+
implementation(kotlin("sam-with-receiver-compiler-plugin", version = kotlinVersion))
47+
implementation(kotlin("reflect", version = kotlinVersion))
48+
implementation("org.jetbrains:fernflower:1.0")
49+
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
50+
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
51+
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
52+
implementation("com.h2database:h2:1.4.200")
53+
implementation("com.github.fwcd.ktfmt:ktfmt:b5d31d1")
54+
implementation("com.beust:jcommander:1.78")
55+
56+
testImplementation("org.hamcrest:hamcrest-all:1.3")
57+
testImplementation("junit:junit:4.11")
58+
testImplementation("org.openjdk.jmh:jmh-core:1.20")
59+
60+
// See https://github.com/JetBrains/kotlin/blob/65b0a5f90328f4b9addd3a10c6f24f3037482276/libraries/examples/scripting/jvm-embeddable-host/build.gradle.kts#L8
61+
compileOnly(kotlin("scripting-jvm-host", version = kotlinVersion))
62+
testCompileOnly(kotlin("scripting-jvm-host", version = kotlinVersion))
63+
64+
annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:1.20")
65+
}
66+
67+
configurations.forEach { config ->
68+
config.resolutionStrategy {
69+
preferProjectModules()
70+
}
71+
}
72+
73+
tasks.startScripts {
74+
applicationName = "kotlin-language-server"
75+
}
76+
77+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
78+
kotlinOptions {
79+
jvmTarget = javaVersion
80+
}
81+
}
82+
83+
tasks.register<Copy>("copyPropertiesToTestWorkspace") {
84+
from("$rootDir/gradle.properties")
85+
into(file("src/test/resources/additionalWorkspace"))
86+
}
87+
88+
tasks.register<Copy>("copyPropertiesToDSLTestWorkspace") {
89+
from("$rootDir/gradle.properties")
90+
into(file("src/test/resources/kotlinDSLWorkspace"))
91+
}
92+
93+
tasks.register<Exec>("fixFilePermissions") {
94+
// When running on macOS or Linux the start script
95+
// needs executable permissions to run.
96+
97+
onlyIf { !System.getProperty("os.name").toLowerCase().contains("windows") }
98+
commandLine("chmod", "+x", "${tasks.installDist.get().destinationDir}/bin/kotlin-language-server")
99+
}
100+
101+
tasks.register<JavaExec>("debugRun") {
102+
mainClass.set(serverMainClassName)
103+
classpath(sourceSets.main.get().runtimeClasspath)
104+
standardInput = System.`in`
105+
106+
jvmArgs(debugArgs)
107+
doLast {
108+
println("Using debug port $debugPort")
109+
}
110+
}
111+
112+
tasks.register<CreateStartScripts>("debugStartScripts") {
113+
applicationName = "kotlin-language-server"
114+
mainClass.set(serverMainClassName)
115+
outputDir = tasks.installDist.get().destinationDir.toPath().resolve("bin").toFile()
116+
classpath = tasks.startScripts.get().classpath
117+
defaultJvmOpts = listOf(debugArgs)
118+
}
119+
120+
tasks.register<Sync>("installDebugDist") {
121+
dependsOn("installDist")
122+
finalizedBy("debugStartScripts")
123+
}
124+
125+
tasks.getByName("processTestResources") {
126+
dependsOn("copyPropertiesToTestWorkspace", "copyPropertiesToDSLTestWorkspace")
127+
}
128+
129+
tasks.withType<Test>() {
130+
dependsOn("copyPropertiesToTestWorkspace", "copyPropertiesToDSLTestWorkspace")
131+
132+
testLogging {
133+
events("failed")
134+
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
135+
}
136+
}
137+
138+
tasks.installDist {
139+
finalizedBy("fixFilePermissions")
140+
}
141+
142+
tasks.build {
143+
finalizedBy("installDist")
144+
}

settings.gradle

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)