@@ -203,13 +203,13 @@ kotlin {
203203}
204204
205205tasks {
206- named( " jvmTest" , Test ::class ) {
206+ val jvmTest by existing( Test ::class ) {
207207 // maxHeapSize = "1024m"
208208 }
209209
210- create( " compileJavaModuleInfo" , JavaCompile ::class ) {
210+ val compileJavaModuleInfo by registering( JavaCompile ::class ) {
211211 val moduleName = " kotlinx.datetime" // this module's name
212- val compileKotlinJvm = getByName< KotlinCompile >( " compileKotlinJvm " )
212+ val compileKotlinJvm by getting( KotlinCompile :: class )
213213 val sourceDir = file(" jvm/java9/" )
214214 val targetDir = compileKotlinJvm.destinationDir.resolve(" ../java9/" )
215215
@@ -227,7 +227,7 @@ tasks {
227227 // but it currently won't compile to a module-info.class file.
228228 // Note that module checking only works on JDK 9+,
229229 // because the JDK built-in base modules are not available in earlier versions.
230- val javaVersion = compileKotlinJvm.kotlinJavaToolchain.javaVersion.orNull
230+ val javaVersion = compileKotlinJvm.kotlinJavaToolchain.javaVersion.getOrNull()
231231 if (javaVersion?.isJava9Compatible == true ) {
232232 logger.info(" Module-info checking is enabled; $compileKotlinJvm is compiled using Java $javaVersion " )
233233 compileKotlinJvm.source(sourceDir)
@@ -247,6 +247,7 @@ tasks {
247247 options.release.set(9 )
248248
249249 // Ignore warnings about using 'requires transitive' on automatic modules.
250+ // not needed when compiling with recent JDKs, e.g. 17
250251 options.compilerArgs.add(" -Xlint:-requires-transitive-automatic" )
251252
252253 // Patch the compileKotlinJvm output classes into the compilation so exporting packages works correctly.
@@ -256,21 +257,20 @@ tasks {
256257 // Also ensure that the module path is used instead of classpath.
257258 classpath = compileKotlinJvm.classpath
258259 modularity.inferModulePath.set(true )
260+ }
259261
260- // Configure the JAR task so that it will include the compiled module-info class file.
261- getByName<Jar >(" jvmJar" ) {
262- dependsOn(this @create)
263- manifest {
264- attributes(" Multi-Release" to true )
265- }
266- from(targetDir) {
267- into(" META-INF/versions/9/" )
268- }
262+ // Configure the JAR task so that it will include the compiled module-info class file.
263+ val jvmJar by existing(Jar ::class ) {
264+ manifest {
265+ attributes(" Multi-Release" to true )
266+ }
267+ from(compileJavaModuleInfo) {
268+ into(" META-INF/versions/9/" )
269269 }
270270 }
271271}
272272
273- task( " downloadWindowsZonesMapping" ) {
273+ val downloadWindowsZonesMapping by tasks.registering {
274274 description = " Updates the mapping between Windows-specific and usual names for timezones"
275275 val output = " $projectDir /nativeMain/cinterop/public/windows_zones.hpp"
276276 outputs.file(output)
0 commit comments