[*] Logging via SLF4J
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
group = "de.siphalor"
|
||||
version = "1.0-SNAPSHOT"
|
||||
group = "de.siphalor.tweed5"
|
||||
version = properties["version"]!!
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "maven-publish")
|
||||
|
||||
group = rootProject.group
|
||||
version = properties["version"]!!
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
@@ -18,6 +23,11 @@ allprojects {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
val localRuntimeOnly = configurations.create("localRuntimeOnly")
|
||||
sourceSets.main.get().runtimeClasspath += localRuntimeOnly
|
||||
|
||||
sourceSets.test.get().runtimeClasspath += sourceSets.main.get().runtimeClasspath
|
||||
|
||||
dependencies {
|
||||
val lombok = "org.projectlombok:lombok:${properties["lombok.version"]}"
|
||||
compileOnly(lombok)
|
||||
@@ -34,6 +44,9 @@ allprojects {
|
||||
|
||||
implementation("org.jetbrains:annotations:${properties["jetbrains_annotations.version"]}")
|
||||
|
||||
implementation("org.slf4j:slf4j-api:${properties["slf4j.version"]}")
|
||||
localRuntimeOnly("org.slf4j:slf4j-simple:${properties["slf4j.version"]}")
|
||||
|
||||
testImplementation(platform("org.junit:junit-bom:${properties["junit.version"]}"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testImplementation("org.mockito:mockito-core:${properties["mockito.version"]}")
|
||||
@@ -48,4 +61,16 @@ allprojects {
|
||||
"junit.jupiter.execution.timeout.thread.mode.default" to "SEPARATE_THREAD",
|
||||
)
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
groupId = project.group.toString()
|
||||
artifactId = project.name
|
||||
version = project.version.toString()
|
||||
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
version = 0.1.0
|
||||
|
||||
asm.version = 9.7
|
||||
jetbrains_annotations.version = 26.0.1
|
||||
lombok.version = 1.18.34
|
||||
auto_service.version = 1.1.1
|
||||
slf4j.version = 2.0.16
|
||||
|
||||
junit.version = 5.11.2
|
||||
mockito.version = 5.14.2
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
@@ -16,6 +17,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class PojoClassIntrospector {
|
||||
private final Class<?> clazz;
|
||||
@@ -67,11 +69,23 @@ public class PojoClassIntrospector {
|
||||
Property property = introspectProperty(field);
|
||||
properties.put(property.field.getName(), property);
|
||||
} else {
|
||||
// TODO: logging
|
||||
Property existingProperty = properties.get(field.getName());
|
||||
log.error(
|
||||
"Duplicate property \"{}\" detected in hierarchy of {} in classes: {} and {}",
|
||||
field.getName(),
|
||||
clazz.getName(),
|
||||
existingProperty.field().getDeclaringClass().getName(),
|
||||
targetClass.getName()
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: logging
|
||||
log.error(
|
||||
"Got unexpected error introspecting the properties of class {} (in hierarchy of {})",
|
||||
targetClass.getName(),
|
||||
clazz.getName(),
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +192,13 @@ public class PojoClassIntrospector {
|
||||
} catch (NoSuchMethodException e) {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO: logging
|
||||
log.warn(
|
||||
"Failed to access method \"{}\" of class {} in hierarchy of {}",
|
||||
methodDescriptor,
|
||||
targetClass.getName(),
|
||||
clazz.getName(),
|
||||
e
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -190,7 +210,13 @@ public class PojoClassIntrospector {
|
||||
} catch (NoSuchFieldException e) {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO: logging
|
||||
log.warn(
|
||||
"Failed to access getter for field \"{}\" of class {} in hierarchy of {}",
|
||||
field.getName(),
|
||||
field.getDeclaringClass().getName(),
|
||||
clazz.getName(),
|
||||
e
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +228,13 @@ public class PojoClassIntrospector {
|
||||
} catch (NoSuchFieldException e) {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO: logging
|
||||
log.warn(
|
||||
"Failed to access setter for field \"{}\" of class {} in hierarchy of {}",
|
||||
field.getName(),
|
||||
field.getDeclaringClass().getName(),
|
||||
clazz.getName(),
|
||||
e
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user