You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2021/01/07 15:00:00 UTC
[camel-quarkus] 02/02: Auto-update Camel major.minor in Antora
config files
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit c3db032e5ef55d05d59aca8f1bb90a33a25ec8fa
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu Jan 7 15:11:27 2021 +0100
Auto-update Camel major.minor in Antora config files
---
docs/pom.xml | 19 +++++++++++++++++++
pom.xml | 4 +++-
tooling/scripts/update-antora-config.groovy | 24 ++++++++++++++++--------
3 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/docs/pom.xml b/docs/pom.xml
index 4c7665f..b89eaa1 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -34,6 +34,25 @@
<build>
<plugins>
<plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-antora-config</id>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <source>file://${maven.multiModuleProjectDirectory}/tooling/scripts/update-antora-config.groovy</source>
+ <properties>
+ <maven.multiModuleProjectDirectory>${maven.multiModuleProjectDirectory}</maven.multiModuleProjectDirectory>
+ </properties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
diff --git a/pom.xml b/pom.xml
index 16a863a..a50124f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,10 +44,12 @@
<avro-ipc-version>1.10.0</avro-ipc-version>
<awssdk1-swf-libs.version>1.11.22</awssdk1-swf-libs.version>
<bouncycastle.version>${bouncycastle-version}</bouncycastle.version><!-- keep in sync with Camel -->
- <camel.major.minor>3.7</camel.major.minor>
+
+ <camel.major.minor>3.7</camel.major.minor> <!-- run after each change: cd docs && mvndev validate -->
<camel.version>${camel.major.minor}.0</camel.version>
<camel.docs.components.xref>${camel.major.minor}.x@components</camel.docs.components.xref><!-- the version in Camel's docs/components/antora.yml -->
<camel.docs.branch>camel-${camel.major.minor}.x</camel.docs.branch><!-- The stable branch on which our Antora docs depends -->
+
<commons-beanutils.version>${commons-beanutils-version}</commons-beanutils.version><!-- keep in sync with Camel -->
<commons-cli.version>1.4</commons-cli.version><!-- keep in sync with Quarkus, via quarkus-bootstrap-core -->
<commons-collections.version>3.2.2</commons-collections.version><!-- used by hbase, should be pretty stable as commons-collections are not developed actively anymore -->
diff --git a/tooling/scripts/update-antora-config.groovy b/tooling/scripts/update-antora-config.groovy
index 81d00bd..9533d9c 100644
--- a/tooling/scripts/update-antora-config.groovy
+++ b/tooling/scripts/update-antora-config.groovy
@@ -16,17 +16,20 @@
*/
/**
- * Makes sure that each itest is executed by the CI
+ * Replace property values (defined in pom.xml files) in Antora yaml config
*/
import java.nio.file.Path
+import java.nio.file.Paths
import java.nio.file.Files
import java.util.stream.Stream
+import java.util.stream.Collectors
import java.util.regex.Pattern
+import java.util.regex.Matcher
final Path treeRootDir = Paths.get(properties['maven.multiModuleProjectDirectory'])
-final final List<Path> replaceInFiles = [
+final List<Path> replaceInFiles = [
treeRootDir.resolve('docs/antora-playbook.yml'),
treeRootDir.resolve('docs/antora-playbook-dev.yml'),
treeRootDir.resolve('docs/antora.yml')
@@ -39,21 +42,26 @@ if (!missingFiles.isEmpty()) {
throw new IllegalStateException("Files expected to exist: " + missingFiles)
}
-final Pattern replacementPattern = Pattern.compile("([\\-\\:]) *([^ ]+) *# * replace ${([^}]+)}")
-replaceInFiles.stream()
- .forEach { path ->
+final Pattern replacementPattern = ~'([\\-\\:]) *([^ ]+) *# * replace \\$\\{([^}]+)\\}'
+
+replaceInFiles.each { path ->
+ println 'Updating ' + path
final String content = path.getText('UTF-8')
final Matcher m = replacementPattern.matcher(content)
final StringBuffer newContent = new StringBuffer(content.length())
while (m.find()) {
final String property = m.group(3)
- final String newValue = properties.get(property)
- m.appendReplacement(newContent, '$1 ' + Matcher.quoteReplacement(newValue) + ' # replace '" + Matcher.quoteReplacement('${' + property + '}'))
+ final String newValue = project.properties.get(property)
+ println " - replacing ${property} '" + m.group(2) +"' -> '${newValue}'"
+ m.appendReplacement(newContent, '$1 ' + Matcher.quoteReplacement(newValue) + ' # replace ' + Matcher.quoteReplacement('${' + property + '}'))
}
m.appendTail(newContent)
final String newContentString = newContent.toString()
if (!newContentString.equals(content)) {
+ println 'Updated ' + path
Files.write(path, newContentString.getBytes('UTF-8'))
+ } else {
+ println 'No change in ' + path
}
- }
+}