Intellij Set Compiler Version

0 views
Skip to first unread message

Muriel Pelley

unread,
Aug 5, 2024, 11:29:15 AM8/5/24
to consusyto
Weplan to release one more traditionally versioned release as Kotlin 1.9, which will also include updates from the ongoing development of the K2 compiler frontend as it approaches stabilization. There will be no Kotlin 1.10. The next major version after Kotlin 1.9 will be Kotlin 2.0.

Kotlin changes with every language version update. New language features get introduced and old bugs get fixed. We always try to minimize the number and impact of breaking changes and follow the Kotlin language evolution process. Kotlin 2.0 will be no different in that respect.


We are committed to minimizing the impact of migrating your code from Kotlin 1.9 to Kotlin 2.0. We will keep you updated on the Kotlin 2.0 stabilization process and provide you with ample time to try out Kotlin 2.0 on your projects in advance so you can report any regressions that we might have missed in our testing. Our current work is focused on a beta-quality release of the K2 compiler frontend later this year, which you can track in this roadmap issue.


In order to give you the performance benefits of the new compiler frontend in your IDE, we are writing a completely new version of the Kotlin IDE plugin that is built on top of the K2 compiler frontend. We are currently working towards a public preview of this new IDE plugin. You can track this issue for updates.


By submitting this form, I agree that JetBrains s.r.o. ("JetBrains") may use my name, email address, and location data to send me newsletters, including commercial communications, and to process my personal data for this purpose. I agree that JetBrains may process said data using third-party services for this purpose in accordance with the JetBrains Privacy Policy. I understand that I can revoke this consent at any time in my profile. In addition, an unsubscribe link is included in each email.


When upgrading the Java/JDK version in a Maven project, we may encounter the error that a specific release version X is not supported. In this article, we will learn to fix this error and understand the root cause behind this exception.


I encountered this error when upgrading an application from Java 17 to Java 21. I was using the IntelliJ idea IDE, although it does not matter much. You can encounter this issue in other IDEs as well as in the terminal/command line as well.


This short Java tutorial discussed the root cause and the solution behind the error Maven-compiler-plugin: release version not supported. This can happen for any release of Java version when we upgrade the project dependencies.


The Scala plugin extends the Java plugin to add support for Scala projects.The plugin also supports joint compilation, which allows you to freely mix and match Scala and Java code with dependencies in both directions.For example, a Scala class can extend a Java class that in turn extends a Scala class.This makes it possible to use the best language for the job, and to rewrite any class in the other language if needed.


The Scala plugin assumes the project layout shown below. All the Scala source directories can contain Scala and Java code. The Java source directories may only contain Java source code. None of these directories need to exist or have anything in them; the Scala plugin will simply compile whatever it finds.


Scala projects need to declare a scala-library dependency. This dependency will then be used on compile and runtime class paths. It will also be used to get hold of the Scala compiler and Scaladoc tool, respectively.[1]


The ScalaCompile and ScalaDoc tasks consume Scala code in two ways: on their classpath, and on their scalaClasspath. The former is used to locate classes referenced by the source code, and will typically contain scala-library along with other libraries. The latter is used to load and execute the Scala compiler and Scaladoc tool, respectively, and should only contain the scala-compiler library and its dependencies.


The Scala plugin uses a configuration named zinc to resolve the Zinc compiler and its dependencies.Gradle will provide a default version of Zinc, but if you need to use a particular Zinc version, you can change it.Gradle supports version 1.6.0 of Zinc and above.


The Zinc compiler itself needs a compatible version of scala-library that may be different from the version required by your application.Gradle takes care of specifying a compatible version of scala-library for you.


The source directories containing the Scala source files of this source set. May also contain Java source files for joint compilation.Can set using anything described in Understanding implicit conversion to file collections.Default value: [projectDir/src/name/scala].


By compiling only classes whose source code has changed since the previous compilation, and classes affected by these changes, incremental compilation can significantly reduce Scala compilation time. It is particularly effective when frequently compiling small code increments, as is often done at development time.


