updated Gradle and lys-catalog versions
All checks were successful
CI / build (push) Successful in 24s

This commit is contained in:
2025-04-19 22:00:58 +08:00
parent ef2ee4a86c
commit 3b55366347
10 changed files with 76 additions and 14 deletions

View File

@@ -1,3 +1,4 @@
import net.woggioni.gradle.graalvm.NativeImageConfigurationTask
import net.woggioni.gradle.graalvm.NativeImageTask
import net.woggioni.gradle.graalvm.NativeImagePlugin
@@ -16,8 +17,17 @@ dependencies {
implementation project(':')
}
nativeImage {
mainClass = 'net.woggioni.jwo.benchmark.Main'
Property<String> mainModuleName = objects.property(String.class)
mainModuleName.set('net.woggioni.jwo')
Property<String> mainClassName = objects.property(String.class)
mainClassName.set('net.woggioni.jwo.benchmark.Main')
tasks.named(NativeImagePlugin.CONFIGURE_NATIVE_IMAGE_TASK_NAME, NativeImageConfigurationTask) {
mainClass = mainClassName
}
tasks.named(NativeImagePlugin.NATIVE_IMAGE_TASK_NAME, NativeImageTask) {
useMusl = true
buildStaticImage = true
mainClass = mainClassName
}

View File

@@ -2,7 +2,6 @@ plugins {
id 'java-library'
id 'maven-publish'
id 'jacoco'
alias(catalog.plugins.multi.release.jar)
alias(catalog.plugins.lombok)
alias(catalog.plugins.sambal)
}
@@ -24,6 +23,7 @@ allprojects {
languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.ORACLE
}
modularity.inferModulePath = true
}
dependencies {
@@ -63,7 +63,6 @@ allprojects {
pluginManager.withPlugin('java-library') {
java {
withJavadocJar()
withSourcesJar()
}
}
@@ -115,7 +114,7 @@ dependencies {
}
compileJava {
options.release = 8
options.release = 11
options.compilerArgs << '-parameters'
}

View File

@@ -3,6 +3,6 @@ org.gradle.parallel=true
org.gradle.caching=true
gitea.maven.url = https://gitea.woggioni.net/api/packages/woggioni/maven
jwo.version = 2025.02.25
lys.version = 2025.02.25
jwo.version = 2025.04.19
lys.version = 2025.04.16
guice.version = 5.0.1

View File

@@ -1,5 +1,6 @@
import net.woggioni.gradle.graalvm.NativeImagePlugin
import net.woggioni.gradle.graalvm.NativeImageTask
import net.woggioni.gradle.graalvm.NativeImageConfigurationTask
plugins {
id 'java-library'
@@ -16,13 +17,17 @@ dependencies {
implementation project(':jmath')
}
nativeImage {
mainClass = 'net.woggioni.jmath.benchmark.Main'
useMusl = true
buildStaticImage = true
}
Property<String> mainClassName = objects.property(String.class)
mainClassName.set('net.woggioni.jmath.benchmark.Main')
configureNativeImage {
tasks.named(NativeImagePlugin.CONFIGURE_NATIVE_IMAGE_TASK_NAME, NativeImageConfigurationTask) {
mainClass = mainClassName
args('20')
}
tasks.named(NativeImagePlugin.NATIVE_IMAGE_TASK_NAME, NativeImageTask) {
useMusl = true
buildStaticImage = true
mainClass = mainClassName
}

View File

@@ -90,7 +90,36 @@ public class Hash {
return new String(hexChars);
}
private static int charToInt(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
} else if(c >= 'a' && c <= 'f') {
return 10 + c - 'a';
} else if(c >= 'A' && c <= 'F') {
return 10 + c - 'A';
} else {
throw newThrowable(IllegalArgumentException.class, "Illegal hex character '%c'", c);
}
}
public static byte[] hexToBytes(String hexString) {
if (hexString.length() % 2 != 0) {
throw newThrowable(IllegalArgumentException.class, "Hex string length must be even," +
" string has length '%d' instead", hexString.length());
}
byte[] result = new byte[hexString.length() / 2];
for(int i = 0; i < hexString.length(); i++) {
int value = charToInt(hexString.charAt(i));
if (i % 2 == 0) {
result[i / 2] += (byte) (value << 4);
} else {
result[i / 2] += (byte) value;
}
}
return result;
}
public static byte[] hexToBytes2(String hexString) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (hexString.length() % 2 != 0) {
throw newThrowable(IllegalArgumentException.class, "Hex string length must be even," +

View File

@@ -237,6 +237,10 @@ public class JWO {
return Hash.bytesToHex(bytes);
}
public static byte[] hexToBytes(String hexStr) {
return Hash.hexToBytes(hexStr);
}
@SneakyThrows
public static void deletePath(Path path) {
Files.walk(path)

View File

@@ -65,6 +65,7 @@ public class HashTest {
);
}
}
@ArgumentsSource(HexTestArguments.class)
@ParameterizedTest
public void hexTest(String sourceString, Class<? extends Throwable> t) {
@@ -78,4 +79,18 @@ public class HashTest {
Assertions.assertEquals(sourceString.toUpperCase(), Hash.bytesToHex(bytes));
}
}
@ArgumentsSource(HexTestArguments.class)
@ParameterizedTest
public void hexTest2(String sourceString, Class<? extends Throwable> t) {
if(t != null) {
Assertions.assertThrows(t, () ->
Hash.hexToBytes2(sourceString)
);
} else {
byte[] bytes = Hash.hexToBytes2(sourceString);
Assertions.assertEquals(sourceString.length() / 2, bytes.length);
Assertions.assertEquals(sourceString.toUpperCase(), Hash.bytesToHex(bytes));
}
}
}

View File

@@ -82,7 +82,7 @@ public class JavaVersionTest {
JWO.copy(is, baos);
}
final var jwoClassVersion = JavaVersion.forClass(baos.toByteArray());
assertEquals(JavaVersion.VERSION_1_8, jwoClassVersion);
assertEquals(JavaVersion.VERSION_11, jwoClassVersion);
}
}
}