Skip to content

Apache Lucene open-source search software

Apply stricter checks on maven dependencies to fail if a different Lucene version is imported as transitive dependency

Uwe Schindler652ea275d881
diff --git a/lucene/analysis/build.xml b/lucene/analysis/build.xml
index 27a600934fc..0cf8a0a8bf0 100644
--- a/lucene/analysis/build.xml
+++ b/lucene/analysis/build.xml
@@ -36,7 +36,7 @@
<attribute name="target" />
<sequential>
<subant target="@{target}" inheritall="false" failonerror="true">
- <propertyset refid="uptodate.and.compiled.properties"/>
+ <propertyset refid="uptodate.and.compiled.properties"/>
<fileset dir="${analyzers.dir}" includes="*/build.xml" />
</subant>
</sequential>
@@ -46,6 +46,7 @@
<propertyref regex=".*\.uptodate$$"/>
<propertyref regex=".*\.compiled$$"/>
<propertyref regex=".*\.loaded$$"/>
+ <propertyref name="maven.version.glob"/>
</propertyset>
<target name="common">
diff --git a/lucene/build.xml b/lucene/build.xml
index 71dd7305ad9..bb1c2995355 100644
--- a/lucene/build.xml
+++ b/lucene/build.xml
@@ -483,7 +483,7 @@
</sequential>
</target>
- <target name="-validate-maven-dependencies" depends="compile-tools, install-maven-tasks, load-custom-tasks">
+ <target name="-validate-maven-dependencies" depends="compile-tools, install-maven-tasks, load-custom-tasks, -define-maven-version-glob">
<sequential>
<subant target="-validate-maven-dependencies" failonerror="true" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 215978aba7d..09c0208fcd2 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -246,6 +246,7 @@
<propertyref regex=".*\.uptodate$$"/>
<propertyref regex=".*\.compiled$$"/>
<propertyref regex=".*\.loaded$$"/>
+ <propertyref name="maven.version.glob"/>
<propertyref name="lucene.javadoc.url"/><!-- for Solr -->
</propertyset>
@@ -1349,6 +1350,13 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
</m2-deploy>
</sequential>
</target>
+
+ <target name="-define-maven-version-glob" depends="resolve-groovy" unless="maven.version.glob">
+ <!-- Too stupid, that ANT cannot apply regexes to property values: -->
+ <script language="groovy" classpathref="groovy.classpath"><![CDATA[
+ project.setProperty('maven.version.glob', project.getProperty('version').replaceAll(/\-SNAPSHOT/, '-*'));
+ ]]></script>
+ </target>
<target name="-validate-maven-dependencies">
<property name="top.level.dir" location="${common.dir}/.."/>
@@ -1363,7 +1371,7 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
</pathconvert>
<m2-validate-dependencies pom.xml="${pom.xml}" licenseDirectory="${license.dir}">
<excludes>
- <rsel:name name="**/lucene-*.jar" handledirsep="true"/>
+ <rsel:name name="**/lucene-*-${maven.version.glob}.jar" handledirsep="true"/>
</excludes>
</m2-validate-dependencies>
</target>
diff --git a/solr/build.xml b/solr/build.xml
index cae6595faf6..e6fd3131db8 100644
--- a/solr/build.xml
+++ b/solr/build.xml
@@ -589,7 +589,7 @@
</subant>
</target>
- <target name="-validate-maven-dependencies" depends="compile-tools, install-maven-tasks, load-custom-tasks">
+ <target name="-validate-maven-dependencies" depends="compile-tools, install-maven-tasks, load-custom-tasks, -define-maven-version-glob">
<sequential>
<subant target="-validate-maven-dependencies" failonerror="true" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
diff --git a/solr/common-build.xml b/solr/common-build.xml
index c3062cd90c3..34ab7f6a8d2 100644
--- a/solr/common-build.xml
+++ b/solr/common-build.xml
@@ -325,8 +325,8 @@
</additional-filters>
<excludes>
<rsel:or>
- <rsel:name name="**/lucene-*.jar" handledirsep="true"/>
- <rsel:name name="**/solr-*.jar" handledirsep="true"/>
+ <rsel:name name="**/lucene-*-${maven.version.glob}.jar" handledirsep="true"/>
+ <rsel:name name="**/solr-*-${maven.version.glob}.jar" handledirsep="true"/>
<!-- TODO: figure out what is going on here with servlet-apis -->
<rsel:name name="**/*servlet*.jar" handledirsep="true"/>
</rsel:or>