|
| 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 | +} |
0 commit comments