Skip to content

Commit

Permalink
CAMEL-21252 Add checking for non .*-versions to sync-properties-maven…
Browse files Browse the repository at this point in the history
…-plugin
  • Loading branch information
cunningt committed Sep 23, 2024
1 parent 2b4f6b2 commit 51b3593
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
3 changes: 3 additions & 0 deletions camel-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
<goals>
<goal>sync-properties</goal>
</goals>
<configuration>
<checkForInvalidVersions>true</checkForInvalidVersions>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion components/camel-zeebe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-client-java</artifactId>
<version>${zeebe.version}</version>
<version>${zeebe-version}</version>
</dependency>

<!-- test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
<jboss-el-api_3.0_spec-version>2.0.0.Final</jboss-el-api_3.0_spec-version>
<jboss-logging-version>3.6.1.Final</jboss-logging-version>
<jboss-marshalling-version>1.4.10.Final</jboss-marshalling-version>
<jboss-transaction-spi.version>7.6.1.Final</jboss-transaction-spi.version>
<jboss-transaction-spi-version>7.6.1.Final</jboss-transaction-spi-version>
<jboss-xnio-version>3.3.8.Final</jboss-xnio-version>
<jcache-version>1.1.1</jcache-version>
<jcr-version>2.0</jcr-version>
Expand Down Expand Up @@ -501,7 +501,7 @@
<xpp3-version>1.1.4c</xpp3-version>
<yasson-version>3.0.4</yasson-version>
<yetus-audience-annotations-version>0.15.0</yetus-audience-annotations-version>
<zeebe.version>8.5.7</zeebe.version>
<zeebe-version>8.5.7</zeebe-version>
<zendesk-client-version>1.0.0</zendesk-client-version>
<zookeeper-version>3.9.2</zookeeper-version>
<zxing-version>3.5.3</zxing-version>
Expand Down
2 changes: 1 addition & 1 deletion tests/camel-itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-transaction-spi-jakarta</artifactId>
<version>${jboss-transaction-spi.version}</version>
<version>${jboss-transaction-spi-version}</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ public class SyncPropertiesMojo extends AbstractMojo {
@Parameter(defaultValue = ".*-version")
private List<String> 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<String> propertyInvalidVersions;

/**
* List of regular expressions to ignore from {@link #sourcePomXml}
*
Expand Down Expand Up @@ -154,6 +170,27 @@ public void execute() throws MojoExecutionException, MojoFailureException {

final Predicate<String> includes = toPredicate(propertyIncludes, true);
final Predicate<String> excludes = toPredicate(propertyExcludes, false);
final Predicate<String> 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()
Expand Down

0 comments on commit 51b3593

Please sign in to comment.