The Scala plugin defaults to incremental compilation by integrating with Zinc, a standalone version of sbt's incremental Scala compiler. If you want to disable the incremental compilation, set force = true in your build file:


Note: This will only cause all classes to be recompiled if at least one input source file has changed. If there are no changes to the source files, the compileScala task will still be considered UP-TO-DATE as usual.


The Zinc-based Scala Compiler supports joint compilation of Java and Scala code. By default, all Java and Scala code under src/main/scala will participate in joint compilation. Even Java code will be compiled incrementally.


Incremental compilation requires dependency analysis of the source code. The results of this analysis are stored in the file designated by scalaCompileOptions.incrementalOptions.analysisFile (which has a sensible default). In a multi-project build, analysis files are passed on to downstream ScalaCompile tasks to enable incremental compilation across project boundaries. For ScalaCompile tasks added by the Scala plugin, no configuration is necessary to make this work. For other ScalaCompile tasks that you might add, the property scalaCompileOptions.incrementalOptions.publishedCode needs to be configured to point to the classes folder or Jar archive by which the code is passed on to compile class paths of downstream ScalaCompile tasks. Note that if publishedCode is not set correctly, downstream tasks may not recompile code affected by upstream changes, leading to incorrect compilation results.


When the Eclipse plugin encounters a Scala project, it adds additional configuration to make the project work with Scala IDE out of the box. Specifically, the plugin adds a Scala nature and dependency container.


After Java 8, Oracle introduced the concept of LTS versions of the JDK. These versions will remain supported (by Oracle, and likely by the rest of the ecosystem, including Scala) for longer than the versions in between. See -135779.html.


Scala provides experimental support for running the Scala compiler on non-LTS versions of the JDK. The current LTS versions are normally tested in our CI matrix and by the Scala community build. We may also test non-LTS versions, but any issues found there are considered lower priority, and will not be considered release blockers. (Lightbend may be able to offer faster resolution of issues like this under commercial support.)


For example, the Scala compiler does not enforce the restrictions of the Java Platform Module System, which means that code that typechecks may incur linkage errors at runtime. Scala 2.13.x will eventually provide rudimentary support for this (perhaps only in nightlies built on JDK 11).


There are several records of successfully using Scala with GraalVM Native Image (i.e., ahead of time compiler) to produce directly executable binaries.Beware that, even using solely the Scala standard library, Native Image compilation have some heavy requirements in terms of reflective access, and it very likely require additional configuration steps to be performed.


Use Maven to create a new project, add or remove extensions, launch development mode, debug your application, and build your application into a jar, native executable, or container-friendly executable. Import your project into your favorite IDE using Maven project metadata.


If you need to customize the compiler flags used by the plugin, like in development mode, add a configuration section to the plugin block and set the compilerArgs property just as you would when configuring maven-compiler-plugin.You can also set source, target, and jvmArgs.For example, to pass --enable-preview to both the JVM and javac:


Because the Quarkus Maven plugin itself runs in the JVM started by Maven,and because some (rare) Quarkus extensions need to load application classes during the build,it may be necessary to pass the same flags to the JVM running Maven.


Alternatively, you can simply create the file.mvn/jvm.config at the root of your project:and any options you put in that file will be picked up by Maven, without having to set MAVEN_OPTS.


You can then update the application sources, resources and configurations.The changes are automatically reflected in your running application.This is great to do development spanning UI and database as you see changes reflected immediately.


Dev mode enables hot deployment with background compilation, which meansthat when you modify your Java files or your resource files and refresh your browser these changes will automatically take effect.This works too for resource files like the configuration property file.The act ofrefreshing the browser triggers a scan of the workspace, and if any changes are detected the Java files are compiled,and the application is redeployed, then your request is serviced by the redeployed application. If there are any issueswith compilation or deployment an error page will let you know.


Now every time you refresh the browser you should see any changes you have made locally immediately visible in the remoteapp. This is done via an HTTP based long polling transport, that will synchronize your local workspace and the remoteapplication via HTTP calls.

3a8082e126
Reply all
Reply to author
Forward
0 new messages