Skip to content

Commit

Permalink
Update kotlin and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
NoComment1105 committed Jan 9, 2024
1 parent 1fe201f commit 1a20157
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 60 deletions.
3 changes: 3 additions & 0 deletions api/doc-generator.api
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public final class org/hyacinthbots/docgenerator/enums/CommandTypes : java/lang/
public static final field MESSAGE Lorg/hyacinthbots/docgenerator/enums/CommandTypes;
public static final field SLASH Lorg/hyacinthbots/docgenerator/enums/CommandTypes;
public static final field USER Lorg/hyacinthbots/docgenerator/enums/CommandTypes;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lorg/hyacinthbots/docgenerator/enums/CommandTypes;
public static fun values ()[Lorg/hyacinthbots/docgenerator/enums/CommandTypes;
}
Expand All @@ -69,13 +70,15 @@ public final class org/hyacinthbots/docgenerator/enums/CommandTypes$Companion {
public final class org/hyacinthbots/docgenerator/enums/Environment : java/lang/Enum {
public static final field DEVELOPMENT Lorg/hyacinthbots/docgenerator/enums/Environment;
public static final field PRODUCTION Lorg/hyacinthbots/docgenerator/enums/Environment;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getValue ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lorg/hyacinthbots/docgenerator/enums/Environment;
public static fun values ()[Lorg/hyacinthbots/docgenerator/enums/Environment;
}

public final class org/hyacinthbots/docgenerator/enums/SupportedFileFormat : java/lang/Enum {
public static final field MARKDOWN Lorg/hyacinthbots/docgenerator/enums/SupportedFileFormat;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getFileExtension ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lorg/hyacinthbots/docgenerator/enums/SupportedFileFormat;
public static fun values ()[Lorg/hyacinthbots/docgenerator/enums/SupportedFileFormat;
Expand Down
31 changes: 15 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*

object Meta {
const val projectVersion = "0.1.2"
const val description = "Generate documentation for KordEx bots!"
const val githubRepo = "HyacinthBots/doc-generator"
const val release = "https://s01.oss.sonatype.org/content/repositories/releases/"
const val snapshot = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
const val PROJECT_VERSION = "0.1.3"
const val DESCRIPTION = "Generate documentation for KordEx bots!"
const val GITHUB_REPO = "HyacinthBots/doc-generator"
const val RELEASE = "https://s01.oss.sonatype.org/content/repositories/releases/"
const val SNAPSHOT = "https://s01.oss.sonatype.org/content/repositories/snapshots/"

val version: String
get() {
Expand All @@ -17,7 +16,7 @@ object Meta {
return when {
!tag.isNullOrBlank() -> tag
!branch.isNullOrBlank() && branch.startsWith("refs/heads/") ->
"$projectVersion-SNAPSHOT"
"$PROJECT_VERSION-SNAPSHOT"

else -> "undefined"
}
Expand All @@ -43,7 +42,7 @@ plugins {
}

group = "org.hyacinthbots"
version = Meta.projectVersion
version = Meta.PROJECT_VERSION
val javaVersion = 17

repositories {
Expand Down Expand Up @@ -117,7 +116,7 @@ tasks {

detekt {
buildUponDefaultConfig = true
config = files("$rootDir/detekt.yml")
config.from(files("$rootDir/detekt.yml"))

autoCorrect = true
}
Expand Down Expand Up @@ -150,8 +149,8 @@ publishing {

pom {
name.set(project.name)
description.set(Meta.description)
url.set("https://github.com/${Meta.githubRepo}")
description.set(Meta.DESCRIPTION)
url.set("https://github.com/${Meta.GITHUB_REPO}")

organization {
name.set("HyacinthBots")
Expand All @@ -166,7 +165,7 @@ publishing {

issueManagement {
system.set("GitHub")
url.set("https://github.com/${Meta.githubRepo}/issues")
url.set("https://github.com/${Meta.GITHUB_REPO}/issues")
}

licenses {
Expand All @@ -177,17 +176,17 @@ publishing {
}

scm {
url.set("https://github.com/${Meta.githubRepo}.git")
connection.set("scm:git:git://github.com/${Meta.githubRepo}.git")
developerConnection.set("scm:git:git://github.com/#${Meta.githubRepo}.git")
url.set("https://github.com/${Meta.GITHUB_REPO}.git")
connection.set("scm:git:git://github.com/${Meta.GITHUB_REPO}.git")
developerConnection.set("scm:git:git://github.com/#${Meta.GITHUB_REPO}.git")
}
}
}
}

repositories {
maven {
url = uri(if (Meta.isSnapshot) Meta.snapshot else Meta.release)
url = uri(if (Meta.isSnapshot) Meta.SNAPSHOT else Meta.RELEASE)

credentials {
username = System.getenv("NEXUS_USER")
Expand Down
7 changes: 1 addition & 6 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ naming:
active: true
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
ignoreOverridden: true
InvalidPackageDeclaration:
active: true
rootPackage: 'org.HyacinthBots'
Expand Down Expand Up @@ -281,7 +280,7 @@ style:
includeLineWrapping: true
ForbiddenComment:
active: false
values: ['TODO:', 'FIXME:', 'STOPSHIP:']
comments: ['TODO:', 'FIXME:', 'STOPSHIP:']
allowedPatterns: ''
ForbiddenImport:
active: false
Expand All @@ -308,14 +307,10 @@ style:
ignoreNamedArgument: true
ignoreEnums: true
ignoreRanges: false
MandatoryBracesIfStatements:
active: true
MandatoryBracesLoops:
active: true
OptionalUnit:
active: false
OptionalWhenBraces:
active: true
PreferToOverPairSyntax:
active: true
RedundantExplicitType:
Expand Down
14 changes: 7 additions & 7 deletions libs.versions.toml → gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[versions]
kotlin = "1.8.10"
kordex = "1.5.7-20230412.093301-8"
kotlin = "1.9.10"
kordex = "1.7.1-20231226.111824-10"
git-hooks = "0.0.2"
licenser = "0.6.1"
bin-compat = "0.13.0"
bin-compat = "0.13.2"

detekt = "1.22.0"
logging = "3.0.5"
detekt = "1.23.4"
logging = "5.1.1"

junit5 = "5.9.2"
junit5 = "5.10.1"

[libraries]
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8" }
detekt = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
kordex = { module = "com.kotlindiscord.kord.extensions:kord-extensions", version.ref = "kordex" }
logging = { module = "io.github.microutils:kotlin-logging", version.ref = "logging" }
logging = { module = "io.github.oshai:kotlin-logging", version.ref = "logging" }
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
22 changes: 13 additions & 9 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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 @@ -130,26 +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=SC3045
# 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=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -198,11 +202,11 @@ fi
# 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, 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.
# 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
8 changes: 0 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
rootProject.name = "doc-generator"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("libs.versions.toml"))
}
}
}
8 changes: 4 additions & 4 deletions src/main/kotlin/org/hyacinthbots/docgenerator/_Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import kotlin.io.path.exists
*/
internal suspend inline fun findOrCreateDocumentsFile(path: Path) {
if (!path.exists()) {
DocsGenerator.generatorLogger.debug("File does not exist, creating...")
DocsGenerator.generatorLogger.debug { "File does not exist, creating..." }
try {
withContext(Dispatchers.IO) {
path.createFile()
Expand All @@ -42,7 +42,7 @@ internal suspend inline fun findOrCreateDocumentsFile(path: Path) {
DocsGenerator.generatorLogger.error(e) { e.message }
return
}
DocsGenerator.generatorLogger.debug("File created successfully...")
DocsGenerator.generatorLogger.debug { "File created successfully..." }
}
}

Expand Down Expand Up @@ -91,9 +91,9 @@ internal fun Permissions?.formatPermissionsSet(language: Locale?): String? {

this.values.forEach { perm ->
permissionsSet.add(
Permission.values.find { it.code.value == perm.code.value }
Permission.entries.find { it.code.value == perm.code.value }
?.translate(language ?: SupportedLocales.ENGLISH)
?: Permission.Unknown().translate(language ?: SupportedLocales.ENGLISH)
?: Permission.fromShift(perm.shift).translate(language ?: SupportedLocales.ENGLISH)
)
}
return permissionsSet.toString().replace("[", "").replace("]", "")
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/org/hyacinthbots/docgenerator/_docAddition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ internal var ApplicationCommand<*>.subCommandAdditionalDocumentation: MutableMap
/**
* Private variable to get the persistence of additional docs to work.
*/
@Suppress("ObjectPropertyName")
private var _additionalDocumentation: MutableMap<String, DocAdditionBuilder?> = mutableMapOf() // I hate but it works

/**
* Private variable to get the persistence of additional docs to work.
*/
@Suppress("ObjectPropertyName")
private var _subCommandAdditionalDocumentation: MutableMap<String, DocAdditionBuilder?> = mutableMapOf() // More hatred
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.hyacinthbots.docgenerator

import com.kotlindiscord.kord.extensions.builders.ExtensibleBotBuilder
import mu.KotlinLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import org.hyacinthbots.docgenerator.annotations.ConfigurationBuilderDSL
import org.hyacinthbots.docgenerator.builder.ConfigurationBuilder
import org.hyacinthbots.docgenerator.enums.Environment
Expand Down Expand Up @@ -43,19 +43,19 @@ public suspend fun ExtensibleBotBuilder.docsGenerator(
hooks {
afterExtensionsAdded {
if (!action.enabled) {
generatorLogger.debug("Doc generation disabled, not generating!")
generatorLogger.debug { "Doc generation disabled, not generating!" }
return@afterExtensionsAdded
}

when (action.environment.lowercase()) {
Environment.PRODUCTION.value -> {
generatorLogger.debug("Production environment detected, not generating!")
generatorLogger.debug { "Production environment detected, not generating!" }
return@afterExtensionsAdded
}

Environment.DEVELOPMENT.value -> {
if (action.commandTypes.isEmpty()) {
generatorLogger.error("No command types have been specified! Please specify command types to document")
generatorLogger.error { "No command types have been specified! Please specify command types to document" }
return@afterExtensionsAdded
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import com.kotlindiscord.kord.extensions.commands.application.user.UserCommand
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.i18n.ResourceBundleTranslations
import com.kotlindiscord.kord.extensions.i18n.SupportedLocales
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import mu.KotlinLogging
import org.hyacinthbots.docgenerator.addArguments
import org.hyacinthbots.docgenerator.additionalDocumentation
import org.hyacinthbots.docgenerator.enums.CommandTypes
Expand All @@ -29,7 +29,7 @@ import org.hyacinthbots.docgenerator.subCommandAdditionalDocumentation
import org.hyacinthbots.docgenerator.translate
import java.io.IOException
import java.nio.file.Path
import java.util.*
import java.util.Locale
import kotlin.io.path.Path
import kotlin.io.path.bufferedWriter

Expand Down Expand Up @@ -398,7 +398,7 @@ internal object DocsGenerator {
writer.flush()
writer.close()
}
generatorLogger.info("Written documents for ${language.toLanguageTag()}!")
generatorLogger.info { "Written documents for ${language.toLanguageTag()}!" }
}
} else {
// Generate the contents in the target language
Expand All @@ -410,7 +410,7 @@ internal object DocsGenerator {
writer.flush()
writer.close()
}
generatorLogger.info("Written documents!")
generatorLogger.info { "Written documents!" }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/UtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class UtilsTest {
@Test
@Order(4)
fun `CommandType ALL contains all command types`(): Unit = runBlocking {
CommandTypes.values().forEach {
CommandTypes.entries.forEach {
assertTrue("All commands types were not present in the list: $it is missing.") {
it in CommandTypes.ALL
}
Expand Down

0 comments on commit 1a20157

Please sign in to comment.