|
| 1 | +plugins { |
| 2 | + kotlin("jvm") |
| 3 | + id("maven-publish") |
| 4 | + id("application") |
| 5 | + id("com.jaredsburrows.license") |
| 6 | +} |
| 7 | + |
| 8 | +val debugPort = 8000 |
| 9 | +val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y" |
| 10 | + |
| 11 | +val adapterMainClassName = "org.javacs.ktda.KDAMainKt" |
| 12 | + |
| 13 | +application { |
| 14 | + mainClass.set(adapterMainClassName) |
| 15 | + description = "Debug Adapter for Kotlin" |
| 16 | + applicationDistribution.into("bin") { |
| 17 | + fileMode = 755 |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +dependencies { |
| 22 | + // The JSON-RPC and Debug Adapter Protocol implementations |
| 23 | + implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.debug:0.15.0") |
| 24 | + implementation("org.jetbrains.kotlin:kotlin-stdlib") |
| 25 | + implementation("org.jetbrains.kotlin:kotlin-reflect") |
| 26 | + implementation("kotlin-language-server:shared") |
| 27 | + |
| 28 | + // modules temporarily needed because of shared module import above |
| 29 | + implementation("org.jetbrains.exposed:exposed-core:0.37.3") |
| 30 | + implementation("org.jetbrains.exposed:exposed-dao:0.37.3") |
| 31 | + |
| 32 | + |
| 33 | + testImplementation("junit:junit:4.12") |
| 34 | + testImplementation("org.hamcrest:hamcrest-all:1.3") |
| 35 | +} |
| 36 | + |
| 37 | +tasks.startScripts { |
| 38 | + applicationName = "kotlin-debug-adapter" |
| 39 | +} |
| 40 | + |
| 41 | +tasks.register<Exec>("fixFilePermissions") { |
| 42 | + // When running on macOS or Linux the start script |
| 43 | + // needs executable permissions to run. |
| 44 | + |
| 45 | + onlyIf { !System.getProperty("os.name").lowercase().contains("windows") } |
| 46 | + commandLine("chmod", "+x", "${tasks.installDist.get().destinationDir}/bin/kotlin-debug-adapter") |
| 47 | +} |
| 48 | + |
| 49 | +tasks.register<JavaExec>("debugRun") { |
| 50 | + mainClass.set(adapterMainClassName) |
| 51 | + classpath(sourceSets.main.get().runtimeClasspath) |
| 52 | + standardInput = System.`in` |
| 53 | + |
| 54 | + jvmArgs(debugArgs) |
| 55 | + doLast { |
| 56 | + println("Using debug port $debugPort") |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +tasks.register<CreateStartScripts>("debugStartScripts") { |
| 61 | + applicationName = "kotlin-debug-adapter" |
| 62 | + mainClass.set(adapterMainClassName) |
| 63 | + outputDir = tasks.installDist.get().destinationDir.toPath().resolve("bin").toFile() |
| 64 | + classpath = tasks.startScripts.get().classpath |
| 65 | + defaultJvmOpts = listOf(debugArgs) |
| 66 | +} |
| 67 | + |
| 68 | +tasks.register<Sync>("installDebugDist") { |
| 69 | + dependsOn("installDist") |
| 70 | + finalizedBy("debugStartScripts") |
| 71 | +} |
| 72 | + |
| 73 | +tasks.withType<Test>() { |
| 74 | + testLogging { |
| 75 | + events("failed") |
| 76 | + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.SHORT |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +tasks.installDist { |
| 81 | + finalizedBy("fixFilePermissions") |
| 82 | +} |
| 83 | + |
| 84 | +tasks.build { |
| 85 | + finalizedBy("installDist") |
| 86 | +} |
0 commit comments