This is an automated email from the ASF dual-hosted git repository.
janhoy pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new dc43239 Dynamically discover lucene version for use in build (#501)
dc43239 is described below
commit dc432390651cbce8e009504456c72367dfc1ac20
Author: Jan Høydahl <[email protected]>
AuthorDate: Wed Jan 12 21:38:39 2022 +0100
Dynamically discover lucene version for use in build (#501)
Co-authored-by: Uwe Schindler <[email protected]>
(cherry picked from commit 9e96dc3b83b2a62f1c2424e81c0fdec8a423e921)
---
build.gradle | 15 ++++++++++---
dev-tools/scripts/addVersion.py | 25 +++++++++-------------
dev-tools/scripts/scriptutil.py | 3 +--
gradle/lucene-dev/lucene-dev-repo-composite.gradle | 15 +++++++++++++
gradle/testing/randomization.gradle | 13 ++++++++---
gradle/validation/solr.config-file-sanity.gradle | 6 ++----
.../solr/configsets/_default/conf/solrconfig.xml | 2 +-
.../conf/solrconfig.xml | 2 +-
8 files changed, 52 insertions(+), 29 deletions(-)
diff --git a/build.gradle b/build.gradle
index bb513fc..2137d4b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -46,7 +46,7 @@ version = {
String versionSuffix = propertyOrDefault('version.suffix', 'SNAPSHOT')
return propertyOrDefault('version.release',
"${baseVersion}-${versionSuffix}")
}()
-description = 'Grandparent project for Apache Lucene Core and Apache Solr'
+description = 'Grandparent project for Apache Solr'
// Propagate version and derived properties across projects.
allprojects {
@@ -81,8 +81,6 @@ ext {
minJavaVersion = JavaVersion.VERSION_11
- luceneBaseVersion = '9.0.0' // TODO: Use
org.apache.lucene.util.Version.LATEST.toString()
-
// Declare script dependency versions outside of palantir's
// version unification control. These are not our main dependencies.
scriptDepVersions = [
@@ -101,6 +99,17 @@ ext {
logger.info("External tool '${name}' resolved to: ${resolved}")
return resolved
}
+
+ luceneBaseVersionProvider = project.provider {
+ def luceneVersion = getVersion('org.apache.lucene:lucene-core')
+ def m = (luceneVersion =~ /^\d+\.\d+\.\d+\b/)
+ if (!m) {
+ throw GradleException("Can't strip base version from " + luceneVersion)
+ }
+ def luceneBaseVersion = m[0]
+ logger.debug('Lucene base version (without suffix): {}', luceneBaseVersion)
+ return luceneBaseVersion
+ }
}
// Include smaller chunks configuring dedicated build areas.
diff --git a/dev-tools/scripts/addVersion.py b/dev-tools/scripts/addVersion.py
index 2b11f3a..a3d955d 100755
--- a/dev-tools/scripts/addVersion.py
+++ b/dev-tools/scripts/addVersion.py
@@ -75,7 +75,7 @@ def onerror(x):
raise x
def update_example_solrconfigs(new_version):
- print(' updating example solrconfig.xml files with version %s' %
new_version)
+ print(' updating example solrconfig.xml files with lucene version %s' %
new_version)
matcher = re.compile('<luceneMatchVersion>(.*?)</luceneMatchVersion>')
paths = ['solr/server/solr/configsets', 'solr/example']
@@ -91,12 +91,12 @@ def update_example_solrconfigs(new_version):
def update_solrconfig(filename, matcher, new_version):
print(' %s...' % filename, end='', flush=True)
def edit(buffer, match, line):
- if new_version.dot in line:
+ if new_version in line:
return None
match = matcher.search(line)
if match is None:
return False
- buffer.append(line.replace(match.group(1), new_version.dot))
+ buffer.append(line.replace(match.group(1), new_version))
return True
changed = update_file(filename, matcher, edit)
@@ -150,27 +150,22 @@ def main():
is_bugfix = newconf.version.is_bugfix_release()
print('\nAdding new version %s' % newconf.version)
- # See LUCENE-8883 for some thoughts on which categories to use
update_changes('solr/CHANGES.txt', newconf.version, get_solr_init_changes(),
['Bug Fixes'] if is_bugfix else ['New Features',
'Improvements', 'Optimizations', 'Bug Fixes', 'Other Changes'])
- latest_or_backcompat = newconf.is_latest_version or
current_version.is_back_compat_with(newconf.version)
- if latest_or_backcompat:
- update_solrversion_class(newconf.version)
- else:
- print('\nNot adding constant for version %s because it is no longer
supported' % newconf.version)
-
if newconf.is_latest_version:
- print('\nUpdating latest version')
+ print('\nAdded version is latest version, updating...')
update_build_version(newconf.version)
- update_example_solrconfigs(newconf.lucene_version)
+ update_solrversion_class(newconf.version)
+ if newconf.version.is_major_release or newconf.version.is_minor_release():
+ # Update solrconfig.xml with new
<luceneMatchVersion>major.minor</luceneMatchVersion> for major/minor releases
+ update_example_solrconfigs("%d.%d" % (newconf.lucene_version.major,
newconf.lucene_version.minor))
- if newconf.version.is_major_release():
- print('\nNo tests to run for major release')
- elif latest_or_backcompat:
print('\nTesting changes')
check_solr_version_class_tests()
check_lucene_match_version_tests()
+ else:
+ print('\nNot updating build.gradle, SolrVersion or solrconfig.xml since
version added is not latest version' % newconf.version)
print()
diff --git a/dev-tools/scripts/scriptutil.py b/dev-tools/scripts/scriptutil.py
index 9866767..93d062f 100644
--- a/dev-tools/scripts/scriptutil.py
+++ b/dev-tools/scripts/scriptutil.py
@@ -130,8 +130,7 @@ def find_branch_type():
return BranchType.stable
if re.match(r'branch_(\d+)_(\d+)', branchName.decode('UTF-8')):
return BranchType.release
- return BranchType.release
- # raise Exception('Cannot run %s on feature branch' %
sys.argv[0].rsplit('/', 1)[-1])
+ raise Exception('Cannot run %s on feature branch' % sys.argv[0].rsplit('/',
1)[-1])
def download(name, urlString, tmpDir, quiet=False, force_clean=True):
diff --git a/gradle/lucene-dev/lucene-dev-repo-composite.gradle
b/gradle/lucene-dev/lucene-dev-repo-composite.gradle
index 0ad6ee8..9d23c73 100644
--- a/gradle/lucene-dev/lucene-dev-repo-composite.gradle
+++ b/gradle/lucene-dev/lucene-dev-repo-composite.gradle
@@ -130,6 +130,21 @@ if (luceneDevRepo != null) {
} else {
// We're being applied at build-time and Lucene development repository
exists. Configure
// certain aspects of the build so that things work with it.
+
+ // replace luceneBaseVersionProvider by one evaluating the included build:
+ configure(rootProject) {
+ def line = new File(gradle.includedBuild('lucene').projectDir,
'build.gradle').readLines("UTF-8").find { it =~ /\bbaseVersion\s*=\s*['"]/ }
+ if (!line) {
+ throw new GradleException('Cannot extract Lucene baseVersion from
build.gradle file.')
+ }
+ def luceneBaseVersion = evaluate(line)
+
+ logger.lifecycle("Local Lucene development repository will override
luceneBaseVersion with: {}", luceneBaseVersion)
+
+ ext {
+ luceneBaseVersionProvider = provider { luceneBaseVersion }
+ }
+ }
// Security policy requires read access to the repo path.
allprojects {
diff --git a/gradle/testing/randomization.gradle
b/gradle/testing/randomization.gradle
index 2ad4ed4..295b656 100644
--- a/gradle/testing/randomization.gradle
+++ b/gradle/testing/randomization.gradle
@@ -99,7 +99,6 @@ allprojects {
// test data
[propName: 'tests.linedocsfile', value: 'europarl.lines.txt.gz',
description: "Test data file path."],
// miscellaneous; some of them very weird.
- [propName: 'tests.LUCENE_VERSION', value: luceneBaseVersion,
description: "Base Lucene version."],
[propName: 'tests.bwcdir', value: null, description: "Data for
backward-compatibility indexes."],
]
}
@@ -111,7 +110,6 @@ configure(allprojects.findAll {project ->
project.path.startsWith(":solr") }) {
plugins.withType(JavaPlugin) {
ext {
testOptions += [
- [propName: 'tests.luceneMatchVersion', value: luceneBaseVersion,
description: "Base Lucene version."],
[propName: 'common-solr.dir',
value: project(":solr").projectDir,
description: "Solr base dir.",
@@ -179,7 +177,16 @@ allprojects {
if (Boolean.parseBoolean(testOptionsResolved["tests.failfast"])) {
failFast true
}
-
+
+ // The Lucene version is only available after resolving was done, so
add lately using a provider:
+ jvmArgumentProviders.add({
+ def luceneMatchVersion = rootProject.luceneBaseVersionProvider.get()
+ return [
+ "-Dtests.LUCENE_VERSION=${luceneMatchVersion}",
+ "-Dtests.luceneMatchVersion=${luceneMatchVersion}",
+ ]
+ } as CommandLineArgumentProvider)
+
// Enable security manager, if requested. We could move the selection
of security manager and security policy
// to each project's build/ configuration but it seems compact enough
to keep it here for now.
if
(Boolean.parseBoolean(testOptionsResolved["tests.useSecurityManager"])) {
diff --git a/gradle/validation/solr.config-file-sanity.gradle
b/gradle/validation/solr.config-file-sanity.gradle
index 30f6391..3b50843 100644
--- a/gradle/validation/solr.config-file-sanity.gradle
+++ b/gradle/validation/solr.config-file-sanity.gradle
@@ -20,10 +20,8 @@
configure(project(":solr")) {
task validateConfigFileSanity() {
doFirst {
- def matchVersion =
project(":solr:core").resolvedTestOption('tests.luceneMatchVersion')
- if (!matchVersion) {
- throw new GradleException("tests.luceneMatchVersion not defined?")
- }
+ def (major, minor) =
rootProject.luceneBaseVersionProvider.get().tokenize('.')
+ def matchVersion = "${major}.${minor}"
// Verify solrconfig.xml files declare proper luceneMatchVersion.
[
diff --git a/solr/server/solr/configsets/_default/conf/solrconfig.xml
b/solr/server/solr/configsets/_default/conf/solrconfig.xml
index 0ae25bd..ce19152 100644
--- a/solr/server/solr/configsets/_default/conf/solrconfig.xml
+++ b/solr/server/solr/configsets/_default/conf/solrconfig.xml
@@ -35,7 +35,7 @@
that you fully re-index after changing this setting as it can
affect both how text is indexed and queried.
-->
- <luceneMatchVersion>9.0.0</luceneMatchVersion>
+ <luceneMatchVersion>9.0</luceneMatchVersion>
<!-- <lib/> directives can be used to instruct Solr to load any Jars
identified and use them to resolve any "plugins" specified in
diff --git
a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
index 0985150..7bbed36 100644
---
a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
+++
b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml
@@ -35,7 +35,7 @@
that you fully re-index after changing this setting as it can
affect both how text is indexed and queried.
-->
- <luceneMatchVersion>9.0.0</luceneMatchVersion>
+ <luceneMatchVersion>9.0</luceneMatchVersion>
<!-- <lib/> directives can be used to instruct Solr to load any Jars
identified and use them to resolve any "plugins" specified in