|
17 | 17 | import org.junit.jupiter.api.condition.EnabledOnOs; |
18 | 18 | import org.junit.jupiter.api.condition.OS; |
19 | 19 | import org.openrewrite.java.JavaParser; |
| 20 | +import org.openrewrite.maven.MavenParser; |
20 | 21 | import org.openrewrite.test.RewriteTest; |
21 | 22 | import org.slf4j.Logger; |
22 | 23 | import org.slf4j.LoggerFactory; |
@@ -644,6 +645,144 @@ void upgradeToRecommendCoreVersionTestWithBaseline() { |
644 | 645 | .formatted(Settings.getBomVersion()))); |
645 | 646 | } |
646 | 647 |
|
| 648 | + @Test |
| 649 | + void upgradeToRecommendCoreVersionTestWithMultipleBom() { |
| 650 | + rewriteRun( |
| 651 | + spec -> { |
| 652 | + spec.parser(MavenParser.builder().activeProfiles("consume-incrementals")); |
| 653 | + spec.recipeFromResource( |
| 654 | + "/META-INF/rewrite/recipes.yml", |
| 655 | + "io.jenkins.tools.pluginmodernizer.UpgradeToRecommendCoreVersion"); |
| 656 | + }, |
| 657 | + // language=xml |
| 658 | + pomXml( |
| 659 | + """ |
| 660 | + <?xml version="1.0" encoding="UTF-8"?> |
| 661 | + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
| 662 | + <modelVersion>4.0.0</modelVersion> |
| 663 | + <parent> |
| 664 | + <groupId>org.jenkins-ci.plugins</groupId> |
| 665 | + <artifactId>plugin</artifactId> |
| 666 | + <version>4.88</version> |
| 667 | + <relativePath /> |
| 668 | + </parent> |
| 669 | + <artifactId>my-api</artifactId> |
| 670 | + <version>${revision}-${changelist}</version> |
| 671 | + <packaging>hpi</packaging> |
| 672 | + <name>My API Plugin</name> |
| 673 | + <properties> |
| 674 | + <revision>2.17.0</revision> |
| 675 | + <changelist>999999-SNAPSHOT</changelist> |
| 676 | + <jenkins.version>2.401.3</jenkins.version> |
| 677 | + </properties> |
| 678 | + <repositories> |
| 679 | + <repository> |
| 680 | + <id>repo.jenkins-ci.org</id> |
| 681 | + <url>https://repo.jenkins-ci.org/public/</url> |
| 682 | + </repository> |
| 683 | + </repositories> |
| 684 | + <pluginRepositories> |
| 685 | + <pluginRepository> |
| 686 | + <id>repo.jenkins-ci.org</id> |
| 687 | + <url>https://repo.jenkins-ci.org/public/</url> |
| 688 | + </pluginRepository> |
| 689 | + </pluginRepositories> |
| 690 | + <dependencyManagement> |
| 691 | + <dependencies> |
| 692 | + <dependency> |
| 693 | + <groupId>com.fasterxml.jackson</groupId> |
| 694 | + <artifactId>jackson-bom</artifactId> |
| 695 | + <version>2.17.0</version> |
| 696 | + <scope>import</scope> |
| 697 | + <type>pom</type> |
| 698 | + </dependency> |
| 699 | + <dependency> |
| 700 | + <groupId>io.jenkins.tools.bom</groupId> |
| 701 | + <artifactId>bom-2.401.x</artifactId> |
| 702 | + <version>2745.vc7b_fe4c876fa_</version> |
| 703 | + <scope>import</scope> |
| 704 | + <type>pom</type> |
| 705 | + </dependency> |
| 706 | + </dependencies> |
| 707 | + </dependencyManagement> |
| 708 | + <dependencies> |
| 709 | + <dependency> |
| 710 | + <groupId>com.fasterxml.jackson.core</groupId> |
| 711 | + <artifactId>jackson-databind</artifactId> |
| 712 | + </dependency> |
| 713 | + <dependency> |
| 714 | + <groupId>io.jenkins.plugins</groupId> |
| 715 | + <artifactId>json-api</artifactId> |
| 716 | + </dependency> |
| 717 | + </dependencies> |
| 718 | + </project> |
| 719 | + """, |
| 720 | + """ |
| 721 | + <?xml version="1.0" encoding="UTF-8"?> |
| 722 | + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
| 723 | + <modelVersion>4.0.0</modelVersion> |
| 724 | + <parent> |
| 725 | + <groupId>org.jenkins-ci.plugins</groupId> |
| 726 | + <artifactId>plugin</artifactId> |
| 727 | + <version>4.88</version> |
| 728 | + <relativePath /> |
| 729 | + </parent> |
| 730 | + <artifactId>my-api</artifactId> |
| 731 | + <version>${revision}-${changelist}</version> |
| 732 | + <packaging>hpi</packaging> |
| 733 | + <name>My API Plugin</name> |
| 734 | + <properties> |
| 735 | + <revision>2.17.0</revision> |
| 736 | + <changelist>999999-SNAPSHOT</changelist> |
| 737 | + <!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ --> |
| 738 | + <jenkins.baseline>2.452</jenkins.baseline> |
| 739 | + <jenkins.version>${jenkins.baseline}.4</jenkins.version> |
| 740 | + </properties> |
| 741 | + <repositories> |
| 742 | + <repository> |
| 743 | + <id>repo.jenkins-ci.org</id> |
| 744 | + <url>https://repo.jenkins-ci.org/public/</url> |
| 745 | + </repository> |
| 746 | + </repositories> |
| 747 | + <pluginRepositories> |
| 748 | + <pluginRepository> |
| 749 | + <id>repo.jenkins-ci.org</id> |
| 750 | + <url>https://repo.jenkins-ci.org/public/</url> |
| 751 | + </pluginRepository> |
| 752 | + </pluginRepositories> |
| 753 | + <dependencyManagement> |
| 754 | + <dependencies> |
| 755 | + <dependency> |
| 756 | + <groupId>com.fasterxml.jackson</groupId> |
| 757 | + <artifactId>jackson-bom</artifactId> |
| 758 | + <version>2.17.0</version> |
| 759 | + <scope>import</scope> |
| 760 | + <type>pom</type> |
| 761 | + </dependency> |
| 762 | + <dependency> |
| 763 | + <groupId>io.jenkins.tools.bom</groupId> |
| 764 | + <artifactId>bom-${jenkins.baseline}.x</artifactId> |
| 765 | + <version>%s</version> |
| 766 | + <scope>import</scope> |
| 767 | + <type>pom</type> |
| 768 | + </dependency> |
| 769 | + </dependencies> |
| 770 | + </dependencyManagement> |
| 771 | + <dependencies> |
| 772 | + <dependency> |
| 773 | + <groupId>com.fasterxml.jackson.core</groupId> |
| 774 | + <artifactId>jackson-databind</artifactId> |
| 775 | + </dependency> |
| 776 | + <dependency> |
| 777 | + <groupId>io.jenkins.plugins</groupId> |
| 778 | + <artifactId>json-api</artifactId> |
| 779 | + </dependency> |
| 780 | + </dependencies> |
| 781 | + </project> |
| 782 | + """ |
| 783 | + .formatted(Settings.getBomVersion()))); |
| 784 | + } |
| 785 | + |
647 | 786 | @Test |
648 | 787 | void upgradeToUpgradeToLatestJava11CoreVersion() { |
649 | 788 | rewriteRun( |
|
0 commit comments