diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0f2629..05deae4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,4 +21,4 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} - name: Build - run: ./gradlew :adapter:build + run: ./gradlew :adapter:build -PjavaVersion=${{ matrix.java }} diff --git a/adapter/build.gradle b/adapter/build.gradle deleted file mode 100644 index 6c99b1d..0000000 --- a/adapter/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -plugins { - id 'org.jetbrains.kotlin.jvm' - id 'application' - id 'com.jaredsburrows.license' version '0.8.42' -} - -version = projectVersion - -mainClassName = 'org.javacs.ktda.KDAMainKt' -description = 'Debug Adapter for Kotlin' - -startScripts { - applicationName = "kotlin-debug-adapter" -} - -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:gradle_dsl_pre_platform') - testImplementation 'junit:junit:4.12' - testImplementation 'org.hamcrest:hamcrest-all:1.3' -} - -task fixFilePermissions(type: Exec) { - // When running on macOS or Linux the start script - // needs executable permissions to run. - onlyIf { !System.getProperty('os.name').toLowerCase().contains('windows') } - commandLine 'chmod', '+x', "${installDist.destinationDir}/bin/kotlin-debug-adapter" -} - -test { - testLogging { - events 'failed' - exceptionFormat 'short' - } -} - -run { - standardInput = System.in -} - -distZip { - archiveFileName = "${project.name}.zip" -} - -installDist.finalizedBy fixFilePermissions diff --git a/adapter/build.gradle.kts b/adapter/build.gradle.kts new file mode 100644 index 0000000..96ca48d --- /dev/null +++ b/adapter/build.gradle.kts @@ -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("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("debugRun") { + mainClass.set(adapterMainClassName) + classpath(sourceSets.main.get().runtimeClasspath) + standardInput = System.`in` + + jvmArgs(debugArgs) + doLast { + println("Using debug port $debugPort") + } +} + +tasks.register("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("installDebugDist") { + dependsOn("installDist") + finalizedBy("debugStartScripts") +} + +tasks.withType() { + testLogging { + events("failed") + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.SHORT + } +} + +tasks.installDist { + finalizedBy("fixFilePermissions") +} + +tasks.build { + finalizedBy("installDist") +} diff --git a/adapter/src/test/kotlin/org/javacs/ktda/DebugAdapterTestFixture.kt b/adapter/src/test/kotlin/org/javacs/ktda/DebugAdapterTestFixture.kt index de342c6..7769ef2 100644 --- a/adapter/src/test/kotlin/org/javacs/ktda/DebugAdapterTestFixture.kt +++ b/adapter/src/test/kotlin/org/javacs/ktda/DebugAdapterTestFixture.kt @@ -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() diff --git a/build.gradle b/build.gradle.kts similarity index 56% rename from build.gradle rename to build.gradle.kts index 16469b9..5a3d1df 100644 --- a/build.gradle +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { - id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion" + kotlin("jvm") + `maven-publish` } allprojects { diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 769a694..0000000 --- a/settings.gradle +++ /dev/null @@ -1,15 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - } -} - -rootProject.name = 'kotlin-debug-adapter' - -include 'adapter' - -sourceControl { - gitRepository('https://github.com/fwcd/kotlin-language-server.git') { - producesModule('kotlin-language-server:shared') - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..a749c80 --- /dev/null +++ b/settings.gradle.kts @@ -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") + } +}