16
16
17
17
package org.jetbrains.kotlin.idea.maven
18
18
19
+ import org.jetbrains.kotlin.config.KotlinFacetSettings
20
+ import org.jetbrains.kotlin.idea.facet.KotlinFacet
21
+ import org.junit.Assert
19
22
import java.io.File
20
23
21
24
class KotlinMavenImporterTest : MavenImportingTestCase () {
@@ -384,7 +387,115 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
384
387
assertTestSources(" project" , " src/test/java" , " src/test/kotlin" , " src/test/kotlin.jvm" )
385
388
}
386
389
390
+ fun testJvmTarget () {
391
+ createProjectSubDirs(" src/main/kotlin" , " src/main/kotlin.jvm" , " src/test/kotlin" , " src/test/kotlin.jvm" )
392
+
393
+ importProject("""
394
+ <groupId>test</groupId>
395
+ <artifactId>project</artifactId>
396
+ <version>1.0.0</version>
397
+
398
+ <dependencies>
399
+ <dependency>
400
+ <groupId>org.jetbrains.kotlin</groupId>
401
+ <artifactId>kotlin-stdlib</artifactId>
402
+ <version>$kotlinVersion </version>
403
+ </dependency>
404
+ </dependencies>
405
+
406
+ <build>
407
+ <sourceDirectory>src/main/kotlin</sourceDirectory>
408
+
409
+ <plugins>
410
+ <plugin>
411
+ <groupId>org.jetbrains.kotlin</groupId>
412
+ <artifactId>kotlin-maven-plugin</artifactId>
413
+
414
+ <executions>
415
+ <execution>
416
+ <id>compile</id>
417
+ <phase>compile</phase>
418
+ <goals>
419
+ <goal>compile</goal>
420
+ </goals>
421
+ </execution>
422
+ </executions>
423
+ <configuration>
424
+ <jvmTarget>1.8</jvmTarget>
425
+ </configuration>
426
+ </plugin>
427
+ </plugins>
428
+ </build>
429
+ """ )
430
+
431
+ assertModules(" project" )
432
+ assertImporterStatePresent()
433
+
434
+ with (facetSettings) {
435
+ Assert .assertEquals(" JVM 1.8" , versionInfo.targetPlatformKind!! .description)
436
+ Assert .assertEquals(" 1.8" , compilerInfo.k2jvmCompilerArguments!! .jvmTarget)
437
+ }
438
+ }
439
+
440
+ fun testArgsInFacet () {
441
+ createProjectSubDirs(" src/main/kotlin" , " src/main/kotlin.jvm" , " src/test/kotlin" , " src/test/kotlin.jvm" )
442
+
443
+ importProject("""
444
+ <groupId>test</groupId>
445
+ <artifactId>project</artifactId>
446
+ <version>1.0.0</version>
447
+
448
+ <dependencies>
449
+ <dependency>
450
+ <groupId>org.jetbrains.kotlin</groupId>
451
+ <artifactId>kotlin-stdlib</artifactId>
452
+ <version>$kotlinVersion </version>
453
+ </dependency>
454
+ </dependencies>
455
+
456
+ <build>
457
+ <sourceDirectory>src/main/kotlin</sourceDirectory>
458
+
459
+ <plugins>
460
+ <plugin>
461
+ <groupId>org.jetbrains.kotlin</groupId>
462
+ <artifactId>kotlin-maven-plugin</artifactId>
463
+
464
+ <executions>
465
+ <execution>
466
+ <id>compile</id>
467
+ <phase>compile</phase>
468
+ <goals>
469
+ <goal>compile</goal>
470
+ </goals>
471
+ </execution>
472
+ </executions>
473
+ <configuration>
474
+ <args>
475
+ <arg>-jvm-target</arg>
476
+ <arg>1.8</arg>
477
+ <arg>-Xcoroutines=enable</arg>
478
+ </args>
479
+ </configuration>
480
+ </plugin>
481
+ </plugins>
482
+ </build>
483
+ """ )
484
+
485
+ assertModules(" project" )
486
+ assertImporterStatePresent()
487
+
488
+ with (facetSettings) {
489
+ Assert .assertEquals(" JVM 1.8" , versionInfo.targetPlatformKind!! .description)
490
+ Assert .assertEquals(" 1.8" , compilerInfo.k2jvmCompilerArguments!! .jvmTarget)
491
+ Assert .assertEquals(" enable" , compilerInfo.coroutineSupport.compilerArgument)
492
+ }
493
+ }
494
+
387
495
private fun assertImporterStatePresent () {
388
496
assertNotNull(" Kotlin importer component is not present" , myTestFixture.module.getComponent(KotlinImporterComponent ::class .java))
389
497
}
498
+
499
+ private val facetSettings: KotlinFacetSettings
500
+ get() = KotlinFacet .get(getModule(" project" ))!! .configuration.settings
390
501
}
0 commit comments