@@ -448,6 +448,96 @@ void gradle(String versionPattern) {
448448 );
449449 }
450450
451+ @ Test
452+ void invertedWithVersionRangeMarksModulesWithoutOldKotlin () {
453+ var groupId = "org.jetbrains.kotlin" ;
454+ var artifactId = "kotlin-stdlib" ;
455+ var versionRange = "[0,2.3)" ;
456+ var negativeSub = "(Module does not have dependency: %s:%s:%s)~~" .formatted (groupId , artifactId , versionRange );
457+ var mavenMarker = "<!--~~%s>-->" .formatted (negativeSub );
458+ var javaMarker = "/*~~%s>*/" .formatted (negativeSub );
459+ rewriteRun (
460+ spec -> spec .recipe (new ModuleHasDependency (groupId , artifactId , null , versionRange , true )),
461+ // Module with old Kotlin (2.1.0) — should NOT be marked
462+ mavenProject ("old-kotlin" ,
463+ pomXml (
464+ """
465+ <project>
466+ <groupId>com.example</groupId>
467+ <artifactId>old-kotlin</artifactId>
468+ <version>1.0.0</version>
469+ <dependencies>
470+ <dependency>
471+ <groupId>org.jetbrains.kotlin</groupId>
472+ <artifactId>kotlin-stdlib</artifactId>
473+ <version>2.1.0</version>
474+ </dependency>
475+ </dependencies>
476+ </project>
477+ """
478+ ),
479+ java ("public class OldKotlin {}" )
480+ ),
481+ // Module with new Kotlin (2.3.0) — SHOULD be marked
482+ mavenProject ("new-kotlin" ,
483+ pomXml (
484+ """
485+ <project>
486+ <groupId>com.example</groupId>
487+ <artifactId>new-kotlin</artifactId>
488+ <version>1.0.0</version>
489+ <dependencies>
490+ <dependency>
491+ <groupId>org.jetbrains.kotlin</groupId>
492+ <artifactId>kotlin-stdlib</artifactId>
493+ <version>2.3.0</version>
494+ </dependency>
495+ </dependencies>
496+ </project>
497+ """ ,
498+ spec -> spec .after (actual ->
499+ assertThat (actual )
500+ .startsWith (mavenMarker )
501+ .actual ()
502+ )
503+ ),
504+ java (
505+ "public class NewKotlin {}" ,
506+ spec -> spec .after (actual ->
507+ assertThat (actual )
508+ .startsWith (javaMarker )
509+ .actual ()
510+ )
511+ )
512+ ),
513+ // Module with no Kotlin — SHOULD be marked
514+ mavenProject ("no-kotlin" ,
515+ pomXml (
516+ """
517+ <project>
518+ <groupId>com.example</groupId>
519+ <artifactId>no-kotlin</artifactId>
520+ <version>1.0.0</version>
521+ </project>
522+ """ ,
523+ spec -> spec .after (actual ->
524+ assertThat (actual )
525+ .startsWith (mavenMarker )
526+ .actual ()
527+ )
528+ ),
529+ java (
530+ "public class NoKotlin {}" ,
531+ spec -> spec .after (actual ->
532+ assertThat (actual )
533+ .startsWith (javaMarker )
534+ .actual ()
535+ )
536+ )
537+ )
538+ );
539+ }
540+
451541 @ Test
452542 void noPresentVersion () {
453543 rewriteRun (
0 commit comments