Skip to content

Commit

Permalink
Unify dependency versions (#424)
Browse files Browse the repository at this point in the history
Addresses #419
  • Loading branch information
RenFraser committed Mar 3, 2023
1 parent 88d6f52 commit 54c8465
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 55 deletions.
5 changes: 1 addition & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask

// TODO: change the hardcoded 1.6.10 to kotlinVeresion that lives in project props
// We could use a buildSrc script for this.
// See: https://github.com/gradle/kotlin-dsl-samples/issues/802
plugins {
kotlin("jvm") version "1.8.10"
kotlin("jvm")
`maven-publish`
id("io.gitlab.arturbosch.detekt") version "1.22.0"
}
Expand Down
43 changes: 43 additions & 0 deletions gradle/platform/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
id("java-platform")
}

group = "dev.fwcd.kotlin-language-server"

javaPlatform {
allowDependencies()
}

val kotlinVersion = "1.8.10"
val exposedVersion = "0.37.3"
val lsp4jVersion = "0.15.0"

// constrain the dependencies that we use to these specific versions
dependencies {
constraints {
api("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
api("org.hamcrest:hamcrest-all:1.3")
api("junit:junit:4.11")
api("org.eclipse.lsp4j:org.eclipse.lsp4j:$lsp4jVersion")
api("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:$lsp4jVersion")
api("org.jetbrains.kotlin:kotlin-compiler:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-scripting-compiler:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-scripting-jvm-host-unshaded:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-jvm:$kotlinVersion")
api("org.jetbrains:fernflower:1.0")
api("org.jetbrains.exposed:exposed-core:$exposedVersion")
api("org.jetbrains.exposed:exposed-dao:$exposedVersion")
api("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
api("com.h2database:h2:1.4.200")
api("com.github.fwcd.ktfmt:ktfmt:b5d31d1")
api("com.beust:jcommander:1.78")
api("org.hamcrest:hamcrest-all:1.3")
api("junit:junit:4.11")
api("org.openjdk.jmh:jmh-core:1.20")
api("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
api("org.openjdk.jmh:jmh-generator-annprocess:1.20")
}
}
80 changes: 36 additions & 44 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import groovy.lang.MissingPropertyException

plugins {
kotlin("jvm")
id("maven-publish")
id("application")
id("com.github.jk1.tcdeps") version "1.2"
id("com.jaredsburrows.license") version "0.8.42"
id("com.github.jk1.tcdeps")
id("com.jaredsburrows.license")
}

val projectVersion = project.property("projectVersion").toString()
val kotlinVersion = project.property("kotlinVersion").toString()
val exposedVersion = project.property("exposedVersion").toString()
val lsp4jVersion = project.property("lsp4jVersion").toString()
val javaVersion = project.property("javaVersion").toString()
val projectVersion = "1.3.2"
val debugPort = 8000
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
val javaVersion = try {
project.property("javaVersion").toString()
} catch (_: MissingPropertyException) {
"11"
}

version = projectVersion

Expand All @@ -38,31 +40,37 @@ repositories {
}

dependencies {
// dependencies are constrained to versions defined
// in /gradle/platform/build.gradle.kts
implementation(platform("dev.fwcd.kotlin-language-server:platform"))
annotationProcessor(platform("dev.fwcd.kotlin-language-server:platform"))

implementation(project(":shared"))
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:$lsp4jVersion")
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:$lsp4jVersion")
implementation(kotlin("compiler", version = kotlinVersion))
implementation(kotlin("scripting-compiler", version = kotlinVersion))
implementation(kotlin("scripting-jvm-host-unshaded", version = kotlinVersion))
implementation(kotlin("sam-with-receiver-compiler-plugin", version = kotlinVersion))
implementation(kotlin("reflect", version = kotlinVersion))
implementation("org.jetbrains:fernflower:1.0")
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
implementation("com.h2database:h2:1.4.200")
implementation("com.github.fwcd.ktfmt:ktfmt:b5d31d1")
implementation("com.beust:jcommander:1.78")

testImplementation("org.hamcrest:hamcrest-all:1.3")
testImplementation("junit:junit:4.11")
testImplementation("org.openjdk.jmh:jmh-core:1.20")

implementation("org.eclipse.lsp4j:org.eclipse.lsp4j")
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc")
implementation(kotlin("compiler"))
implementation(kotlin("scripting-compiler"))
implementation(kotlin("scripting-jvm-host-unshaded"))
implementation(kotlin("sam-with-receiver-compiler-plugin"))
implementation(kotlin("reflect"))
implementation("org.jetbrains:fernflower")
implementation("org.jetbrains.exposed:exposed-core")
implementation("org.jetbrains.exposed:exposed-dao")
implementation("org.jetbrains.exposed:exposed-jdbc")
implementation("com.h2database:h2")
implementation("com.github.fwcd.ktfmt:ktfmt")
implementation("com.beust:jcommander")

testImplementation("org.hamcrest:hamcrest-all")
testImplementation("junit:junit")
testImplementation("org.openjdk.jmh:jmh-core")

// See https://github.com/JetBrains/kotlin/blob/65b0a5f90328f4b9addd3a10c6f24f3037482276/libraries/examples/scripting/jvm-embeddable-host/build.gradle.kts#L8
compileOnly(kotlin("scripting-jvm-host", version = kotlinVersion))
testCompileOnly(kotlin("scripting-jvm-host", version = kotlinVersion))
compileOnly(kotlin("scripting-jvm-host"))
testCompileOnly(kotlin("scripting-jvm-host"))

annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:1.20")
annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess")
}

configurations.forEach { config ->
Expand All @@ -81,16 +89,6 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
}
}

tasks.register<Copy>("copyPropertiesToTestWorkspace") {
from("$rootDir/gradle.properties")
into(file("src/test/resources/additionalWorkspace"))
}

tasks.register<Copy>("copyPropertiesToDSLTestWorkspace") {
from("$rootDir/gradle.properties")
into(file("src/test/resources/kotlinDSLWorkspace"))
}

tasks.register<Exec>("fixFilePermissions") {
// When running on macOS or Linux the start script
// needs executable permissions to run.
Expand Down Expand Up @@ -123,13 +121,7 @@ tasks.register<Sync>("installDebugDist") {
finalizedBy("debugStartScripts")
}

tasks.getByName("processTestResources") {
dependsOn("copyPropertiesToTestWorkspace", "copyPropertiesToDSLTestWorkspace")
}

tasks.withType<Test>() {
dependsOn("copyPropertiesToTestWorkspace", "copyPropertiesToDSLTestWorkspace")

testLogging {
events("failed")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
Expand Down
2 changes: 0 additions & 2 deletions server/src/test/resources/additionalWorkspace/.gitignore

This file was deleted.

File renamed without changes.
2 changes: 0 additions & 2 deletions server/src/test/resources/kotlinDSLWorkspace/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
projectVersion=1.3.2
kotlinVersion=1.8.10
exposedVersion=0.37.3
lsp4jVersion=0.15.0
javaVersion=11
25 changes: 25 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@ pluginManagement {
gradlePluginPortal()
maven("https://cache-redirector.jetbrains.com/kotlin.bintray.com/kotlin-plugin")
}

// Centralize plugin versions.
// Ensure these plugins use the same version from the /gradle/platform/build.gradle.kts
// otherwise you'll get an exception during Gradle's configuration phase
// stating that the plugin with the specified (or unspecified) version
// cannot be found.
//
// Once declared here, subsequent plugin blocks in the build don't require
// a version to be applied. They inherit the versions from the following
// block.
//
// This can be verified by running the dependencies task via
// ./gradlew dependencies
plugins {
id("application") apply false
id("maven-publish") apply false

kotlin("jvm") version "1.8.10" apply false
id("com.github.jk1.tcdeps") version "1.2" apply false
id("com.jaredsburrows.license") version "0.8.42" apply false
}
}

dependencyResolutionManagement {
includeBuild("gradle/platform")
}

rootProject.name = "kotlin-language-server"
Expand Down
19 changes: 16 additions & 3 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovy.lang.MissingPropertyException

plugins {
id("maven-publish")
kotlin("jvm")
Expand All @@ -8,15 +10,26 @@ repositories {
}

version = project.version
val javaVersion = try {
project.property("javaVersion").toString()
} catch (_: MissingPropertyException) {
"11"
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of("11"))
languageVersion.set(
JavaLanguageVersion.of(javaVersion)
)
}
}

dependencies {
// dependencies are constrained to versions defined
// in /gradle/platform/build.gradle.kts
implementation(platform("dev.fwcd.kotlin-language-server:platform"))

implementation(kotlin("stdlib"))
testImplementation("org.hamcrest:hamcrest-all:1.3")
testImplementation("junit:junit:4.11")
testImplementation("org.hamcrest:hamcrest-all")
testImplementation("junit:junit")
}

0 comments on commit 54c8465

Please sign in to comment.