You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Parkerhiphop (via GitHub)" <gi...@apache.org> on 2026/01/21 11:37:35 UTC
[PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Parkerhiphop opened a new pull request, #21340:
URL: https://github.com/apache/kafka/pull/21340
### Description
This PR replaces the verbose manual version update instructions in `gradle.properties` with a custom Gradle task to automate the process.
The new `updateVersion` task automatically syncs the version number across the following files:
* `committer-tools/kafka-merge-pr.py`
* `tests/kafkatest/version.py`
* `tests/kafkatest/__init__.py`
* `streams/quickstart/pom.xml`
* `streams/quickstart/java/pom.xml`
* `streams/quickstart/java/src/main/resources/archetype-resources/pom.xml`
### Verification
I verified the task locally with the following steps:
1. Modified the version in `gradle.properties`.
2. Ran `./gradlew updateVersion`.
3. Verified that all target files were updated correctly.
**Console Output:**
```text
> Task :updateVersion
Updated committer-tools/kafka-merge-pr.py
Updated tests/kafkatest/version.py
Updated tests/kafkatest/__init__.py
Updated streams/quickstart/pom.xml
Updated streams/quickstart/java/pom.xml
Updated streams/quickstart/java/src/main/resources/archetype-resources/pom.xml
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "Parkerhiphop (via GitHub)" <gi...@apache.org>.
Parkerhiphop commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2725998653
##########
build.gradle:
##########
@@ -3990,3 +3990,103 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
Review Comment:
Thans for review! I've updated the PR description with the details, but here is the output when inconsistencies are detected.
For example, if I manually update `gradle.properties` but forget to sync other files, running `./gradlew check` (or just the verify task) will fail with:
```
> Task :verifyVersionConsistency FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':verifyVersionConsistency'.
> Found inconsistent versions in the following files:
committer-tools/kafka-merge-pr.py
tests/kafkatest/version.py
tests/kafkatest/__init__.py
streams/quickstart/pom.xml
streams/quickstart/java/pom.xml
streams/quickstart/java/src/main/resources/archetype-resources/pom.xml
Please run './gradlew updateVersion -PnewVersion=...' to fix them.
```
The output will show the inconsistent files and inform the `updateVersion` task.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2712625545
##########
build.gradle:
##########
@@ -3990,3 +3990,85 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing."
+
+ doLast {
+ def rawVersion = project.version.toString()
+
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ def targets = [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+check.dependsOn updateVersionTask
Review Comment:
I prefer to update those files transactionally, since we always miss something when changing versions ... yes, that includes the kafka version, gradle version, etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #21340:
URL: https://github.com/apache/kafka/pull/21340#issuecomment-3777654605
@clolov @FrankYang0529 WDYT? Does this help make the release process smarter?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2712726275
##########
build.gradle:
##########
@@ -3990,3 +3990,85 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing."
+
+ doLast {
+ def rawVersion = project.version.toString()
+
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ def targets = [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+check.dependsOn updateVersionTask
Review Comment:
sounds good
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #21340:
URL: https://github.com/apache/kafka/pull/21340
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "Parkerhiphop (via GitHub)" <gi...@apache.org>.
Parkerhiphop commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2712999396
##########
build.gradle:
##########
@@ -3990,3 +3990,85 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing."
+
+ doLast {
+ def rawVersion = project.version.toString()
+
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ def targets = [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+check.dependsOn updateVersionTask
Review Comment:
Thanks @FrankYang0529 for suggestion. It really simplifies the process.
I've implemented the `-PnewVersion` logic and updated the PR description with the new usage and verification steps.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2718115640
##########
build.gradle:
##########
@@ -3990,3 +3990,103 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
Review Comment:
How to encourage release manager to use this task?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2736114059
##########
build.gradle:
##########
@@ -3990,3 +3990,146 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+
+// Helper to get version targets and expected patterns
+ext.getVersionTargets = { rawVersion ->
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ return [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+}
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing. Use -PnewVersion=X.Y.Z to set a new version."
+
+ doLast {
+ def rawVersion
+ if (project.hasProperty('newVersion')) {
+ rawVersion = newVersion
+ if (!rawVersion.matches(/^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?$/)) {
+ throw new GradleException("Invalid version format: '${rawVersion}'. Expected format: X.Y.Z or X.Y.Z-SNAPSHOT")
+ }
+ // Update gradle.properties
+ def gradlePropsFile = file("${project.rootDir}/gradle.properties")
+ if (gradlePropsFile.exists()) {
+ def propsContent = gradlePropsFile.text
+ def newPropsContent = propsContent.replaceAll(/(?m)^version\s*=.*/, "version=${rawVersion}")
+ if (propsContent != newPropsContent) {
+ gradlePropsFile.text = newPropsContent
+ println "Updated gradle.properties to version ${rawVersion}"
+ }
+ }
+ } else {
+ rawVersion = project.version.toString()
+ }
+
+ def targets = getVersionTargets(rawVersion)
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+def verifyVersionConsistencyTask = tasks.register('verifyVersionConsistency') {
+ group = "Verification"
+ description = "Verifies that python, pom, and script versions match gradle.properties."
+
+ doLast {
+ def rawVersion = project.version.toString()
+ def targets = getVersionTargets(rawVersion)
+ def inconsistentFiles = []
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check if regex matches current content "as is"
+ // Note: We need to see if the file content *already* matches what we want it to be.
+ // One way is to simulate the replacement and see if it changes nothing.
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ inconsistentFiles.add(item.path)
+ }
+ }
+
+ if (!inconsistentFiles.isEmpty()) {
+ throw new GradleException("Found inconsistent versions in the following files:\n" +
+ inconsistentFiles.join("\n") +
+ "\n\nPlease run './gradlew updateVersion -Pversion=...' to fix them.")
Review Comment:
`-Pversion` -> `-PnewVersion`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "Parkerhiphop (via GitHub)" <gi...@apache.org>.
Parkerhiphop commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2712999396
##########
build.gradle:
##########
@@ -3990,3 +3990,85 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing."
+
+ doLast {
+ def rawVersion = project.version.toString()
+
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ def targets = [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+check.dependsOn updateVersionTask
Review Comment:
Thanks @FrankYang0529 for suggestion. It really simplifies the process.
I've implemented the `newVersion` logic and updated the PR description with the new usage and verification steps.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "Parkerhiphop (via GitHub)" <gi...@apache.org>.
Parkerhiphop commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2725544427
##########
build.gradle:
##########
@@ -3990,3 +3990,103 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
Review Comment:
I've addressed this by hooking a `verifyVersionConsistency` task into the `check` lifecycle.
This ensures that if the RM misses a file, the build will fail and guide them to use the new `updateVersion` task to fix it automatically.
What do you think of this approach?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2712594527
##########
build.gradle:
##########
@@ -3990,3 +3990,85 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing."
+
+ doLast {
+ def rawVersion = project.version.toString()
+
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ def targets = [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+check.dependsOn updateVersionTask
Review Comment:
With this change, any developer or CI agent running `./gradlew check` will have their local source files silently modified if the version is out of sync. Will this surprise user? How about we remove the `dependsOn` and add comments to `gradle.properties` to ask release manager run `./gradlew updateVersion` explicitly? Or refactor this as `verifyVersionSync` and run it during `check`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2712678387
##########
build.gradle:
##########
@@ -3990,3 +3990,85 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing."
+
+ doLast {
+ def rawVersion = project.version.toString()
+
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ def targets = [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+check.dependsOn updateVersionTask
Review Comment:
How about using `updateVersion` to update all files including `gradle.properties`? Like `./gradlew updateVersion -PnewVersion="4.3.0-SNAPSHOT"`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "Parkerhiphop (via GitHub)" <gi...@apache.org>.
Parkerhiphop commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2725998653
##########
build.gradle:
##########
@@ -3990,3 +3990,103 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
Review Comment:
Sure! I've updated the PR description with the details, but here is the output when inconsistencies are detected.
For example, if I manually update `gradle.properties` but forget to sync other files, running `./gradlew check` (or just the verify task) will fail with:
```
> Task :verifyVersionConsistency FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':verifyVersionConsistency'.
> Found inconsistent versions in the following files:
committer-tools/kafka-merge-pr.py
tests/kafkatest/version.py
tests/kafkatest/__init__.py
streams/quickstart/pom.xml
streams/quickstart/java/pom.xml
streams/quickstart/java/src/main/resources/archetype-resources/pom.xml
Please run './gradlew updateVersion -PnewVersion=...' to fix them.
```
The output will show the inconsistent files and inform the `updateVersion` task.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2725657989
##########
build.gradle:
##########
@@ -3990,3 +3990,103 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+def updateVersionTask = tasks.register('updateVersion') {
Review Comment:
sounds good. Could you share the output when the versions are inconsistent?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2727743974
##########
gradle.properties:
##########
@@ -14,14 +14,7 @@
# limitations under the License.
group=org.apache.kafka
-# NOTE: When you change this version number, you should also make sure to update
-# the version numbers in
-# - tests/kafkatest/__init__.py
-# - tests/kafkatest/version.py (variable DEV_VERSION)
-# - kafka-merge-pr.py
-# - streams/quickstart/pom.xml
-# - streams/quickstart/java/src/main/resources/archetype-resources/pom.xml
-# - streams/quickstart/java/pom.xml
+
Review Comment:
Could you remove this empty line?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "Parkerhiphop (via GitHub)" <gi...@apache.org>.
Parkerhiphop commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2736103114
##########
gradle.properties:
##########
@@ -14,14 +14,7 @@
# limitations under the License.
group=org.apache.kafka
-# NOTE: When you change this version number, you should also make sure to update
-# the version numbers in
-# - tests/kafkatest/__init__.py
-# - tests/kafkatest/version.py (variable DEV_VERSION)
-# - kafka-merge-pr.py
-# - streams/quickstart/pom.xml
-# - streams/quickstart/java/src/main/resources/archetype-resources/pom.xml
-# - streams/quickstart/java/pom.xml
+
Review Comment:
Sorry for missing this. I've removed it!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20085: Replace verbose version instructions with updateVersion task [kafka]
Posted by "Parkerhiphop (via GitHub)" <gi...@apache.org>.
Parkerhiphop commented on code in PR #21340:
URL: https://github.com/apache/kafka/pull/21340#discussion_r2736125730
##########
build.gradle:
##########
@@ -3990,3 +3990,146 @@ task aggregatedJavadoc(type: Javadoc, dependsOn: compileJava) {
includes = projectsWithJavadoc.collectMany { it.javadoc.getIncludes() }
excludes = projectsWithJavadoc.collectMany { it.javadoc.getExcludes() }
}
+
+
+
+// Helper to get version targets and expected patterns
+ext.getVersionTargets = { rawVersion ->
+ // Python Package Version (PEP 440): 4.3.0.dev0
+ def pythonVersion = rawVersion.contains("SNAPSHOT") ?
+ rawVersion.replace("-SNAPSHOT", ".dev0") :
+ rawVersion
+
+ def baseVersion = rawVersion.replace("-SNAPSHOT", "")
+
+ return [
+ // 1. kafka-merge-pr.py
+ [
+ path: "committer-tools/kafka-merge-pr.py",
+ // Regex: match DEFAULT_FIX_VERSION = os.environ.get("DEFAULT_FIX_VERSION", "...")
+ pattern: /DEFAULT_FIX_VERSION\s*=\s*os\.environ\.get\("DEFAULT_FIX_VERSION",\s*".*?"\)/,
+ replace: "DEFAULT_FIX_VERSION = os.environ.get(\"DEFAULT_FIX_VERSION\", \"${baseVersion}\")"
+ ],
+ // 2. version.py
+ [
+ path: "tests/kafkatest/version.py",
+ pattern: /DEV_VERSION\s*=\s*KafkaVersion\(".*"\)/,
+ replace: "DEV_VERSION = KafkaVersion(\"${rawVersion}\")"
+ ],
+ // 3. __init__.py
+ [
+ path: "tests/kafkatest/__init__.py",
+ pattern: /__version__\s*=\s*'.*'/,
+ replace: "__version__ = '${pythonVersion}'"
+ ],
+ // 4. Maven POMs
+ [
+ path: "streams/quickstart/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/pom.xml",
+ pattern: /(?s)(<artifactId>streams-quickstart<\/artifactId>.*?<version>)([^<]+)(<\/version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ],
+ [
+ path: "streams/quickstart/java/src/main/resources/archetype-resources/pom.xml",
+ pattern: /(<kafka\.version>)([^<]+)(<\/kafka\.version>)/,
+ replace: { "\$1${rawVersion}\$3" }
+ ]
+ ]
+}
+
+def updateVersionTask = tasks.register('updateVersion') {
+ group = "Release"
+ description = "Syncs python, pom, and script versions with gradle.properties. Fails if files or patterns are missing. Use -PnewVersion=X.Y.Z to set a new version."
+
+ doLast {
+ def rawVersion
+ if (project.hasProperty('newVersion')) {
+ rawVersion = newVersion
+ if (!rawVersion.matches(/^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?$/)) {
+ throw new GradleException("Invalid version format: '${rawVersion}'. Expected format: X.Y.Z or X.Y.Z-SNAPSHOT")
+ }
+ // Update gradle.properties
+ def gradlePropsFile = file("${project.rootDir}/gradle.properties")
+ if (gradlePropsFile.exists()) {
+ def propsContent = gradlePropsFile.text
+ def newPropsContent = propsContent.replaceAll(/(?m)^version\s*=.*/, "version=${rawVersion}")
+ if (propsContent != newPropsContent) {
+ gradlePropsFile.text = newPropsContent
+ println "Updated gradle.properties to version ${rawVersion}"
+ }
+ }
+ } else {
+ rawVersion = project.version.toString()
+ }
+
+ def targets = getVersionTargets(rawVersion)
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+
+ // Check 1: file must exist
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check 2: regex must match
+ def matcher = (content =~ item.pattern)
+ if (!matcher.find()) {
+ throw new GradleException("Pattern not found in ${item.path}.\nExpected pattern: ${item.pattern}")
+ }
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ f.text = newContent
+ println "Updated ${item.path}"
+ }
+ }
+ }
+}
+
+def verifyVersionConsistencyTask = tasks.register('verifyVersionConsistency') {
+ group = "Verification"
+ description = "Verifies that python, pom, and script versions match gradle.properties."
+
+ doLast {
+ def rawVersion = project.version.toString()
+ def targets = getVersionTargets(rawVersion)
+ def inconsistentFiles = []
+
+ targets.each { item ->
+ def f = file("${project.rootDir}/${item.path}")
+ if (!f.exists()) {
+ throw new GradleException("File not found: ${item.path}")
+ }
+
+ def content = f.text
+ // Check if regex matches current content "as is"
+ // Note: We need to see if the file content *already* matches what we want it to be.
+ // One way is to simulate the replacement and see if it changes nothing.
+
+ def replacementStr = item.replace instanceof Closure ? item.replace.call() : item.replace
+ def newContent = content.replaceAll(item.pattern, replacementStr)
+
+ if (content != newContent) {
+ inconsistentFiles.add(item.path)
+ }
+ }
+
+ if (!inconsistentFiles.isEmpty()) {
+ throw new GradleException("Found inconsistent versions in the following files:\n" +
+ inconsistentFiles.join("\n") +
+ "\n\nPlease run './gradlew updateVersion -Pversion=...' to fix them.")
Review Comment:
Fix!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org