Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #73 from atoulme/try_upgrading_gradle
Browse files Browse the repository at this point in the history
upgrade to gradle 6.3
  • Loading branch information
atoulme authored Apr 30, 2020
2 parents a34908a + 52f4feb commit 7b2d43f
Show file tree
Hide file tree
Showing 109 changed files with 5,193 additions and 4,342 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/master-pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Install Gradle
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 5.6.2
arguments: setup
- name: Cache Gradle packages
uses: actions/cache@v1
with:
Expand All @@ -55,15 +50,24 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/dependency-versions.gradle') }}
restore-keys: ${{ runner.os }}-m2
- name: gradle checks
run: ./gradlew --no-daemon spotlessCheck checkLicenses
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 6.3
arguments: spotlessCheck checkLicenses
- name: gradle assemble
run: ./gradlew --no-daemon assemble -x test
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 6.3
arguments: assemble -x test
- uses: actions/upload-artifact@v1
with:
name: Libs
path: build/libs
- name: gradle test
run: ./gradlew --no-daemon test
uses: eskatos/gradle-command-action@v1
with:
gradle-version: 6.3
arguments: test
- uses: actions/upload-artifact@v1
with:
name: Reports
Expand Down
15 changes: 7 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import java.util.regex.Pattern
import net.ltgt.gradle.errorprone.CheckSeverity

