Skip to content

Commit 1d527a7

Browse files
authored
#477 Build with all Java 8+ LTS versions (#487)
* Add matrix build for Java LTS versions above Java 8 * Specify permissions to GHA files
1 parent d4d5b5d commit 1d527a7

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

.github/workflows/maven_jdk11.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/maven_jdk8.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
name: Java 8 build
44
on: [push, pull_request]
5+
permissions:
6+
contents: read
57

68
jobs:
79
build:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Secondary build that builds the project with JDK 11+. Note that the target in the pom.xml is still Java 8.
2+
3+
name: Maven build
4+
on: [push, pull_request]
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
# Java 8 has its own file so we can do other stuff like Coveralls
14+
java: ['11', '17', '21']
15+
name: Java ${{ matrix.java }} build
16+
17+
steps:
18+
- uses: actions/checkout@v5
19+
- name: Set up Java
20+
uses: actions/setup-java@v5
21+
with:
22+
java-version: ${{ matrix.java }}
23+
distribution: 'adopt'
24+
- name: Build with Maven
25+
run: mvn -B --file pom.xml package

src/test/java/ch/jalu/configme/properties/types/NumberTypeTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ch.jalu.configme.properties.convertresult.ConvertErrorRecorder;
44
import ch.jalu.typeresolver.TypeInfo;
55
import ch.jalu.typeresolver.numbers.StandardNumberType;
6+
import org.hamcrest.Matchers;
67
import org.junit.jupiter.api.Test;
78
import org.junit.jupiter.api.extension.ExtendWith;
89
import org.junit.jupiter.params.ParameterizedTest;
@@ -236,7 +237,9 @@ void shouldConvertToBigDecimalsWithoutLossOfPrecision() {
236237
// when / then
237238
assertThat(NumberType.BIG_DECIMAL.convert(longImpreciseAsDouble, bigDecimalType, errorRecorder), equalTo(new BigDecimal("5076541234567890123")));
238239
assertThat(NumberType.BIG_DECIMAL.convert(2e50, bigDecimalType, errorRecorder), equalTo(new BigDecimal("2.0E+50")));
239-
assertThat(NumberType.BIG_DECIMAL.convert(-1e18f, bigDecimalType, errorRecorder), equalTo(new BigDecimal("-9.9999998430674944E+17")));
240+
assertThat(NumberType.BIG_DECIMAL.convert(-1e18f, bigDecimalType, errorRecorder),
241+
Matchers.<Object>either(equalTo(new BigDecimal("-9.9999998430674944E+17")))
242+
.or(equalTo(new BigDecimal("-9.999999843067494E+17")))); // #347: JDK21 has different Double#toString impl.
240243
assertThat(NumberType.BIG_DECIMAL.convert("88223372036854775807.999", bigDecimalType, errorRecorder), equalTo(new BigDecimal("88223372036854775807.999")));
241244
assertThat(NumberType.BIG_DECIMAL.convert(largeBigDecimal, bigDecimalType, errorRecorder), equalTo(largeBigDecimal));
242245
verifyNoInteractions(errorRecorder);

src/test/java/ch/jalu/configme/utils/FileUtilsTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import static org.mockito.ArgumentMatchers.anySet;
2727
import static org.mockito.ArgumentMatchers.eq;
2828
import static org.mockito.BDDMockito.given;
29-
import static org.mockito.Mockito.doThrow;
29+
import static org.mockito.Mockito.lenient;
3030
import static org.mockito.Mockito.mock;
3131

3232
/**
@@ -88,7 +88,8 @@ void shouldThrowIfFileCannotBeCreated() throws IOException {
8888
given(fileSystem.provider()).willReturn(provider);
8989
Path child = mock(Path.class);
9090
given(child.getFileSystem()).willReturn(fileSystem);
91-
doThrow(NoSuchFileException.class).when(provider).checkAccess(child); // for Files#exists
91+
// #347: JDK21 does not call checkAccess anymore
92+
lenient().doThrow(NoSuchFileException.class).when(provider).checkAccess(child); // for Files#exists
9293
IOException ioException = new IOException("File creation not supported");
9394
given(provider.newByteChannel(eq(child), anySet(), any(FileAttribute[].class))).willThrow(ioException);
9495

0 commit comments

Comments
 (0)