Skip to content

Commit a44d92b

Browse files
committed
Merge branch 'main' of github.com:fwcd/kotlin-language-server into dependency-caching
2 parents d939788 + 8b24f5a commit a44d92b

File tree

10 files changed

+69
-29
lines changed

10 files changed

+69
-29
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
name: Build
2-
on: [push]
2+
on: [push, pull_request]
33

44
jobs:
55
build:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
java: ['11']
9+
java: ['11', '17']
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
- name: Setup JDK
13-
uses: actions/setup-java@v1
13+
uses: actions/setup-java@v2
1414
with:
15+
distribution: 'temurin'
1516
java-version: ${{ matrix.java }}
1617
- name: Build
1718
run: ./gradlew :server:build :shared:build

.github/workflows/deploy.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
- name: Setup JDK
13-
uses: actions/setup-java@v1
13+
uses: actions/setup-java@v2
1414
with:
15-
java-version: 11
15+
distribution: 'temurin'
16+
java-version: '11'
1617
- name: Build distribution
1718
run: ./gradlew :server:distZip :grammars:distZip
1819
- name: Create release

.gitignore

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1+
# General
2+
.DS_Store
3+
hs_err_*
4+
5+
# Java/Eclipse/IDEA
16
.settings
27
.classpath
38
.project
49
.factorypath
510
.gradle
6-
711
.idea
812
*.iml
9-
10-
lib-kotlin
1113
bin
1214
build
1315
target
1416
out
17+
18+
# Python
1519
__pycache__
16-
*.vsix
1720

21+
# Node.js
1822
node_modules
19-
.vscode-test
20-
21-
.DS_Store
2223

