Skip to content

Commit b70a170

Browse files
committed
Factor out a Kotlin convention plugin for the toolchain
1 parent 0ea1cd6 commit b70a170

8 files changed

+29
-38
lines changed

buildSrc/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,15 @@ plugins {
44

55
repositories {
66
mavenCentral()
7+
gradlePluginPortal()
8+
}
9+
10+
// Use JDK 11 for compiling the convention plugins (this is NOT the project!)
11+
12+
kotlin {
13+
jvmToolchain(11)
14+
}
15+
16+
dependencies {
17+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
718
}

buildSrc/settings.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
dependencyResolutionManagement {
2-
repositories {
3-
gradlePluginPortal()
4-
}
5-
}
1+
rootProject.name = "build-conventions"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
kotlin("jvm")
3+
}
4+
5+
val javaVersion = property("javaVersion").toString()
6+
7+
kotlin {
8+
jvmToolchain(javaVersion.toInt())
9+
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version=1.3.2
2+
javaVersion=11

scripts/release_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def git_working_dir_is_clean(repo_path):
6161
}
6262
EDITOR = os.environ.get("EDITOR", "vim") # https://stackoverflow.com/questions/6309587/call-up-an-editor-vim-from-a-python-script
6363
PROJECT_DIR = Path(__file__).parent.parent
64-
PROJECT_VERSION_KEY = "projectVersion"
64+
PROJECT_VERSION_KEY = "version"
6565

6666
def main():
6767
parser = argparse.ArgumentParser(description="A small utility for updating the project's version and creating tags.")

server/build.gradle.kts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,20 @@ plugins {
66
id("application")
77
id("com.github.jk1.tcdeps")
88
id("com.jaredsburrows.license")
9-
id("kotlin-language-server.configure-publishing")
9+
id("kotlin-language-server.publishing-conventions")
10+
id("kotlin-language-server.kotlin-conventions")
1011
}
1112

12-
val projectVersion = "1.3.2"
1313
val debugPort = 8000
1414
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
15-
val javaVersion = try {
16-
project.property("javaVersion").toString()
17-
} catch (_: MissingPropertyException) {
18-
"11"
19-
}
20-
21-
version = projectVersion
2215

2316
val serverMainClassName = "org.javacs.kt.MainKt"
2417
val applicationName = "kotlin-language-server"
2518

2619
application {
2720
mainClass.set(serverMainClassName)
2821
description = "Code completions, diagnostics and more for Kotlin"
29-
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$projectVersion")
22+
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$version")
3023
applicationDistribution.into("bin") {
3124
fileMode = 755
3225
}
@@ -84,12 +77,6 @@ tasks.startScripts {
8477
applicationName = "kotlin-language-server"
8578
}
8679

87-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
88-
kotlinOptions {
89-
jvmTarget = javaVersion
90-
}
91-
}
92-
9380
tasks.register<Exec>("fixFilePermissions") {
9481
// When running on macOS or Linux the start script
9582
// needs executable permissions to run.

shared/build.gradle.kts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,14 @@ import groovy.lang.MissingPropertyException
33
plugins {
44
id("maven-publish")
55
kotlin("jvm")
6-
id("configure-publishing")
6+
id("kotlin-language-server.publishing-conventions")
7+
id("kotlin-language-server.kotlin-conventions")
78
}
89

910
repositories {
1011
mavenCentral()
1112
}
1213

13-
version = project.version
14-
val javaVersion = try {
15-
project.property("javaVersion").toString()
16-
} catch (_: MissingPropertyException) {
17-
"11"
18-
}
19-
20-
java {
21-
toolchain {
22-
languageVersion.set(
23-
JavaLanguageVersion.of(javaVersion)
24-
)
25-
}
26-
}
27-
2814
dependencies {
2915
// dependencies are constrained to versions defined
3016
// in /gradle/platform/build.gradle.kts

0 commit comments

Comments
 (0)