Skip to content

Commit

Permalink
Use Kotlin DSL for gradle scripts (#81)
Browse files Browse the repository at this point in the history
* Use Kotlin DSL for gradle scripts

* Made the shared module import work with latest kotlin-language-server main

* Add java version specifier to build pipeline

* Experiment with disabling daemon for test invoking gradle

* Remove copy-paste from kotlin language server
  • Loading branch information
themkat committed Nov 23, 2023
1 parent 3b09a57 commit 7f05669
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Build
run: ./gradlew :adapter:build
run: ./gradlew :adapter:build -PjavaVersion=${{ matrix.java }}
48 changes: 0 additions & 48 deletions adapter/build.gradle

This file was deleted.

86 changes: 86 additions & 0 deletions adapter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
plugins {
kotlin("jvm")
id("maven-publish")
id("application")
id("com.jaredsburrows.license")
}

val debugPort = 8000
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"

val adapterMainClassName = "org.javacs.ktda.KDAMainKt"

application {
mainClass.set(adapterMainClassName)
description = "Debug Adapter for Kotlin"
applicationDistribution.into("bin") {
fileMode = 755
}
}

dependencies {
// The JSON-RPC and Debug Adapter Protocol implementations
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.debug:0.15.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("kotlin-language-server:shared")

// modules temporarily needed because of shared module import above
implementation("org.jetbrains.exposed:exposed-core:0.37.3")
implementation("org.jetbrains.exposed:exposed-dao:0.37.3")


testImplementation("junit:junit:4.12")
testImplementation("org.hamcrest:hamcrest-all:1.3")
}

tasks.startScripts {
applicationName = "kotlin-debug-adapter"
}

tasks.register<Exec>("fixFilePermissions") {
// When running on macOS or Linux the start script
// needs executable permissions to run.

onlyIf { !System.getProperty("os.name").lowercase().contains("windows") }
commandLine("chmod", "+x", "${tasks.installDist.get().destinationDir}/bin/kotlin-debug-adapter")
}

tasks.register<JavaExec>("debugRun") {
mainClass.set(adapterMainClassName)
classpath(sourceSets.main.get().runtimeClasspath)
standardInput = System.`in`

jvmArgs(debugArgs)
doLast {
println("Using debug port $debugPort")
}
}

tasks.register<CreateStartScripts>("debugStartScripts") {
applicationName = "kotlin-debug-adapter"
mainClass.set(adapterMainClassName)
outputDir = tasks.installDist.get().destinationDir.toPath().resolve("bin").toFile()
classpath = tasks.startScripts.get().classpath
defaultJvmOpts = listOf(debugArgs)
}

tasks.register<Sync>("installDebugDist") {
dependsOn("installDist")
finalizedBy("debugStartScripts")
}

tasks.withType<Test>() {
testLogging {
events("failed")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.SHORT
}
}

tasks.installDist {
finalizedBy("fixFilePermissions")
}

tasks.build {
finalizedBy("installDist")
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class DebugAdapterTestFixture(

@Before fun startDebugAdapter() {
// Build the project first
val process = ProcessBuilder("./gradlew", "assemble")
val process = ProcessBuilder("./gradlew", "--no-daemon", "assemble")
.directory(absoluteWorkspaceRoot.toFile())
.inheritIO()
.start()
Expand Down
3 changes: 2 additions & 1 deletion build.gradle → build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion"
kotlin("jvm")
`maven-publish`
}

allprojects {
Expand Down
15 changes: 0 additions & 15 deletions settings.gradle

This file was deleted.

21 changes: 21 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
rootProject.name = "kotlin-debug-adapter"

include("adapter")

pluginManagement {
repositories {
gradlePluginPortal()
}

plugins {
val kotlinVersion: String by settings
kotlin("jvm") version "$kotlinVersion" apply false
id("com.jaredsburrows.license") version "0.8.42" apply false
}
}

sourceControl {
gitRepository(java.net.URI.create("https://github.com/fwcd/kotlin-language-server.git")) {
producesModule("kotlin-language-server:shared")
}
}

0 comments on commit 7f05669

Please sign in to comment.