17
17
package org.jetbrains.kotlin.idea.maven
18
18
19
19
import org.jetbrains.kotlin.config.KotlinFacetSettings
20
+ import org.jetbrains.kotlin.config.TargetPlatformKind
20
21
import org.jetbrains.kotlin.idea.facet.KotlinFacet
21
22
import org.junit.Assert
22
23
import java.io.File
@@ -387,7 +388,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
387
388
assertTestSources(" project" , " src/test/java" , " src/test/kotlin" , " src/test/kotlin.jvm" )
388
389
}
389
390
390
- fun testJvmTarget () {
391
+ fun testJvmFacetConfiguration () {
391
392
createProjectSubDirs(" src/main/kotlin" , " src/main/kotlin.jvm" , " src/test/kotlin" , " src/test/kotlin.jvm" )
392
393
393
394
importProject("""
@@ -421,7 +422,16 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
421
422
</execution>
422
423
</executions>
423
424
<configuration>
425
+ <languageVersion>1.1</languageVersion>
426
+ <apiVersion>1.0</apiVersion>
427
+ <multiPlatform>true</multiPlatform>
428
+ <nowarn>true</nowarn>
429
+ <args>
430
+ <arg>-Xcoroutines=enable</arg>
431
+ </args>
424
432
<jvmTarget>1.8</jvmTarget>
433
+ <jdkHome>JDK_HOME</jdkHome>
434
+ <classpath>foobar.jar</classpath>
425
435
</configuration>
426
436
</plugin>
427
437
</plugins>
@@ -432,8 +442,154 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
432
442
assertImporterStatePresent()
433
443
434
444
with (facetSettings) {
445
+ Assert .assertEquals(" 1.1" , versionInfo.languageLevel!! .versionString)
446
+ Assert .assertEquals(" 1.1" , compilerInfo.commonCompilerArguments!! .languageVersion)
447
+ Assert .assertEquals(" 1.0" , versionInfo.apiLevel!! .versionString)
448
+ Assert .assertEquals(" 1.0" , compilerInfo.commonCompilerArguments!! .apiVersion)
449
+ Assert .assertEquals(true , compilerInfo.commonCompilerArguments!! .suppressWarnings)
450
+ Assert .assertEquals(" enable" , compilerInfo.coroutineSupport.compilerArgument)
451
+ Assert .assertEquals(" JVM 1.8" , versionInfo.targetPlatformKind!! .description)
452
+ Assert .assertEquals(" 1.8" , compilerInfo.k2jvmCompilerArguments!! .jvmTarget)
453
+ Assert .assertEquals(" -cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform" ,
454
+ compilerInfo.compilerSettings!! .additionalArguments)
455
+ }
456
+ }
457
+
458
+ fun testJsFacetConfiguration () {
459
+ createProjectSubDirs(" src/main/kotlin" , " src/main/kotlin.jvm" , " src/test/kotlin" , " src/test/kotlin.jvm" )
460
+
461
+ importProject("""
462
+ <groupId>test</groupId>
463
+ <artifactId>project</artifactId>
464
+ <version>1.0.0</version>
465
+
466
+ <dependencies>
467
+ <dependency>
468
+ <groupId>org.jetbrains.kotlin</groupId>
469
+ <artifactId>kotlin-stdlib</artifactId>
470
+ <version>$kotlinVersion </version>
471
+ </dependency>
472
+ </dependencies>
473
+
474
+ <build>
475
+ <sourceDirectory>src/main/kotlin</sourceDirectory>
476
+
477
+ <plugins>
478
+ <plugin>
479
+ <groupId>org.jetbrains.kotlin</groupId>
480
+ <artifactId>kotlin-maven-plugin</artifactId>
481
+
482
+ <executions>
483
+ <execution>
484
+ <id>compile</id>
485
+ <phase>compile</phase>
486
+ <goals>
487
+ <goal>js</goal>
488
+ </goals>
489
+ </execution>
490
+ </executions>
491
+ <configuration>
492
+ <languageVersion>1.1</languageVersion>
493
+ <apiVersion>1.0</apiVersion>
494
+ <multiPlatform>true</multiPlatform>
495
+ <nowarn>true</nowarn>
496
+ <args>
497
+ <arg>-Xcoroutines=enable</arg>
498
+ </args>
499
+ <sourceMap>true</sourceMap>
500
+ <outputFile>test.js</outputFile>
501
+ <metaInfo>true</metaInfo>
502
+ <moduleKind>commonjs</moduleKind>
503
+ </configuration>
504
+ </plugin>
505
+ </plugins>
506
+ </build>
507
+ """ )
508
+
509
+ assertModules(" project" )
510
+ assertImporterStatePresent()
511
+
512
+ with (facetSettings) {
513
+ Assert .assertEquals(" 1.1" , versionInfo.languageLevel!! .versionString)
514
+ Assert .assertEquals(" 1.1" , compilerInfo.commonCompilerArguments!! .languageVersion)
515
+ Assert .assertEquals(" 1.0" , versionInfo.apiLevel!! .versionString)
516
+ Assert .assertEquals(" 1.0" , compilerInfo.commonCompilerArguments!! .apiVersion)
517
+ Assert .assertEquals(true , compilerInfo.commonCompilerArguments!! .suppressWarnings)
518
+ Assert .assertEquals(" enable" , compilerInfo.coroutineSupport.compilerArgument)
519
+ Assert .assertTrue(versionInfo.targetPlatformKind is TargetPlatformKind .JavaScript )
520
+ Assert .assertEquals(true , compilerInfo.k2jsCompilerArguments!! .sourceMap)
521
+ Assert .assertEquals(" commonjs" , compilerInfo.k2jsCompilerArguments!! .moduleKind)
522
+ Assert .assertEquals(" -output test.js -meta-info -Xmulti-platform" ,
523
+ compilerInfo.compilerSettings!! .additionalArguments)
524
+ }
525
+ }
526
+
527
+ fun testFacetSplitConfiguration () {
528
+ createProjectSubDirs(" src/main/kotlin" , " src/main/kotlin.jvm" , " src/test/kotlin" , " src/test/kotlin.jvm" )
529
+
530
+ importProject("""
531
+ <groupId>test</groupId>
532
+ <artifactId>project</artifactId>
533
+ <version>1.0.0</version>
534
+
535
+ <dependencies>
536
+ <dependency>
537
+ <groupId>org.jetbrains.kotlin</groupId>
538
+ <artifactId>kotlin-stdlib</artifactId>
539
+ <version>$kotlinVersion </version>
540
+ </dependency>
541
+ </dependencies>
542
+
543
+ <build>
544
+ <sourceDirectory>src/main/kotlin</sourceDirectory>
545
+
546
+ <plugins>
547
+ <plugin>
548
+ <groupId>org.jetbrains.kotlin</groupId>
549
+ <artifactId>kotlin-maven-plugin</artifactId>
550
+
551
+ <executions>
552
+ <execution>
553
+ <id>compile</id>
554
+ <phase>compile</phase>
555
+ <goals>
556
+ <goal>compile</goal>
557
+ </goals>
558
+ <configuration>
559
+ <languageVersion>1.1</languageVersion>
560
+ <multiPlatform>true</multiPlatform>
561
+ <args>
562
+ <arg>-Xcoroutines=enable</arg>
563
+ </args>
564
+ <jdkHome>JDK_HOME</jdkHome>
565
+ <classpath>foobar.jar</classpath>
566
+ </configuration>
567
+ </execution>
568
+ </executions>
569
+ <configuration>
570
+ <apiVersion>1.0</apiVersion>
571
+ <nowarn>true</nowarn>
572
+ <jvmTarget>1.8</jvmTarget>
573
+ </configuration>
574
+ </plugin>
575
+ </plugins>
576
+ </build>
577
+ """ )
578
+
579
+ assertModules(" project" )
580
+ assertImporterStatePresent()
581
+
582
+ with (facetSettings) {
583
+ Assert .assertEquals(" 1.1" , versionInfo.languageLevel!! .versionString)
584
+ Assert .assertEquals(" 1.1" , compilerInfo.commonCompilerArguments!! .languageVersion)
585
+ Assert .assertEquals(" 1.0" , versionInfo.apiLevel!! .versionString)
586
+ Assert .assertEquals(" 1.0" , compilerInfo.commonCompilerArguments!! .apiVersion)
587
+ Assert .assertEquals(true , compilerInfo.commonCompilerArguments!! .suppressWarnings)
588
+ Assert .assertEquals(" enable" , compilerInfo.coroutineSupport.compilerArgument)
435
589
Assert .assertEquals(" JVM 1.8" , versionInfo.targetPlatformKind!! .description)
436
590
Assert .assertEquals(" 1.8" , compilerInfo.k2jvmCompilerArguments!! .jvmTarget)
591
+ Assert .assertEquals(" -version -cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform" ,
592
+ compilerInfo.compilerSettings!! .additionalArguments)
437
593
}
438
594
}
439
595
0 commit comments