generated from rnentjes/kotlin-server-web-empty
Add logging functionality and Maven publishing setup
Added Logger class with various log levels to `commonMain`. Integrated `maven-publish` and `signing` plugins in `build.gradle.kts` to facilitate publishing artifacts to the Maven repository with proper credentials and metadata. Removed `gradle.properties` and updated `.gitignore` accordingly.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -44,3 +44,4 @@ bin/
|
|||||||
### .kotlin ###
|
### .kotlin ###
|
||||||
.kotlin
|
.kotlin
|
||||||
kotlin-js-store
|
kotlin-js-store
|
||||||
|
gradle.properties
|
||||||
|
|||||||
1
.idea/.name
generated
1
.idea/.name
generated
@@ -1 +0,0 @@
|
|||||||
template
|
|
||||||
6
.idea/artifacts/kotlin_simple_logging_js_1_0_0_SNAPSHOT.xml
generated
Normal file
6
.idea/artifacts/kotlin_simple_logging_js_1_0_0_SNAPSHOT.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" name="kotlin-simple-logging-js-1.0.0-SNAPSHOT">
|
||||||
|
<output-path>$PROJECT_DIR$/build/libs</output-path>
|
||||||
|
<root id="archive" name="kotlin-simple-logging-js-1.0.0-SNAPSHOT.jar" />
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
6
.idea/artifacts/kotlin_simple_logging_jvm_1_0_0_SNAPSHOT.xml
generated
Normal file
6
.idea/artifacts/kotlin_simple_logging_jvm_1_0_0_SNAPSHOT.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" name="kotlin-simple-logging-jvm-1.0.0-SNAPSHOT">
|
||||||
|
<output-path>$PROJECT_DIR$/build/libs</output-path>
|
||||||
|
<root id="archive" name="kotlin-simple-logging-jvm-1.0.0-SNAPSHOT.jar" />
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
@@ -2,6 +2,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform") version "2.0.21"
|
kotlin("multiplatform") version "2.0.21"
|
||||||
|
`maven-publish`
|
||||||
|
signing
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "nl.astraeus"
|
group = "nl.astraeus"
|
||||||
@@ -9,57 +11,65 @@ version = "1.0.0-SNAPSHOT"
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
|
||||||
url = uri("https://gitea.astraeus.nl/api/packages/rnentjes/maven")
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url = uri("https://gitea.astraeus.nl:8443/api/packages/rnentjes/maven")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain(17)
|
jvm {}
|
||||||
jvm {
|
js {}
|
||||||
withJava()
|
|
||||||
}
|
|
||||||
js {
|
|
||||||
binaries.executable()
|
|
||||||
browser {
|
|
||||||
distribution {
|
|
||||||
outputDirectory.set(File("$projectDir/web/"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting {
|
val commonMain by getting
|
||||||
dependencies {
|
val jvmMain by getting
|
||||||
api("nl.astraeus:kotlin-css-generator:1.0.10")
|
val jsMain by getting
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "gitea"
|
||||||
|
setUrl("https://gitea.astraeus.nl/api/packages/rnentjes/maven")
|
||||||
|
|
||||||
|
credentials() {
|
||||||
|
val giteaUsername: kotlin.String? by project
|
||||||
|
val giteaPassword: kotlin.String? by project
|
||||||
|
|
||||||
|
username = giteaUsername
|
||||||
|
password = giteaPassword
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val commonTest by getting
|
}
|
||||||
val jvmMain by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation("io.undertow:undertow-core:2.3.14.Final")
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.11.0")
|
|
||||||
|
|
||||||
implementation("org.xerial:sqlite-jdbc:3.32.3.2")
|
// Configure all publications
|
||||||
implementation("com.zaxxer:HikariCP:4.0.3")
|
publications.withType<MavenPublication> {
|
||||||
implementation("nl.astraeus:simple-jdbc-stats:1.6.1") {
|
// Stub javadoc.jar artifact
|
||||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
artifact(javadocJar.get())
|
||||||
|
|
||||||
|
// Provide artifacts information requited by Maven Central
|
||||||
|
pom {
|
||||||
|
name.set("kotlin-komponent")
|
||||||
|
description.set("Kotlin komponent")
|
||||||
|
url.set("https://github.com/rnentjes/komponent")
|
||||||
|
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name.set("MIT")
|
||||||
|
url.set("https://opensource.org/licenses/MIT")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
developers {
|
||||||
val jvmTest by getting {
|
developer {
|
||||||
dependencies {
|
id.set("rnentjes")
|
||||||
|
name.set("Rien Nentjes")
|
||||||
|
email.set("info@nentjes.com")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
url.set("https://github.com/rnentjes/komponent")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jsMain by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation("nl.astraeus:kotlin-komponent:1.2.4")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val jsTest by getting
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signing {
|
||||||
|
sign(publishing.publications)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
kotlin.code.style=official
|
|
||||||
52
src/commonMain/kotlin/nl/astraeus/logger/Logger.kt
Normal file
52
src/commonMain/kotlin/nl/astraeus/logger/Logger.kt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package nl.astraeus.logger
|
||||||
|
|
||||||
|
enum class LogLevel {
|
||||||
|
TRACE,
|
||||||
|
DEBUG,
|
||||||
|
INFO,
|
||||||
|
WARN,
|
||||||
|
ERROR,
|
||||||
|
FATAL
|
||||||
|
}
|
||||||
|
|
||||||
|
class Logger(
|
||||||
|
var level: LogLevel = LogLevel.INFO
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun trace(message: () -> String?) {
|
||||||
|
if (level.ordinal <= LogLevel.TRACE.ordinal) {
|
||||||
|
println("TRACE: ${message()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun debug(message: () -> String?) {
|
||||||
|
if (level.ordinal <= LogLevel.DEBUG.ordinal) {
|
||||||
|
println("DEBUG: ${message()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun info(message: () -> String?) {
|
||||||
|
if (level.ordinal <= LogLevel.INFO.ordinal) {
|
||||||
|
println("INFO: ${message()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun warn(e: Throwable? = null, message: () -> String?) {
|
||||||
|
if (level.ordinal <= LogLevel.WARN.ordinal) {
|
||||||
|
println("WARN: ${message()}")
|
||||||
|
e?.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun error(e: Throwable? = null, message: () -> String?) {
|
||||||
|
if (level.ordinal <= LogLevel.ERROR.ordinal) {
|
||||||
|
println("ERROR: ${message()}")
|
||||||
|
e?.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fatal(e: Throwable, message: () -> String?) {
|
||||||
|
println("FATAL: ${message()}")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user