![]() ![]() ![]() If you override the Kotlin/JVM KotlinJvmCompile/ KotlinCompile task's destinationDirectory location, update your build script. Non-default location of compile tasks' destinationDirectory Starting from Kotlin 1.8.20, the Kotlin Gradle plugin registers all tasks and doesn't configure them on a dry run. Put module-info.java into the src/main/java directory as usual.įor a module, a package name in Kotlin files should be equal to the package name from module-info.java to avoid a "package is empty or does not exist" build failure.īuilding modules for the Java Module Systemīuilding applications using the Java Module System Tasks.named("compileJava", JavaCompile.class) "] Add the following three lines if you use a Gradle version less than 7.0 Replace the placeholder with the JDK version you would like to use: Use the following code to set a toolchain. Sets the toolchain to be used by any Java compile, test and javadoc tasks.Īffects which JDK kapt workers are running on. Learn more about JVM target compatibility. If the user doesn't configure the toolchain, the jvmTarget field uses the default value. Sets the compilerOptions.jvmTarget to the toolchain's JDK version if the user doesn't set the jvmTarget option explicitly. Sets the -jdk-home option available for JVM targets. The Kotlin compiler always runs on the JDK the Gradle daemon is running on. JS and Native tasks don't use toolchains. ![]() The Kotlin Gradle plugin supports Java toolchains for Kotlin/JVM compilation tasks. Now Gradle itself can run on any JDK and still reuse the remote build cache feature for tasks that depend on a major JDK version. With toolchains support, Gradle can autodetect local JDKs and install missing JDKs that Gradle requires for the build. Use a JDK and a JRE that are different from the ones in Gradle to run compilations, tests, and executables.Ĭompile and test code with a not-yet-released language version. Gradle 6.7 introduced Java toolchains support. If you use versions less than 8.1.0-alpha09, you need to configure targetCompatibility manually via compileOptions. Nevertheless, because of this issue, AGP did not set targetCompatibility to be equal to the toolchain's JDK until the version 8.1.0-alpha09. Gradle Java toolchain support is available only from AGP 7.4.0. To use Gradle toolchain support, use the Android Gradle plugin (AGP) version 8.1.0-alpha09 or higher. Gradle Java toolchains supportĪ warning for Android users. Configure a toolchain to solve this issue. In this case, you have to use Java 17 in your main project to add this library, even though the bytecode's version is 1.8. Assuming that your JDK version is 17, your published library artifact will declare itself compatible with JDK 17+: =17, which is wrong. The targetCompatibility equals the current Gradle's JDK version, which is equal to your JDK version (unless you use a Java toolchain approach). When there is no explicit information about the jvmTarget value in the build script, its default value is null, and the compiler translates it to the default value 1.8. You can also configure it at task level in your adle(.kts) file: Ignore – the plugin skips the check and doesn't produce any messages. Warning – the plugin prints a warning message the default value for projects on Gradle less than 8.0. For example: the compileKotlin task has jvmTarget=1.8, and the compileJava task has (or inherits) targetCompatibility=15.Ĭonfigure the behavior of this check for the whole project by setting the .mode property in the adle(.kts) file to:Įrror – the plugin fails the build the default value for projects on Gradle 8.0+. Different values of the jvmTarget attribute in the kotlin extension or task and targetCompatibility in the java extension or task cause JVM target incompatibility. Main and test source set compile tasks are not related.įor related tasks like these, the Kotlin Gradle plugin checks for JVM target compatibility. In the build module, you may have related compile tasks, for example: SourceSets Ĭompile fileTree(dir: 'libs', include: )ĪndroidTestCompile('.espresso:espresso-core:2.2. += 'src/main/myKotlin'Ĭheck for JVM target compatibility of related compile tasks ProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' TestInstrumentationRunner ".AndroidJUnitRunner" in the individual module adle filesĪnd second adle: apply plugin: '' NOTE: Do not place your application dependencies here they belong Here is my adle // Top-level build file where you can add configuration options common to all sub-projects/modules.Ĭlasspath ':gradle:2.3.0' Current version is 3.2 how can I solve this problem? ![]() When I today update Android Studio it write: Minimum supported Gradle version is 3.3. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |