File tree Expand file tree Collapse file tree 3 files changed +55
-3
lines changed
metamodel/metamodel-processor
src/main/java/org/hibernate/search/processor Expand file tree Collapse file tree 3 files changed +55
-3
lines changed Original file line number Diff line number Diff line change 9191 <artifactId >maven-surefire-plugin</artifactId >
9292 <configuration >
9393 <systemPropertyVariables >
94- <org .hibernate.search.integrationtest.backend.elasticsearch.version>${version.org.elasticsearch.client } </org .hibernate.search.integrationtest.backend.elasticsearch.version>
94+ <org .hibernate.search.integrationtest.backend.elasticsearch.version>${version.org.elasticsearch.latest } </org .hibernate.search.integrationtest.backend.elasticsearch.version>
9595 </systemPropertyVariables >
9696 </configuration >
9797 </plugin >
98+ <plugin >
99+ <groupId >org.jboss.maven.plugins</groupId >
100+ <artifactId >maven-injection-plugin</artifactId >
101+ <configuration >
102+ <bytecodeInjections >
103+ <bytecodeInjection >
104+ <expression >${version.org.elasticsearch.latest} </expression >
105+ <targetMembers >
106+ <methodBodyReturn >
107+ <className >org.hibernate.search.processor.util.impl.DefaultBackendVersionUtils</className >
108+ <methodName >latestElasticsearchVersion</methodName >
109+ </methodBodyReturn >
110+ </targetMembers >
111+ </bytecodeInjection >
112+ </bytecodeInjections >
113+ </configuration >
114+ </plugin >
98115 </plugins >
99116 </build >
100117 <profiles >
Original file line number Diff line number Diff line change 55package org .hibernate .search .processor ;
66
77
8+ import static org .hibernate .search .processor .util .impl .DefaultBackendVersionUtils .latestElasticsearchVersion ;
9+ import static org .hibernate .search .processor .util .impl .DefaultBackendVersionUtils .latestLuceneVersion ;
10+
811import java .io .Serializable ;
912import java .time .Clock ;
1013import java .time .LocalDateTime ;
@@ -80,11 +83,11 @@ public String formattedGeneratedAnnotation() {
8083 }
8184
8285 public String elasticsearchVersion () {
83- return version == null ? "9.0.1" : version ;
86+ return version == null ? latestElasticsearchVersion () : version ;
8487 }
8588
8689 public String luceneVersion () {
87- return version == null ? "9.12.1" : version ;
90+ return version == null ? latestLuceneVersion () : version ;
8891 }
8992
9093 public String backendVersion () {
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .search .processor .util .impl ;
6+
7+ import java .lang .reflect .Field ;
8+
9+ public final class DefaultBackendVersionUtils {
10+ private DefaultBackendVersionUtils () {
11+ }
12+
13+ public static String latestElasticsearchVersion () {
14+ // This implementation is replaced during the build with another one that returns the correct value:
15+ return "UNKNOWN" ;
16+ }
17+
18+ public static String latestLuceneVersion () {
19+ // since this one depends on which backend we pass to the processor ...
20+ try {
21+ Class <?> luceneVersionClass = Class .forName ( "org.apache.lucene.util.Version" );
22+ Field latestField = luceneVersionClass .getField ( "LATEST" );
23+
24+ Object latestVersion = latestField .get ( null );
25+
26+ return latestVersion .toString ();
27+ }
28+ catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e ) {
29+ return null ;
30+ }
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments