Apache Solr open-source search software
Dynamically discover lucene version for use in build (#501)
Jan Høydahl9e96dc3b83b2
diff --git a/build.gradle b/build.gradleindex 490c2f9c6f5..6e7c3691104 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.pyindex 2b11f3a9ead..a3d955d0c77 100755--- a/dev-tools/scripts/addVersion.py+++ b/dev-tools/scripts/addVersion.py@@ -75,7 +75,7 @@ def onerror(x):raise xdef 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 Nonematch = 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 Truechanged = 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 useupdate_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.pyindex 98667678fd9..93d062f8202 100644--- a/dev-tools/scripts/scriptutil.py+++ b/dev-tools/scripts/scriptutil.py@@ -130,8 +130,7 @@ def find_branch_type():return BranchType.stableif 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.gradleindex 0ad6ee8d79e..9d23c731c46 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.gradleindex 2ad4ed41a8c..295b656403a 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.gradleindex 30f63910043..3b50843afeb 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.xmlindex 0ae25bd3ec8..ce191525607 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 canaffect 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 Jarsidentified and use them to resolve any "plugins" specified indiff --git a/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xml b/solr/server/solr/configsets/sample_techproducts_configs/conf/solrconfig.xmlindex 0985150568c..7bbed362b53 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 canaffect 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 Jarsidentified and use them to resolve any "plugins" specified in