23-
hs_err_*
24+
# VSCode
25+
.vscode-test
26+
.vscode/*
27+
!.vscode/launch.json
28+
!.vscode/tasks.json
29+
*.vsix

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to the language server will be documented in this file.
33

44
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
55

6+
## [1.3.0]
7+
- Bump to Kotlin 1.6
8+
- Support JDK 17
9+
- Add incremental indexing
10+
- Improve logged Gradle errors
11+
612
## [1.2.0]
713
- Support for renaming
814
- Improved semantic highlighting for enum members

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
projectVersion=1.3.0
2-
kotlinVersion=1.5.20
3-
exposedVersion=0.32.1
1+
projectVersion=1.4.0
2+
kotlinVersion=1.6.10
3+
exposedVersion=0.37.3
44
lsp4jVersion=0.12.0
55
javaVersion=11

server/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dependencies {
4646
implementation "org.jetbrains.exposed:exposed-dao:$exposedVersion"
4747
implementation "org.jetbrains.exposed:exposed-jdbc:$exposedVersion"
4848
implementation 'com.h2database:h2:1.4.200'
49-
implementation 'com.github.fwcd.ktfmt:ktfmt:8ef3ee752a'
49+
implementation 'com.github.fwcd.ktfmt:ktfmt:b5d31d1'
5050
implementation 'com.beust:jcommander:1.78'
5151

5252
testImplementation 'org.hamcrest:hamcrest-all:1.3'
@@ -72,7 +72,7 @@ applicationDistribution.into('bin') {
7272

7373
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
7474
kotlinOptions {
75-
jvmTarget = "1.8"
75+
jvmTarget = "11"
7676
}
7777
}
7878

server/src/main/kotlin/org/javacs/kt/formatting/Formatter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package org.javacs.kt.formatting
22

3-
import com.facebook.ktfmt.format
4-
import com.facebook.ktfmt.FormattingOptions as KtfmtOptions
3+
import com.facebook.ktfmt.format.Formatter
4+
import com.facebook.ktfmt.format.FormattingOptions as KtfmtOptions
55
import org.eclipse.lsp4j.FormattingOptions
66

77
fun formatKotlinCode(
88
code: String,
99
options: FormattingOptions = FormattingOptions(4, true)
10-
): String = format(KtfmtOptions(
10+
): String = Formatter.format(KtfmtOptions(
1111
style = KtfmtOptions.Style.GOOGLE,
1212
blockIndent = options.tabSize,
1313
continuationIndent = 2 * options.tabSize

shared/src/main/kotlin/org/javacs/kt/classpath/GradleClassPathResolver.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,14 @@ private fun readDependenciesViaGradleCLI(projectDirectory: Path, gradleScripts:
9292

9393
private fun findGradleCLIDependencies(command: String, projectDirectory: Path): Set<Path>? {
9494
val (result, errors) = execAndReadStdoutAndStderr(command, projectDirectory)
95-
LOG.debug(result)
9695
if ("FAILURE: Build failed" in errors) {
97-
LOG.warn("Gradle task failed: {}", errors.lines().joinToString("\n"))
96+
LOG.warn("Gradle task failed: {}", errors)
97+
} else {
98+
for (error in errors.lines()) {
99+
if ("ERROR: " in error) {
100+
LOG.warn("Gradle error: {}", error)
101+
}
102+
}
98103
}
99104
return parseGradleCLIDependencies(result)
100105
}

shared/src/main/kotlin/org/javacs/kt/classpath/MavenClassPathResolver.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.javacs.kt.classpath
22

33
import org.javacs.kt.LOG
44
import org.javacs.kt.util.findCommandOnPath
5+
import org.javacs.kt.util.findProjectCommandWithName
56
import org.javacs.kt.util.execAndReadStdoutAndStderr
67
import java.nio.file.Path
78
import java.nio.file.Files
@@ -106,14 +107,14 @@ private fun mavenJarName(a: Artifact, source: Boolean) =
106107

107108
private fun generateMavenDependencyList(pom: Path): Path {
108109
val mavenOutput = Files.createTempFile("deps", ".txt")
109-
val command = "$mvnCommand dependency:list -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
110+
val command = "${mvnCommand(pom)} dependency:list -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
110111
runCommand(pom, command)
111112
return mavenOutput
112113
}
113114

114115
private fun generateMavenDependencySourcesList(pom: Path): Path {
115116
val mavenOutput = Files.createTempFile("sources", ".txt")
116-
val command = "$mvnCommand dependency:sources -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
117+
val command = "${mvnCommand(pom)} dependency:sources -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
117118
runCommand(pom, command)
118119
return mavenOutput
119120
}
@@ -128,8 +129,14 @@ private fun runCommand(pom: Path, command: String) {
128129
}
129130
}
130131

131-
private val mvnCommand: Path by lazy {
132-
requireNotNull(findCommandOnPath("mvn")) { "Unable to find the 'mvn' command" }
132+
private val mvnCommandFromPath: Path? by lazy {
133+
findCommandOnPath("mvn")
134+
}
135+
136+
private fun mvnCommand(pom: Path): Path {
137+
return requireNotNull(mvnCommandFromPath ?: findProjectCommandWithName("mvnw", pom)?.also {
138+
LOG.info("Using mvn wrapper (mvnw) in place of mvn command")
139+
}) { "Unable to find the 'mvn' command or suitable wrapper" }
133140
}
134141

135142
fun parseMavenArtifact(rawArtifact: String, version: String? = null): Artifact {

shared/src/main/kotlin/org/javacs/kt/util/ShellPathUtils.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,17 @@ private fun findExecutableOnPath(fileName: String): Path? {
3333

3434
return null
3535
}
36+
37+
fun findProjectCommandWithName(name: String, projectFile: Path): Path? =
38+
if (isOSWindows()) {
39+
findFileRelativeToProjectFile("$name.cmd", projectFile)
40+
} else {
41+
findFileRelativeToProjectFile(name, projectFile)
42+
}
43+
44+
private fun findFileRelativeToProjectFile(name: String, projectFile: Path): Path? =
45+
projectFile.resolveSibling(name).toFile().takeIf { file ->
46+
file.isFile && file.canExecute()
47+
}?.let { file ->
48+
Paths.get(file.absolutePath)
49+
}

0 commit comments

Comments
 (0)