kotlin-language-server
kotlin-language-server copied to clipboard
Failed to build on Mac M1 (arm - aarch64)
I tried building using ./gradlew :server:installDist
with java version 17.0.2
on the PATH. I get this failure:
Downloading https://services.gradle.org/distributions/gradle-7.3.1-bin.zip
...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
Welcome to Gradle 7.3.1!
Here are the highlights of this release:
- Easily declare new test suites in Java projects
- Support for Java 17
- Support for Scala 3
For more details see https://docs.gradle.org/7.3.1/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':server:installDist'.
> Could not resolve all dependencies for configuration ':server:runtimeClasspath'.
> Failed to calculate the value of task ':server:compileJava' property 'javaCompiler'.
> Unable to download toolchain matching these requirements: {languageVersion=11, vendor=any, implementation=vendor-specific}
> Unable to download toolchain. This might indicate that the combination (version, architecture, release/early access, ...) for the requested JDK is not available.
> Could not read 'https://api.adoptopenjdk.net/v3/binary/latest/11/ga/mac/aarch64/jdk/hotspot/normal/adoptopenjdk' as it does not exist.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
From some Googling, I found this issue in a different project, and what may have helped them is updating to Gradle 7.4 and some other changes (see this comment).
For me, I got it working with setting:
# in gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
# in gradle.properties
javaVersion=17
Though there were some intermediate failures:
Compilation with Kotlin compile daemon was not successful
java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.util.io.FileChannelUtil
...
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.util.io.FileChannelUtil
...
Could not connect to kotlin daemon. Using fallback strategy.
Could you check whether this still occurs on the most recent language server?
same thing happened to me.
I had to make the following changes to match the JVM available to gradle
diff --git a/gradle.properties b/gradle.properties
index e8355f8..0cdae21 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,4 +2,4 @@ projectVersion=1.4.0
kotlinVersion=1.6.10
exposedVersion=0.37.3
lsp4jVersion=0.12.0
-javaVersion=11
+javaVersion=15
diff --git a/server/build.gradle b/server/build.gradle
index 08d5c29..82fc80e 100644
--- a/server/build.gradle
+++ b/server/build.gradle
@@ -72,7 +72,7 @@ applicationDistribution.into('bin') {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
- jvmTarget = "11"
+ jvmTarget = "15"
}
}
Upgrade to the latest Gradle & kotlin plugin, it ought to work.