Skip to content

Commit

Permalink
Merge pull request #5376 from dizzzz/feature/make_build_java18compatible
Browse files Browse the repository at this point in the history
[bugfix] Make build compatible with Java18 and beyond.
  • Loading branch information
reinhapa authored Aug 1, 2024
2 parents 56d93bf + 394e4aa commit dbab993
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 32 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
jvm: ['17', '21']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.DEV_JDK }}
java-version: ${{ matrix.jvm }}
cache: 'maven'
- name: Install Maven Daemon
id: install-mvnd
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-build-logs
name: ${{ runner.os }}-${{ matrix.jvm }}-build-logs
retention-days: 5
path: |
**/*.jfr
Expand Down
4 changes: 2 additions & 2 deletions exist-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,9 @@ The BaseX Team. The original license statement is also included below.]]></pream
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>org.omnifaces</groupId>
<artifactId>antlr-maven-plugin</artifactId>
<version>2.2</version>
<version>2.3</version>
<configuration>
<grammars>
org/exist/xquery/parser/XQuery.g,org/exist/xquery/parser/XQueryTree.g,org/exist/xquery/parser/DeclScanner.g,org/exist/xquery/xqdoc/parser/XQDocParser.g
Expand Down
35 changes: 31 additions & 4 deletions extensions/indexes/range/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.exist-db</groupId>
<artifactId>exist-parent</artifactId>
Expand All @@ -42,8 +42,8 @@
<connection>scm:git:https://github.com/exist-db/exist.git</connection>
<developerConnection>scm:git:https://github.com/exist-db/exist.git</developerConnection>
<url>scm:git:https://github.com/exist-db/exist.git</url>
<tag>HEAD</tag>
</scm>
<tag>HEAD</tag>
</scm>

<dependencies>
<dependency>
Expand All @@ -67,7 +67,7 @@
<artifactId>lucene-core</artifactId>
<version>${lucene.version}</version>
</dependency>

<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
Expand Down Expand Up @@ -113,6 +113,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.github.hakky54</groupId>
<artifactId>logcaptor</artifactId>
<version>2.9.3</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand All @@ -128,6 +135,26 @@
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j-impl</classpathDependencyExclude>
<classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j2-impl</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j-impl</classpathDependencyExclude>
<classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j2-impl</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,23 @@
*/
package org.exist.indexing.range;

import nl.altindag.log.LogCaptor;
import org.apache.logging.log4j.Logger;
import org.easymock.Capture;
import org.exist.util.JDKCompatibility;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;

import static junit.framework.TestCase.assertTrue;
import static org.easymock.EasyMock.*;
import static org.exist.collections.CollectionConfiguration.DEFAULT_COLLECTION_CONFIG_FILE;
import static org.exist.indexing.lucene.LuceneIndexConfig.MATCH_ATTR;
import static org.exist.indexing.lucene.LuceneIndexConfig.QNAME_ATTR;
import static org.junit.Assert.assertTrue;

public class RangeIndexConfigTest {

Expand Down Expand Up @@ -88,30 +86,20 @@ public void errorsHaveSourceContext() throws NoSuchFieldException, IllegalAccess
replay(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList, mockLogger);



final Map<String, String> namespaces = new HashMap<>();
namespaces.put("tei", "http://www.tei-c.org/ns/1.0");

overrideLogger(RangeIndexConfig.class, mockLogger);
final RangeIndexConfig config = new RangeIndexConfig(mockConfigNodes, namespaces);

assertTrue(errorMsgCapture.getValue().contains("Illegal QName: '" + badCreateQName + "'.. QName is invalid: INVALID_LOCAL_PART"));
assertTrue(errorMsgCapture.getValue().contains("(" + mockCollectionXConfUri + ")"));
LogCaptor logCaptor = LogCaptor.forClass(RangeIndexConfig.class);

verify(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList, mockLogger);
}

private void overrideLogger(final Class clazz, final Logger logger) throws NoSuchFieldException, IllegalAccessException {
final Field loggerField = clazz.getDeclaredField("LOG");
final RangeIndexConfig config = new RangeIndexConfig(mockConfigNodes, namespaces);

// allow access to private field
loggerField.setAccessible(true);
assertTrue(logCaptor.getLogs().get(0)
.contains("Illegal QName: '" + badCreateQName + "'.. QName is invalid: INVALID_LOCAL_PART"));

// remove final modifier
final Field modifiersField = JDKCompatibility.getModifiersField();
modifiersField.setAccessible(true);
modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL);
assertTrue(logCaptor.getLogs().get(0)
.contains("(" + mockCollectionXConfUri + ")"));

loggerField.set(null, logger);
verify(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList);
}

}
4 changes: 2 additions & 2 deletions extensions/modules/simpleql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>org.omnifaces</groupId>
<artifactId>antlr-maven-plugin</artifactId>
<version>2.2</version>
<version>2.3</version>
<configuration>
<grammars>org/exist/xquery/modules/simpleql/SimpleQLParser.g</grammars>
</configuration>
Expand Down

0 comments on commit dbab993

Please sign in to comment.