Skip to content

Commit 35f9ca2

Browse files
authored
Correct python release scripts for the new location of base version (#14798)
* Correct python release scripts for the new location of base version #14786 * Apply reformat. * Remove test line. * Revert back to plain regexp. * Add build-options.properties to top-level files. Correct the code looking for expected strings in the manifest; jdk 24 doesn't have a not after the java.version property. * Autoformat actually broke the linter here (types). Corrected.
1 parent f305314 commit 35f9ca2

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ gradle/wrapper/gradle-wrapper.jar
2626
# Python
2727
.pydevproject
2828
__pycache__
29+
.venv
2930

3031
# Emacs backup
3132
*~

dev-tools/scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
This folder contains various useful scripts for developers, mostly related to
2121
releasing new versions of Lucene and testing those.
2222

23-
Python scripts require Python 3.6 or avobe. To install necessary python modules, please run:
23+
Python scripts require Python 3.6 or above. To install necessary python modules, please run:
2424

2525
pip3 install -r requirements.txt
2626

dev-tools/scripts/addVersion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ def __call__(self, buffer: list[str], _match: re.Match[str], line: str):
104104

105105
def update_build_version(new_version: Version):
106106
print(" changing baseVersion...", end="", flush=True)
107-
filename = "build.gradle"
107+
filename = "build-options.properties"
108108

109109
def edit(buffer: list[str], _match: re.Match[str], line: str):
110110
if new_version.dot in line:
111111
return None
112-
buffer.append(" String baseVersion = '" + new_version.dot + "'\n")
112+
buffer.append("version.base=" + new_version.dot + "\n")
113113
return True
114114

115-
version_prop_re = re.compile(r'baseVersion\s*=\s*([\'"])(.*)\1')
115+
version_prop_re = re.compile(r"version\.base=(.*)")
116116
changed = update_file(filename, version_prop_re, edit)
117117
print("done" if changed else "uptodate")
118118

@@ -164,7 +164,7 @@ def parse_properties_file(filename: str):
164164

165165

166166
def main():
167-
if not os.path.exists("build.gradle"):
167+
if not os.path.exists("build-options.properties"):
168168
sys.exit("Tool must be run from the root of a source checkout.")
169169
current_version = Version.parse(find_current_version())
170170
newconf = read_config(current_version)

dev-tools/scripts/scriptutil.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,13 @@ def attemptDownload(urlString: str, fileName: str):
184184
os.remove(fileName)
185185

186186

187-
version_prop_re = re.compile(r'baseVersion\s*=\s*([\'"])(.*)\1')
188-
189-
190187
def find_current_version():
188+
version_prop_re = re.compile(r"version\.base=(.*)")
191189
script_path = os.path.dirname(os.path.realpath(__file__))
192190
top_level_dir = os.path.join(Path("%s/" % script_path).resolve(), os.path.pardir, os.path.pardir)
193-
match = version_prop_re.search(open("%s/build.gradle" % top_level_dir).read())
191+
match = version_prop_re.search(open("%s/build-options.properties" % top_level_dir).read())
194192
assert match
195-
return match.group(2).strip()
193+
return match.group(1).strip()
196194

197195

198196
if __name__ == "__main__":

dev-tools/scripts/smokeTestRelease.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ def checkJARMetaData(desc: str, jarFile: str, gitRevision: str, version: str):
149149
"X-Compile-Source-JDK: %s" % BASE_JAVA_VERSION,
150150
"X-Compile-Target-JDK: %s" % BASE_JAVA_VERSION,
151151
"Specification-Version: %s" % version,
152-
"X-Build-JDK: %s." % BASE_JAVA_VERSION,
152+
re.compile("X-Build-JDK: %s[. ]" % re.escape(BASE_JAVA_VERSION)),
153153
"Extension-Name: org.apache.lucene",
154154
):
155155
if type(verify) is not tuple:
156156
verify = (verify,)
157157
for x in verify:
158-
if s.find(x) != -1:
158+
if (isinstance(x, re.Pattern) and x.search(s)) or (isinstance(x, str) and s.find(x) != -1):
159159
break
160160
else:
161161
if len(verify) == 1:
@@ -604,7 +604,21 @@ def verifyUnpacked(java: Any, artifact: str, unpackPath: str, gitRevision: str,
604604
"licenses",
605605
]
606606
if isSrc:
607-
expected_src_root_files = ["build.gradle", "build-tools", "CONTRIBUTING.md", "dev-docs", "dev-tools", "gradle", "gradlew", "gradlew.bat", "help", "lucene", "settings.gradle", "versions.lock"]
607+
expected_src_root_files = [
608+
"build.gradle",
609+
"build-options.properties",
610+
"build-tools",
611+
"CONTRIBUTING.md",
612+
"dev-docs",
613+
"dev-tools",
614+
"gradle",
615+
"gradlew",
616+
"gradlew.bat",
617+
"help",
618+
"lucene",
619+
"settings.gradle",
620+
"versions.lock",
621+
]
608622
expected_src_lucene_files = ["build.gradle", "documentation", "distribution", "dev-docs"]
609623
is_in_list(in_root_folder, expected_src_root_files)
610624
is_in_list(in_lucene_folder, expected_folders)

0 commit comments

Comments
 (0)