From 51b35936117af12683c1ddbfbc2b2c91d97a1503 Mon Sep 17 00:00:00 2001 From: Tom Cunningham Date: Mon, 23 Sep 2024 16:22:04 -0400 Subject: [PATCH] CAMEL-21252 Add checking for non .*-versions to sync-properties-maven-plugin --- camel-dependencies/pom.xml | 3 ++ components/camel-zeebe/pom.xml | 2 +- .../ROOT/pages/camel-report-maven-plugin.adoc | 2 +- parent/pom.xml | 4 +- tests/camel-itest/pom.xml | 2 +- .../sync/properties/SyncPropertiesMojo.java | 37 +++++++++++++++++++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml index 7a3f3476afe0e..57f02d417c415 100644 --- a/camel-dependencies/pom.xml +++ b/camel-dependencies/pom.xml @@ -63,6 +63,9 @@ sync-properties + + true + diff --git a/components/camel-zeebe/pom.xml b/components/camel-zeebe/pom.xml index 52cb9b9770431..d1d5f06de4578 100644 --- a/components/camel-zeebe/pom.xml +++ b/components/camel-zeebe/pom.xml @@ -70,7 +70,7 @@ io.camunda zeebe-client-java - ${zeebe.version} + ${zeebe-version} diff --git a/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc b/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc index f60afeb4d7fc0..fd3202a8532e5 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc @@ -357,7 +357,7 @@ The maven plugin *coverage* goal supports the following options which can be con patterns (wildcard and regular expression). Multiple values can be separated by comma. | excludes | | To filter the names of java and xml files to exclude files matching any of the given list of patterns (wildcard and regular expression). Multiple values can be separated by comma. -| anonymousRoutes | false | Whether to allow anonymous routes (routes without any route id assigned). +| anonymousRoutes | false | **Deprecated** Whether to allow anonymous routes (routes without any route id assigned). By using route id's then it is safer to match the route cover data with the route source code. Anonymous routes are less safe to use for route coverage as its harder to know exactly which route that was tested corresponds to which of the routes from the source code. diff --git a/parent/pom.xml b/parent/pom.xml index 2bc04269ffe2f..4b6a39fc300b7 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -264,7 +264,7 @@ 2.0.0.Final 3.6.1.Final 1.4.10.Final - 7.6.1.Final + 7.6.1.Final 3.3.8.Final 1.1.1 2.0 @@ -501,7 +501,7 @@ 1.1.4c 3.0.4 0.15.0 - 8.5.7 + 8.5.7 1.0.0 3.9.2 3.5.3 diff --git a/tests/camel-itest/pom.xml b/tests/camel-itest/pom.xml index fcb2241e92cf5..a6c721111c662 100644 --- a/tests/camel-itest/pom.xml +++ b/tests/camel-itest/pom.xml @@ -356,7 +356,7 @@ org.jboss jboss-transaction-spi-jakarta - ${jboss-transaction-spi.version} + ${jboss-transaction-spi-version} org.jboss.logging diff --git a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java index 52f66cfff34e4..42b58630f8b14 100644 --- a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java +++ b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java @@ -101,6 +101,22 @@ public class SyncPropertiesMojo extends AbstractMojo { @Parameter(defaultValue = ".*-version") private List propertyIncludes; + /** + * Check for invalid versions + * + * @since 4.9.0 + */ + @Parameter(defaultValue = "false") + private Boolean checkForInvalidVersions; + + /** + * List of regular expressions with invalid versions + * + * @since 4.9.0 + */ + @Parameter(defaultValue = ".*[^\\-]version") + private List propertyInvalidVersions; + /** * List of regular expressions to ignore from {@link #sourcePomXml} * @@ -154,6 +170,27 @@ public void execute() throws MojoExecutionException, MojoFailureException { final Predicate includes = toPredicate(propertyIncludes, true); final Predicate excludes = toPredicate(propertyExcludes, false); + final Predicate invalids = toPredicate(propertyInvalidVersions, true); + + // Check for versions that do not fit the .*-version pattern and log an error + // Enforce the .*-version standard + if (checkForInvalidVersions.booleanValue()) { + List invalidProperties = Stream.concat(camelParentPomXmlModel.getProperties().entrySet().stream(), + camelPomXmlModel.getProperties().entrySet().stream() + .filter(property -> !(property.getKey().equals("jdk.version")))) + .filter(property -> invalids.test((String) property.getKey()) && !excludes.test((String) property.getKey())) + .map(property -> property.getKey()) + .sorted() + .collect(Collectors.toList()); + + if (invalidProperties.size() > 0) { + throw new MojoExecutionException( + "sync-properties-maven-plugin will only synchronize properties matching " + + propertyIncludes + ". " + "Properties were found that will not be synced " + + invalidProperties.toString()); + } + } + final String properties = Stream.concat( camelParentPomXmlModel.getProperties().entrySet().stream(), camelPomXmlModel.getProperties().entrySet().stream()