Skip to content

Commit 54c8465

Browse files
authored
Unify dependency versions (#424)
Addresses #419
1 parent 88d6f52 commit 54c8465

File tree

9 files changed

+126
-55
lines changed

9 files changed

+126
-55
lines changed

build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import io.gitlab.arturbosch.detekt.Detekt
22
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
33

4-
// TODO: change the hardcoded 1.6.10 to kotlinVeresion that lives in project props
5-
// We could use a buildSrc script for this.
6-
// See: https://github.com/gradle/kotlin-dsl-samples/issues/802
74
plugins {
8-
kotlin("jvm") version "1.8.10"
5+
kotlin("jvm")
96
`maven-publish`
107
id("io.gitlab.arturbosch.detekt") version "1.22.0"
118
}

gradle/platform/build.gradle.kts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
plugins {
2+
id("java-platform")
3+
}
4+
5+
group = "dev.fwcd.kotlin-language-server"
6+
7+
javaPlatform {
8+
allowDependencies()
9+
}
10+
11+
val kotlinVersion = "1.8.10"
12+
val exposedVersion = "0.37.3"
13+
val lsp4jVersion = "0.15.0"
14+
15+
// constrain the dependencies that we use to these specific versions
16+
dependencies {
17+
constraints {
18+
api("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
19+
api("org.hamcrest:hamcrest-all:1.3")
20+
api("junit:junit:4.11")
21+
api("org.eclipse.lsp4j:org.eclipse.lsp4j:$lsp4jVersion")
22+
api("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:$lsp4jVersion")
23+
api("org.jetbrains.kotlin:kotlin-compiler:$kotlinVersion")
24+
api("org.jetbrains.kotlin:kotlin-scripting-compiler:$kotlinVersion")
25+
api("org.jetbrains.kotlin:kotlin-scripting-jvm-host-unshaded:$kotlinVersion")
26+
api("org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin:$kotlinVersion")
27+
api("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
28+
api("org.jetbrains.kotlin:kotlin-jvm:$kotlinVersion")
29+
api("org.jetbrains:fernflower:1.0")
30+
api("org.jetbrains.exposed:exposed-core:$exposedVersion")
31+
api("org.jetbrains.exposed:exposed-dao:$exposedVersion")
32+
api("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
33+
api("com.h2database:h2:1.4.200")
34+
api("com.github.fwcd.ktfmt:ktfmt:b5d31d1")
35+
api("com.beust:jcommander:1.78")
36+
api("org.hamcrest:hamcrest-all:1.3")
37+
api("junit:junit:4.11")
38+
api("org.openjdk.jmh:jmh-core:1.20")
39+
api("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
40+
api("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
41+
api("org.openjdk.jmh:jmh-generator-annprocess:1.20")
42+
}
43+
}

server/build.gradle.kts

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
import groovy.lang.MissingPropertyException
12

23
plugins {
34
kotlin("jvm")
45
id("maven-publish")
56
id("application")
6-
id("com.github.jk1.tcdeps") version "1.2"
7-
id("com.jaredsburrows.license") version "0.8.42"
7+
id("com.github.jk1.tcdeps")
8+
id("com.jaredsburrows.license")
89
}
910

10-
val projectVersion = project.property("projectVersion").toString()
11-
val kotlinVersion = project.property("kotlinVersion").toString()
12-
val exposedVersion = project.property("exposedVersion").toString()
13-
val lsp4jVersion = project.property("lsp4jVersion").toString()
14-
val javaVersion = project.property("javaVersion").toString()
11+
val projectVersion = "1.3.2"
1512
val debugPort = 8000
1613
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
14+
val javaVersion = try {
15+
project.property("javaVersion").toString()
16+
} catch (_: MissingPropertyException) {
17+
"11"
18+
}
1719

1820
version = projectVersion
1921

@@ -38,31 +40,37 @@ repositories {
3840
}
3941

4042
dependencies {
43+
// dependencies are constrained to versions defined
44+
// in /gradle/platform/build.gradle.kts
45+
implementation(platform("dev.fwcd.kotlin-language-server:platform"))
46+
annotationProcessor(platform("dev.fwcd.kotlin-language-server:platform"))
47+
4148
implementation(project(":shared"))
42-
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:$lsp4jVersion")
43-
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:$lsp4jVersion")
44-
implementation(kotlin("compiler", version = kotlinVersion))
45-
implementation(kotlin("scripting-compiler", version = kotlinVersion))
46-
implementation(kotlin("scripting-jvm-host-unshaded", version = kotlinVersion))
47-
implementation(kotlin("sam-with-receiver-compiler-plugin", version = kotlinVersion))
48-
implementation(kotlin("reflect", version = kotlinVersion))
49-
implementation("org.jetbrains:fernflower:1.0")
50-
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
51-
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
52-
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
53-
implementation("com.h2database:h2:1.4.200")
54-
implementation("com.github.fwcd.ktfmt:ktfmt:b5d31d1")
55-
implementation("com.beust:jcommander:1.78")
56-
57-
testImplementation("org.hamcrest:hamcrest-all:1.3")
58-
testImplementation("junit:junit:4.11")
59-
testImplementation("org.openjdk.jmh:jmh-core:1.20")
49+
50+
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j")
51+
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc")
52+
implementation(kotlin("compiler"))
53+
implementation(kotlin("scripting-compiler"))
54+
implementation(kotlin("scripting-jvm-host-unshaded"))
55+
implementation(kotlin("sam-with-receiver-compiler-plugin"))
56+
implementation(kotlin("reflect"))
57+
implementation("org.jetbrains:fernflower")
58+
implementation("org.jetbrains.exposed:exposed-core")
59+
implementation("org.jetbrains.exposed:exposed-dao")
60+
implementation("org.jetbrains.exposed:exposed-jdbc")
61+
implementation("com.h2database:h2")
62+
implementation("com.github.fwcd.ktfmt:ktfmt")
63+
implementation("com.beust:jcommander")
64+
65+
testImplementation("org.hamcrest:hamcrest-all")
66+
testImplementation("junit:junit")
67+
testImplementation("org.openjdk.jmh:jmh-core")
6068

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

65-
annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:1.20")
73+
annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess")
6674
}
6775

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

84-
tasks.register<Copy>("copyPropertiesToTestWorkspace") {
85-
from("$rootDir/gradle.properties")
86-
into(file("src/test/resources/additionalWorkspace"))
87-
}
88-
89-
tasks.register<Copy>("copyPropertiesToDSLTestWorkspace") {
90-
from("$rootDir/gradle.properties")
91-
into(file("src/test/resources/kotlinDSLWorkspace"))
92-
}
93-
9492
tasks.register<Exec>("fixFilePermissions") {
9593
// When running on macOS or Linux the start script
9694
// needs executable permissions to run.
@@ -123,13 +121,7 @@ tasks.register<Sync>("installDebugDist") {
123121
finalizedBy("debugStartScripts")
124122
}
125123

126-
tasks.getByName("processTestResources") {
127-
dependsOn("copyPropertiesToTestWorkspace", "copyPropertiesToDSLTestWorkspace")
128-
}
129-
130124
tasks.withType<Test>() {
131-
dependsOn("copyPropertiesToTestWorkspace", "copyPropertiesToDSLTestWorkspace")
132-
133125
testLogging {
134126
events("failed")
135127
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL

server/src/test/resources/additionalWorkspace/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

server/src/test/resources/kotlinDSLWorkspace/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
projectVersion=1.3.2
2+
kotlinVersion=1.8.10
3+
exposedVersion=0.37.3
4+
lsp4jVersion=0.15.0
5+
javaVersion=11

settings.gradle.kts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@ pluginManagement {
33
gradlePluginPortal()
44
maven("https://cache-redirector.jetbrains.com/kotlin.bintray.com/kotlin-plugin")
55
}
6+
7+
// Centralize plugin versions.
8+
// Ensure these plugins use the same version from the /gradle/platform/build.gradle.kts
9+
// otherwise you'll get an exception during Gradle's configuration phase
10+
// stating that the plugin with the specified (or unspecified) version
11+
// cannot be found.
12+
//
13+
// Once declared here, subsequent plugin blocks in the build don't require
14+
// a version to be applied. They inherit the versions from the following
15+
// block.
16+
//
17+
// This can be verified by running the dependencies task via
18+
// ./gradlew dependencies
19+
plugins {
20+
id("application") apply false
21+
id("maven-publish") apply false
22+
23+
kotlin("jvm") version "1.8.10" apply false
24+
id("com.github.jk1.tcdeps") version "1.2" apply false
25+
id("com.jaredsburrows.license") version "0.8.42" apply false
26+
}
27+
}
28+
29+
dependencyResolutionManagement {
30+
includeBuild("gradle/platform")
631
}
732

833
rootProject.name = "kotlin-language-server"

shared/build.gradle.kts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.lang.MissingPropertyException
2+
13
plugins {
24
id("maven-publish")
35
kotlin("jvm")
@@ -8,15 +10,26 @@ repositories {
810
}
911

1012
version = project.version
13+
val javaVersion = try {
14+
project.property("javaVersion").toString()
15+
} catch (_: MissingPropertyException) {
16+
"11"
17+
}
1118

1219
java {
1320
toolchain {
14-
languageVersion.set(JavaLanguageVersion.of("11"))
21+
languageVersion.set(
22+
JavaLanguageVersion.of(javaVersion)
23+
)
1524
}
1625
}
1726

1827
dependencies {
28+
// dependencies are constrained to versions defined
29+
// in /gradle/platform/build.gradle.kts
30+
implementation(platform("dev.fwcd.kotlin-language-server:platform"))
31+
1932
implementation(kotlin("stdlib"))
20-
testImplementation("org.hamcrest:hamcrest-all:1.3")
21-
testImplementation("junit:junit:4.11")
33+
testImplementation("org.hamcrest:hamcrest-all")
34+
testImplementation("junit:junit")
2235
}

0 commit comments

Comments
 (0)