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