buildscript {
repositories { jcenter() // jcenter
repositories {
jcenter() // jcenter
}

dependencies { classpath "org.ajoberstar.grgit:grgit-core:3.1.1" }
}

plugins {
id 'com.diffplug.gradle.spotless' version '3.16.0'
id 'com.diffplug.gradle.spotless' version '3.28.1'
id 'net.ltgt.errorprone' version '0.6'
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
id 'com.github.hierynomus.license' version '0.15.0'
Expand Down Expand Up @@ -161,7 +162,7 @@ subprojects {
}
kotlin {
licenseHeaderFile rootProject.file('gradle/spotless.license.txt')
ktlint().userData(['indent_size': '2', 'continuation_indent_size' : '2', 'max_line_length': '120'])
ktlint().userData(['indent_size': '2', 'continuation_indent_size' : '2', 'max_line_length': '120', 'disabled_rules': 'import-ordering'])
endWithNewline()
}
}
Expand Down Expand Up @@ -564,12 +565,10 @@ allprojects {
// Configure root project as a virtual package that depends on all components

dependencies {
subprojects.each { p ->
subprojects.findAll {
!it.name.contains('reference-tests')
}.each { p ->
switch (p.name) {
case 'eth-reference-tests':
case 'eth2-reference-tests':
// ignore
break
case 'crypto':
compile(p) {
exclude group: 'com.github.jnr', module: 'jnr-ffi'
Expand Down
18 changes: 10 additions & 8 deletions bytes/src/main/java/org/apache/tuweni/bytes/BytesValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ static byte[] fromRawHexString(CharSequence str, int destSize, boolean lenient)
int l = hexToBin(hex.charAt(i + 1));
if (h == -1) {
throw new IllegalArgumentException(
String.format(
"Illegal character '%c' found at index %d in hex binary representation",
hex.charAt(i),
i - idxShift));
String
.format(
"Illegal character '%c' found at index %d in hex binary representation",
hex.charAt(i),
i - idxShift));
}
if (l == -1) {
throw new IllegalArgumentException(
String.format(
"Illegal character '%c' found at index %d in hex binary representation",
hex.charAt(i + 1),
i + 1 - idxShift));
String
.format(
"Illegal character '%c' found at index %d in hex binary representation",
hex.charAt(i + 1),
i + 1 - idxShift));
}

out[destOffset + (i / 2)] = (byte) (h * 16 + l);
Expand Down
5 changes: 3 additions & 2 deletions bytes/src/test/java/org/apache/tuweni/bytes/Bytes32Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ void failsWhenRightPaddingValueLargerThan32() {

@Test
void testWrapSlicesCorrectly() {
Bytes input = Bytes.fromHexString(
"0xA99A76ED7796F7BE22D5B7E85DEEB7C5677E88E511E0B337618F8C4EB61349B4BF2D153F649F7B53359FE8B94A38E44C00000000000000000000000000000000");
Bytes input = Bytes
.fromHexString(
"0xA99A76ED7796F7BE22D5B7E85DEEB7C5677E88E511E0B337618F8C4EB61349B4BF2D153F649F7B53359FE8B94A38E44C00000000000000000000000000000000");
Bytes32 value = Bytes32.wrap(input, 0);
assertEquals(Bytes.fromHexString("0xA99A76ED7796F7BE22D5B7E85DEEB7C5677E88E511E0B337618F8C4EB61349B4"), value);

Expand Down
22 changes: 12 additions & 10 deletions bytes/src/test/java/org/apache/tuweni/bytes/BytesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ void wrap(Object arr) {
}

private static Stream<Arguments> wrapProvider() {
return Stream.of(
Arguments.of(new Object[] {new byte[10]}),
Arguments.of(new Object[] {new byte[] {1}}),
Arguments.of(new Object[] {new byte[] {1, 2, 3, 4}}),
Arguments.of(new Object[] {new byte[] {-1, 127, -128}}));
return Stream
.of(
Arguments.of(new Object[] {new byte[10]}),
Arguments.of(new Object[] {new byte[] {1}}),
Arguments.of(new Object[] {new byte[] {1, 2, 3, 4}}),
Arguments.of(new Object[] {new byte[] {-1, 127, -128}}));
}

@Test
Expand Down Expand Up @@ -108,11 +109,12 @@ void wrapSlice(Object arr, int offset, int length) {
}

private static Stream<Arguments> wrapSliceProvider() {
return Stream.of(
Arguments.of(new byte[] {1, 2, 3, 4}, 0, 4),
Arguments.of(new byte[] {1, 2, 3, 4}, 0, 2),
Arguments.of(new byte[] {1, 2, 3, 4}, 2, 1),
Arguments.of(new byte[] {1, 2, 3, 4}, 2, 2));
return Stream
.of(
Arguments.of(new byte[] {1, 2, 3, 4}, 0, 4),
Arguments.of(new byte[] {1, 2, 3, 4}, 0, 2),
Arguments.of(new byte[] {1, 2, 3, 4}, 2, 1),
Arguments.of(new byte[] {1, 2, 3, 4}, 2, 2));
}

private void assertWrapSlice(byte[] bytes, int offset, int length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ void concatenatedWrap(Object arr1, Object arr2) {
}

private static Stream<Arguments> concatenatedWrapProvider() {
return Stream.of(
Arguments.of(new byte[] {}, new byte[] {}),
Arguments.of(new byte[] {}, new byte[] {1, 2, 3}),
Arguments.of(new byte[] {1, 2, 3}, new byte[] {}),
Arguments.of(new byte[] {1, 2, 3}, new byte[] {4, 5}));
return Stream
.of(
Arguments.of(new byte[] {}, new byte[] {}),
Arguments.of(new byte[] {}, new byte[] {1, 2, 3}),
Arguments.of(new byte[] {1, 2, 3}, new byte[] {}),
Arguments.of(new byte[] {1, 2, 3}, new byte[] {4, 5}));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ static <T> PropertyValidator<T> combine(List<PropertyValidator<? super T>> valid
static <T> PropertyValidator<List<T>> allInList(PropertyValidator<? super T> validator) {
return (key, position, value) -> {
if (value != null) {
return value.stream().flatMap(elem -> validator.validate(key, position, elem).stream()).collect(
Collectors.toList());
return value
.stream()
.flatMap(elem -> validator.validate(key, position, elem).stream())
.collect(Collectors.toList());
}
return noErrors();
};
Expand Down
81 changes: 49 additions & 32 deletions config/src/main/java/org/apache/tuweni/config/SchemaBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ public SchemaBuilder addInteger(
Integer intValue;
if (value instanceof Long) {
if (((Long) value) > Integer.MAX_VALUE) {
return Collections.singletonList(
new ConfigurationError(position, "Value of property '" + canonicalKey + "' is too large for an integer"));
return Collections
.singletonList(
new ConfigurationError(
position,
"Value of property '" + canonicalKey + "' is too large for an integer"));
}
intValue = ((Long) value).intValue();
} else {
Expand Down Expand Up @@ -377,22 +380,25 @@ public SchemaBuilder addListOfInteger(
for (int i = 0; i < objs.size(); ++i) {
Object obj = objs.get(i);
if (obj == null) {
return Collections.singletonList(
new ConfigurationError(position, "Value of property '" + vkey + "', index " + i + ", is null"));
return Collections
.singletonList(
new ConfigurationError(position, "Value of property '" + vkey + "', index " + i + ", is null"));
}
if (!(obj instanceof Integer) && !(obj instanceof Long)) {
return Collections.singletonList(
new ConfigurationError(
position,
"Value of property '" + vkey + "', index " + i + ", is not an integer"));
return Collections
.singletonList(
new ConfigurationError(
position,
"Value of property '" + vkey + "', index " + i + ", is not an integer"));
}
if (obj instanceof Long) {
containsLong = true;
if (((Long) obj) > Integer.MAX_VALUE) {
return Collections.singletonList(
new ConfigurationError(
position,
"Value of property '" + vkey + "', index " + i + ", is too large for an integer"));
return Collections
.singletonList(
new ConfigurationError(
position,
"Value of property '" + vkey + "', index " + i + ", is too large for an integer"));
}
}
}
Expand Down Expand Up @@ -457,8 +463,9 @@ public SchemaBuilder addListOfLong(

validateProperty(key, (canonicalKey, position, value) -> {
if (value != null && !(value instanceof List)) {
return Collections.singletonList(
new ConfigurationError(position, "Property at '" + canonicalKey + "' requires a list of longs"));
return Collections
.singletonList(
new ConfigurationError(position, "Property at '" + canonicalKey + "' requires a list of longs"));
}

boolean containsInteger = false;
Expand All @@ -467,15 +474,19 @@ public SchemaBuilder addListOfLong(
for (int i = 0; i < objs.size(); ++i) {
Object obj = objs.get(i);
if (obj == null) {
return Collections.singletonList(
new ConfigurationError(position, "Value of property '" + canonicalKey + "', index " + i + ", is null"));
return Collections
.singletonList(
new ConfigurationError(
position,
"Value of property '" + canonicalKey + "', index " + i + ", is null"));
}

if (!(obj instanceof Long) && !(obj instanceof Integer)) {
return Collections.singletonList(
new ConfigurationError(
position,
"Value of property '" + canonicalKey + "', index " + i + ", is not a long"));
return Collections
.singletonList(
new ConfigurationError(
position,
"Value of property '" + canonicalKey + "', index " + i + ", is not a long"));
}
containsInteger |= (obj instanceof Integer);
}
Expand Down Expand Up @@ -606,8 +617,9 @@ private <T> SchemaBuilder addScalar(
}
validateProperty(key, (canonicalKey, position, value) -> {
if (value != null && !clazz.isInstance(value)) {
return Collections.singletonList(
new ConfigurationError(position, "Property at '" + canonicalKey + "' requires a " + typeName));
return Collections
.singletonList(
new ConfigurationError(position, "Property at '" + canonicalKey + "' requires a " + typeName));
}
if (validator == null || (defaultValue != null && value == null)) {
return Collections.emptyList();
Expand Down Expand Up @@ -639,25 +651,30 @@ private <T, U> SchemaBuilder addList(

validateProperty(key, (canonicalKey, position, value) -> {
if (value != null && !(value instanceof List)) {
return Collections.singletonList(
new ConfigurationError(
position,
"Property at '" + canonicalKey + "' requires a list of " + typeName + "s"));
return Collections
.singletonList(
new ConfigurationError(
position,
"Property at '" + canonicalKey + "' requires a list of " + typeName + "s"));
}

if (value != null) {
List<Object> objs = (List<Object>) value;
for (int i = 0; i < objs.size(); ++i) {
Object obj = objs.get(i);
if (obj == null) {
return Collections.singletonList(
new ConfigurationError(position, "Value of property '" + canonicalKey + "', index " + i + ", is null"));
return Collections
.singletonList(
new ConfigurationError(
position,
"Value of property '" + canonicalKey + "', index " + i + ", is null"));
}
if (!innerClass.isInstance(obj)) {
return Collections.singletonList(
new ConfigurationError(
position,
"Value of property '" + canonicalKey + "', index " + i + ", is not a " + typeName));
return Collections
.singletonList(
new ConfigurationError(
position,
"Value of property '" + canonicalKey + "', index " + i + ", is not a " + typeName));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ final class TomlBackedConfiguration implements Configuration {

TomlBackedConfiguration(TomlParseResult toml, @Nullable Schema schema) {
List<ConfigurationError> errors = new ArrayList<>();
toml.errors().forEach(
err -> errors.add(new ConfigurationError(documentPosition(err.position()), err.getMessage(), err)));
toml
.errors()
.forEach(err -> errors.add(new ConfigurationError(documentPosition(err.position()), err.getMessage(), err)));
if (schema != null) {
schema.validate(new TomlBackedConfiguration(toml, null)).forEach(errors::add);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ void throwsForMissingValue() throws Exception {

@Test
void throwsForInvalidType() throws Exception {
Configuration config = Configuration.fromToml(
"[foo]\n" + "bar=99\n" + "baz='buz'\n" + "biz=false\n" + "buz = [1,2,3]\n" + "sbuz = ['1', '2', '3']\n");
Configuration config = Configuration
.fromToml(
"[foo]\n" + "bar=99\n" + "baz='buz'\n" + "biz=false\n" + "buz = [1,2,3]\n" + "sbuz = ['1', '2', '3']\n");
assertFalse(config.hasErrors());

assertEquals(99, config.getInteger("foo.bar"));
Expand Down
Loading

0 comments on commit 7b2d43f

Please sign in to comment.