Coud not convert Java to Kotlin from IntelliJ [closed]
I tried to convert some Java source files to Kotlin from IntelliJ IDEA Community Edition. I open my Java source file in the IDE, right click on the file name tab, select Convert Java File to Kotlin File.
The IDE responds with a dialogue box telling me that Kotlin is not configured in the project and that I will have to configure Kotlin before performing a conversion.
I select the button labelled "OK, configure Kotlin in the project". The IDE responds with another dialogue box asking me to accept the Kotlin compiler and runtime version. Although the version disclosed in the attached screen shot says 1.8.0-RC2, I have selected 1.8.0 from the drop down menu, and I still receive the same result as what is stated below.
I accept the settings displayed in this dialogue box by selecting the button labelled "OK".
The IDE appears to show me all of the Gradle build files that were altered by the addition of the Kotlin library to them, but does not appear to alter the Jave file that I selected. I have to reopen the Java file in the editor to check this.
Again, I right click on the file name tab of the Java File's editor pane, select the Convert Java File to Kotlin File option, and I get first given dialogue box stated earlier. I select "OK, configure Kotlin in the project", and I am now confronted with another dialogue box advising me that Kotlin is not configured in the project because there are no "configurators" available.
Again, my file was not converted, and the dialogue box produced above wasn't very helpful, so I right clicked on the "clique-space" project's name in the Project pane and selected "Analyse Dependencies...". This is the output I received:
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Where:
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Build file '/home/x/Development/CliqueSpace/Current/Code/trunk/clique-space/clique-space-concept/build.gradle' line: 2
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.8.0-RC2']
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --stacktrace option to get the stack trace.
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --scan to get full insights.
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
2022-12-26T22:34:39.111+1100 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 219ms
When I build this project from the multiproject build script, I get the following output:
cd /home/x/Development/CliqueSpace/Current/Code/trunk/clique-space; ./gradlew --configure-on-demand -x check clean build
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* Where:
Script '/home/x/Development/CliqueSpace/Current/Code/trunk/clique-space/clique-space-concept/build.gradle' line: 2
* What went wrong:
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.8.0-RC2']
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
* 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
BUILD FAILED in 79ms
My Gradle multiproject root build file named clique-space has the following contents:
1 subprojects {
2 apply plugin: 'java'
3
4 repositories {
5 mavenCentral()
6 }
7 }
8 buildscript {
9 ext.kotlin_version = '1.8.0'
10 repositories {
11 mavenCentral()
12 }
13 dependencies {
14 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15 }
16 }
17 apply plugin: 'kotlin'
18 repositories {
19 mavenCentral()
20 }
21 dependencies {
22 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
23 }
24 compileKotlin {
25 kotlinOptions {
26 jvmTarget = "1.8"
27 }
28 }
29 compileTestKotlin {
30 kotlinOptions {
31 jvmTarget = "1.8"
32 }
33 }
Line 17 in this build scrips seems out of place. I think this line should go in the subprojects section below line 2. So, I've moved it there so the file looks like this:
1 subprojects {
2 apply plugin: 'java'
3 apply plugin: 'kotlin'
4
5 repositories {
6 mavenCentral()
7 }
8 }
9 buildscript {
10 ext.kotlin_version = '1.8.0'
11 repositories {
12 mavenCentral()
13 }
14 dependencies {
15 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16 }
17 }
18 repositories {
19 mavenCentral()
20 }
21 dependencies {
22 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
23 }
24 compileKotlin {
25 kotlinOptions {
26 jvmTarget = "1.8"
27 }
28 }
29 compileTestKotlin {
30 kotlinOptions {
31 jvmTarget = "1.8"
32 }
33 }
Now, although I am not sure if this is an improvement or a further screw up (some guidance would be great!), I get the following message when I try to build the clique-space project:
A problem occurred evaluating root project 'clique-space'.
> Could not find method implementation() for arguments [org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
I am at a complete loss. The only thing obvious to me is that the IntelliJ claim that it can easily convert Java to Kotlin is false. Help me find the answer to why this is going awry and you'll get a tick from me. Thanks.
Perhaps what I need to do is to abandon my current build script because it uses outdated and unsupported features of Gradle, and create a new project. Apart from the pious finger wagging (which isn't help, but equanimity by people who, without an answer, shouldn't be interacting with my question), there is absolutely no help to be had here on crap overfow! None at all!
A philosophy that admits "asking the wrong question" as a reasonable starting point for offering help to others is, at best, an exercise of wilful ignorance that bleeds into conceit.
Is there any credence in the suspicion that Kotlin (named after an island in Russian territory offshore from St Petersburg) may become a victim of Russia's war on Ukraine? Are my troubles with the language a symptom of this victimisation? Perhaps I should stick with Java (which works fine) for now?
Comments
Post a Comment