You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2022/11/17 18:51:06 UTC

[flink] branch master updated: [FLINK-30029][ci] Parse version/classifier separately

This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new f734fa717a8 [FLINK-30029][ci] Parse version/classifier separately
f734fa717a8 is described below

commit f734fa717a818968ad811e7ccd88f8aa09d50663
Author: Chesnay Schepler <ch...@apache.org>
AuthorDate: Thu Nov 17 19:50:43 2022 +0100

    [FLINK-30029][ci] Parse version/classifier separately
---
 .../flink/tools/ci/utils/notice/NoticeParser.java      | 18 +++++++++++++++---
 .../apache/flink/tools/ci/utils/shade/ShadeParser.java |  3 ++-
 .../flink/tools/ci/utils/notice/NoticeParserTest.java  | 18 ++++++++++++------
 .../flink/tools/ci/utils/shade/ShadeParserTest.java    |  2 +-
 4 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/notice/NoticeParser.java b/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/notice/NoticeParser.java
index eb234900a32..e58c6df78f7 100644
--- a/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/notice/NoticeParser.java
+++ b/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/notice/NoticeParser.java
@@ -36,11 +36,22 @@ public class NoticeParser {
 
     // "- org.apache.htrace:htrace-core:3.1.0-incubating"
     private static final Pattern NOTICE_DEPENDENCY_PATTERN =
-            Pattern.compile("- (?<groupId>[^ :]+):(?<artifactId>[^:]+):(?<version>[^ ]+)($| )");
+            Pattern.compile(
+                    "- "
+                            + "(?<groupId>[^ ]*?):"
+                            + "(?<artifactId>[^ ]*?):"
+                            + "(?:(?<classifier>[^ ]*?):)?"
+                            + "(?<version>[^ ]*?)"
+                            + "($| )");
     // "This project bundles "net.jcip:jcip-annotations:1.0".
     private static final Pattern NOTICE_BUNDLES_DEPENDENCY_PATTERN =
             Pattern.compile(
-                    ".*bundles \"(?<groupId>[^:]+):(?<artifactId>[^:]+):(?<version>[^\"]+)\".*");
+                    ".*bundles \""
+                            + "(?<groupId>[^ ]*?):"
+                            + "(?<artifactId>[^ ]*?):"
+                            + "(?:(?<classifier>[^ ]*?):)?"
+                            + "(?<version>[^ ]*?)"
+                            + "\".*");
 
     public static Optional<NoticeContents> parseNoticeFile(Path noticeFile) throws IOException {
         // 1st line contains module name
@@ -75,7 +86,8 @@ public class NoticeParser {
             String groupId = matcher.group("groupId");
             String artifactId = matcher.group("artifactId");
             String version = matcher.group("version");
-            return Optional.of(Dependency.create(groupId, artifactId, version, null));
+            String classifier = matcher.group("classifier");
+            return Optional.of(Dependency.create(groupId, artifactId, version, classifier));
         }
         return Optional.empty();
     }
diff --git a/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/shade/ShadeParser.java b/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/shade/ShadeParser.java
index 3ce87868679..0bd18d982f3 100644
--- a/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/shade/ShadeParser.java
+++ b/tools/ci/flink-ci-tools/src/main/java/org/apache/flink/tools/ci/utils/shade/ShadeParser.java
@@ -46,6 +46,7 @@ public final class ShadeParser {
                             + "(?<groupId>.*?):"
                             + "(?<artifactId>.*?):"
                             + "(?<type>.*?):"
+                            + "(?:(?<classifier>.*?):)?"
                             + "(?<version>.*?)"
                             + " in the shaded jar");
 
@@ -123,7 +124,7 @@ public final class ShadeParser {
                         dependencyMatcher.group("groupId"),
                         dependencyMatcher.group("artifactId"),
                         dependencyMatcher.group("version"),
-                        null));
+                        dependencyMatcher.group("classifier")));
     }
 
     private ShadeParser() {}
diff --git a/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/notice/NoticeParserTest.java b/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/notice/NoticeParserTest.java
index 2151120090f..72debdcd331 100644
--- a/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/notice/NoticeParserTest.java
+++ b/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/notice/NoticeParserTest.java
@@ -34,14 +34,17 @@ class NoticeParserTest {
         final Dependency dependency1 =
                 Dependency.create("groupId1", "artifactId1", "version1", null);
         final Dependency dependency2 =
-                Dependency.create("groupId2", "artifactId2", "version2", null);
+                Dependency.create("groupId2", "artifactId2", "version2", "classifier2");
+        final Dependency dependency3 =
+                Dependency.create("org.codehaus.woodstox", "stax2-api", "4.2.1", null);
         final List<String> noticeContents =
                 Arrays.asList(
                         module,
                         "",
                         "Some text about the applicable license",
-                        "- " + dependency1,
-                        "- " + dependency2,
+                        "- groupId1:artifactId1:version1",
+                        "- groupId2:artifactId2:classifier2:version2",
+                        "- org.codehaus.woodstox:stax2-api:4.2.1 (https://github.com/FasterXML/stax2-api/tree/stax2-api-4.2.1)",
                         "",
                         "some epilogue");
 
@@ -50,16 +53,19 @@ class NoticeParserTest {
                         contents -> {
                             assertThat(contents.getNoticeModuleName()).isEqualTo(module);
                             assertThat(contents.getDeclaredDependencies())
-                                    .containsExactlyInAnyOrder(dependency1, dependency2);
+                                    .containsExactlyInAnyOrder(
+                                            dependency1, dependency2, dependency3);
                         });
     }
 
     @Test
     void testParseNoticeFileBundlesPath() {
         final String module = "some-module";
-        final Dependency dependency = Dependency.create("groupId", "artifactId", "version", null);
+        final Dependency dependency =
+                Dependency.create("groupId", "artifactId", "version", "classifier");
         final List<String> noticeContents =
-                Arrays.asList(module, "", "Something bundles \"" + dependency + "\"");
+                Arrays.asList(
+                        module, "", "Something bundles \"groupId:artifactId:classifier:version\"");
 
         assertThat(NoticeParser.parseNoticeFile(noticeContents))
                 .hasValueSatisfying(
diff --git a/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/shade/ShadeParserTest.java b/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/shade/ShadeParserTest.java
index b9451f6bd28..66845907b1a 100644
--- a/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/shade/ShadeParserTest.java
+++ b/tools/ci/flink-ci-tools/src/test/java/org/apache/flink/tools/ci/utils/shade/ShadeParserTest.java
@@ -52,7 +52,7 @@ class ShadeParserTest {
         assertThat(dependenciesByModule.get("m1"))
                 .containsExactlyInAnyOrder(
                         Dependency.create("external", "dependency1", "2.1", null),
-                        Dependency.create("external", "dependency4", "classifier:2.4", null));
+                        Dependency.create("external", "dependency4", "2.4", "classifier"));
         assertThat(dependenciesByModule.get("m2"))
                 .containsExactlyInAnyOrder(Dependency.create("internal", "m1", "1.1", null));
     }