From 301e3c7770caa427f7a44c5819794215a5ed78dc Mon Sep 17 00:00:00 2001 From: "AO Industries, Inc" Date: Sun, 5 Dec 2021 21:39:46 -0600 Subject: [PATCH] Added timestamped snapshot version to example regular expressions `*-SNAPSHOT` versions can also be matched against their timestamped representation, such as `*-20211206.032231-24` We have modified the example snapshot regular expression to match either form of snapshot version. --- src/site/markdown/keysmap-format.md | 16 ++--- .../plugins/keysmap/ArtifactPatternTest.java | 58 ++++++++++--------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/site/markdown/keysmap-format.md b/src/site/markdown/keysmap-format.md index 93a1b4e9..fdfb380e 100644 --- a/src/site/markdown/keysmap-format.md +++ b/src/site/markdown/keysmap-format.md @@ -97,24 +97,24 @@ match a specific artifact with the version and any packaging test.groupId:artifactId:1.0.0 = 0x1234567890123456789012345678901234567890 --- -match any artifact from group with any packaging and a SNAPSHOT version by regular expression +match any artifact from group with any packaging and a SNAPSHOT/timestamped version by regular expression - test.groupId:*:~.*-SNAPSHOT$ = 0x1234567890123456789012345678901234567890 + test.groupId:*:~.*-(SNAPSHOT|\d{8,}\.\d{6}-\d+) = 0x1234567890123456789012345678901234567890 --- -match any artifact from group with any packaging and a non-SNAPSHOT version by negated regular expression +match any artifact from group with any packaging and a non-SNAPSHOT/timestamped version by negated regular expression - test.groupId:*:!~.*-SNAPSHOT$ = 0x1234567890123456789012345678901234567890 + test.groupId:*:!~.*-(SNAPSHOT|\d{8,}\.\d{6}-\d+) = 0x1234567890123456789012345678901234567890 --- -match a specific artifact with any packaging and a SNAPSHOT version by regular expression +match a specific artifact with any packaging and a SNAPSHOT/timestamped version by regular expression - test.groupId:artifactId:~.*-SNAPSHOT$ = 0x1234567890123456789012345678901234567890 + test.groupId:artifactId:~.*-(SNAPSHOT|\d{8,}\.\d{6}-\d+) = 0x1234567890123456789012345678901234567890 --- -match a specific artifact with specific packaging and a SNAPSHOT version by regular expression +match a specific artifact with specific packaging and a SNAPSHOT/timestamped version by regular expression - test.groupId:artifactId:jar:~.*-SNAPSHOT$ = 0x1234567890123456789012345678901234567890 + test.groupId:artifactId:jar:~.*-(SNAPSHOT|\d{8,}\.\d{6}-\d+) = 0x1234567890123456789012345678901234567890 --- match a specific artifact with any version and packaging and many keys diff --git a/src/test/java/org/simplify4u/plugins/keysmap/ArtifactPatternTest.java b/src/test/java/org/simplify4u/plugins/keysmap/ArtifactPatternTest.java index a04a8209..7a54e484 100644 --- a/src/test/java/org/simplify4u/plugins/keysmap/ArtifactPatternTest.java +++ b/src/test/java/org/simplify4u/plugins/keysmap/ArtifactPatternTest.java @@ -75,34 +75,36 @@ public Object[][] artifactsList() { {"test.*", testArtifact().build(), true}, {"*", testArtifact().build(), true}, // Regular expression in version - {"test.group:test:~.*-SNAPSHOT$", testArtifact().build(), false}, - {"test.group:test:!~.*-SNAPSHOT$", testArtifact().build(), true}, - {"test.group:test:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, - {"test.group:test:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:*:~.*-SNAPSHOT$", testArtifact().build(), false}, - {"test.group:*:!~.*-SNAPSHOT$", testArtifact().build(), true}, - {"test.group:*:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, - {"test.group:*:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:*:jar:~.*-SNAPSHOT$", testArtifact().build(), false}, - {"test.group:*:jar:!~.*-SNAPSHOT$", testArtifact().build(), true}, - {"test.group:*:jar:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, - {"test.group:*:jar:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:*:pom:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:*:pom:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:test:jar:~.*-SNAPSHOT$", testArtifact().build(), false}, - {"test.group:test:jar:!~.*-SNAPSHOT$", testArtifact().build(), true}, - {"test.group:test:jar:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, - {"test.group:test:jar:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:test:pom:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:test:pom:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:other:jar:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:other:jar:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"other.group:test:jar:~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"other.group:test:jar:!~.*-SNAPSHOT$", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, - {"test.group:test:jar:~.*-SNAPshot$", testArtifact().version("1.1.1-snapSHOT").build(), true}, - {"test.group:test:jar:!~.*-SNAPshot$", testArtifact().version("1.1.1-snapSHOT").build(), false}, - {"test.group:test:jar:~.*-snapSHOT$", testArtifact().version("1.1.1-SNAPshot").build(), true}, - {"test.group:test:jar:!~.*-snapSHOT$", testArtifact().version("1.1.1-SNAPshot").build(), false}, + {"test.group:test:~.*-SNAPSHOT", testArtifact().build(), false}, + {"test.group:test:!~.*-SNAPSHOT", testArtifact().build(), true}, + {"test.group:test:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, + {"test.group:test:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:test:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT-malicious").build(), false}, + {"test.group:test:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT-malicious").build(), true}, + {"test.group:*:~.*-SNAPSHOT", testArtifact().build(), false}, + {"test.group:*:!~.*-SNAPSHOT", testArtifact().build(), true}, + {"test.group:*:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, + {"test.group:*:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:*:jar:~.*-SNAPSHOT", testArtifact().build(), false}, + {"test.group:*:jar:!~.*-SNAPSHOT", testArtifact().build(), true}, + {"test.group:*:jar:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, + {"test.group:*:jar:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:*:pom:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:*:pom:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:test:jar:~.*-SNAPSHOT", testArtifact().build(), false}, + {"test.group:test:jar:!~.*-SNAPSHOT", testArtifact().build(), true}, + {"test.group:test:jar:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), true}, + {"test.group:test:jar:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:test:pom:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:test:pom:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:other:jar:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:other:jar:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"other.group:test:jar:~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"other.group:test:jar:!~.*-SNAPSHOT", testArtifact().version("1.1.1-SNAPSHOT").build(), false}, + {"test.group:test:jar:~.*-SNAPshot", testArtifact().version("1.1.1-snapSHOT").build(), true}, + {"test.group:test:jar:!~.*-SNAPshot", testArtifact().version("1.1.1-snapSHOT").build(), false}, + {"test.group:test:jar:~.*-snapSHOT", testArtifact().version("1.1.1-SNAPshot").build(), true}, + {"test.group:test:jar:!~.*-snapSHOT", testArtifact().version("1.1.1-SNAPshot").build(), false}, }; }