Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements, ktor documentation #32

Merged
merged 3 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{kt,kts}]
ktlint_standard_no-wildcard-imports = disabled
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow empty log messages if you only want to create a log entry about a function being called.
- Dependency update:
- [Kotlin 1.9.10](https://kotlinlang.org/docs/whatsnew19.html)
- [Gradle-8.7](https://docs.gradle.org/8.7/release-notes.html)
- [Android Gradle Plugin 8.2.2](https://developer.android.com/build/releases/past-releases/agp-8-2-0-release-notes)

## [1.2.3] - 2022-10-12
### Changed
Expand Down
14 changes: 10 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
plugins {
kotlin("jvm") version "1.9.10"
id("com.android.library") version "7.3.0" apply false
id("com.diffplug.spotless") version "6.21.0"
id("com.github.ben-manes.versions") version "0.48.0"
}
Expand All @@ -11,9 +9,17 @@ spotless {
propertiesFile("gradle.properties")
}
kotlin {
ktlint()
target("**/*.kt")
ktlint().setEditorConfigPath(".editorconfig")
}
kotlinGradle {
ktlint()
ktlint().setEditorConfigPath(".editorconfig")
}
}

tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
rejectVersionIf {
fun isStable(version: String) = Regex("^[0-9,.v-]+(-r)?$").matches(version)
!isStable(candidate.version) && isStable(currentVersion)
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 22 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
21 changes: 11 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -42,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
43 changes: 13 additions & 30 deletions log4k-slf4j/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

kotlin {
androidTarget { publishAllLibraryVariants() }
ios()
iosArm64()
iosSimulatorArm64()
js {
nodejs()
Expand All @@ -18,51 +18,34 @@ kotlin {
}
jvm { testRuns["test"].executionTask.configure { useJUnitPlatform() } }

sourceSets["androidMain"].dependencies {
implementation("org.slf4j:slf4j-api:1.7.36")
}
sourceSets["commonMain"].dependencies {
implementation(project(":log4k"))
}
sourceSets["commonTest"].dependencies {
implementation(kotlin("test"))
}
sourceSets["iosSimulatorArm64Main"].dependsOn(sourceSets["iosMain"])
sourceSets["iosSimulatorArm64Test"].dependsOn(sourceSets["iosTest"])
sourceSets["jvmMain"].dependencies {
implementation("org.slf4j:slf4j-api:1.7.36")
}
applyDefaultHierarchyTemplate()

targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithSimulatorTests::class.java) {
testRuns["test"].deviceId = "iPhone 14"
sourceSets {
commonMain.dependencies { implementation(project(":log4k")) }
commonTest.dependencies { implementation(kotlin("test")) }
androidMain.dependencies { implementation("org.slf4j:slf4j-api:1.7.36") }
jvmMain.dependencies { implementation("org.slf4j:slf4j-api:1.7.36") }
}
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

android {
buildToolsVersion = "33.0.0"
compileSdk = 33
namespace = "saschpe.log4k.slf4j"

defaultConfig {
compileSdk = 33
minSdk = 17
targetSdk = 33
}

sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")

testCoverage.jacocoVersion = "0.8.8"
testCoverage.jacocoVersion = "0.8.10"
}

group = "de.peilicke.sascha"
version = "1.2.3"

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}

publishing {
publications.withType<MavenPublication> {
artifact(javadocJar.get())

pom {
name.set("Log4K-SLF4J")
description.set("Lightweight logging library for Kotlin/Multiplatform - SLF4J integration. Supports Android, iOS, JavaScript and plain JVM environments.")
Expand Down Expand Up @@ -109,4 +92,4 @@ signing {
else -> useInMemoryPgpKeys(sonatypeGpgKey, sonatypeGpgKeyPassword)
}
sign(publishing.publications)
}
}
1 change: 0 additions & 1 deletion log4k-slf4j/src/androidMain/AndroidManifest.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ actual object MDC {
actual fun remove(key: String) = org.slf4j.MDC.remove(key)

actual fun clear() = org.slf4j.MDC.clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ actual class SLF4JLogger : Logger() {
Log.Level.Assert -> error(message, throwable)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ expect object MDC {
fun get(key: String): String?
fun remove(key: String)
fun clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ import saschpe.log4k.Logger
*
* On JVM or Android, SLF4J is used for logging. On JS or Apple platforms, console logging is used internally.
*/
expect class SLF4JLogger : Logger
expect class SLF4JLogger : Logger
2 changes: 1 addition & 1 deletion log4k-slf4j/src/iosMain/kotlin/saschpe/log4k/slf4j/MDC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ actual object MDC {
}

actual fun clear() = context.clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ actual class SLF4JLogger : Logger() {

override fun print(level: Log.Level, tag: String, message: String?, throwable: Throwable?) =
logger.log(level, tag, message, throwable)
}
}
2 changes: 1 addition & 1 deletion log4k-slf4j/src/jsMain/kotlin/saschpe/log4k/slf4j/MDC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ actual object MDC {
}

actual fun clear() = context.clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ actual class SLF4JLogger : Logger() {

override fun print(level: Log.Level, tag: String, message: String?, throwable: Throwable?) =
logger.log(level, tag, message, throwable)
}
}
2 changes: 1 addition & 1 deletion log4k-slf4j/src/jvmMain/kotlin/saschpe/log4k/slf4j/MDC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ actual object MDC {
actual fun remove(key: String) = org.slf4j.MDC.remove(key)

actual fun clear() = org.slf4j.MDC.clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ actual class SLF4JLogger : Logger() {
Log.Level.Assert -> error(message, throwable)
}
}
}
}
31 changes: 10 additions & 21 deletions log4k/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

kotlin {
androidTarget { publishAllLibraryVariants() }
ios()
iosArm64()
iosSimulatorArm64()
js {
nodejs()
Expand All @@ -18,42 +18,31 @@ kotlin {
}
jvm { testRuns["test"].executionTask.configure { useJUnitPlatform() } }

sourceSets["commonTest"].dependencies {
implementation(kotlin("test"))
}
sourceSets["iosSimulatorArm64Main"].dependsOn(sourceSets["iosMain"])
sourceSets["iosSimulatorArm64Test"].dependsOn(sourceSets["iosTest"])
applyDefaultHierarchyTemplate()

targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithSimulatorTests::class.java) {
testRuns["test"].deviceId = "iPhone 14"
sourceSets {
commonTest.dependencies { implementation(kotlin("test")) }
}
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

android {
buildToolsVersion = "33.0.0"
compileSdk = 33
namespace = "saschpe.log4k"

defaultConfig {
compileSdk = 33
minSdk = 17
targetSdk = 33
}

sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")

testCoverage.jacocoVersion = "0.8.8"
testCoverage.jacocoVersion = "0.8.10"
}

group = "de.peilicke.sascha"
version = "1.2.3"

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}

publishing {
publications.withType<MavenPublication> {
artifact(javadocJar.get())

pom {
name.set("Log4K")
description.set("Lightweight logging library for Kotlin/Multiplatform. Supports Android, iOS, JavaScript and plain JVM environments.")
Expand Down Expand Up @@ -100,4 +89,4 @@ signing {
else -> useInMemoryPgpKeys(sonatypeGpgKey, sonatypeGpgKeyPassword)
}
sign(publishing.publications)
}
}
Loading
Loading