Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Kotlin DSL for gradle scripts #81

Merged
merged 5 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Comment on lines +28 to +30
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classpath database machinery would probably be interesting for the debug adapter too, perhaps we can integrate that permanently here too?



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")
}
}
Loading