Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
- Update dependencies
- Make use of getAnnotationsByType
  • Loading branch information
DRSchlaubi committed Aug 11, 2024
1 parent c2a163a commit a40ddba
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class DownloadSourceTask : DefaultTask() {
}

val artifacts = project.dependencies.createArtifactResolutionQuery()
.forModule(dependency.group!!, dependency.name, dependency.version as String)
.forModule(dependency.group, dependency.name, dependency.version as String)
.withArtifacts(JvmLibrary::class.java, SourcesArtifact::class.java)
.execute()

Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlin = "2.0.0"
kotlinpoet = "1.17.0"
ksp = "2.0.0-1.0.22"
kotlinpoet = "1.18.1"
ksp = "2.0.0-1.0.24"

# The compiled binary of codegen.kt we use to compile codegen.kt itself
codegen-kt = "main-SNAPSHOT"
Expand All @@ -15,7 +15,7 @@ codegen-kotlinpoet = { group = "dev.kord.codegen", name = "kotlinpoet", version
codegen-ksp = { group = "dev.kord.codegen", name = "ksp", version = "main-20230912.211940-5" }
codegen-ksp-processor = { group = "dev.kord.codegen", name = "ksp-processor", version = "main-20230912.211940-7" }

mockk = { group = "io.mockk", name = "mockk", version = "1.13.11" }
mockk = { group = "io.mockk", name = "mockk", version = "1.13.12" }

kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
ksp-plugin = { group = "com.google.devtools.ksp", name = "symbol-processing-gradle-plugin", version.ref = "ksp" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# 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
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
12 changes: 4 additions & 8 deletions ksp/src/main/kotlin/TypeResolvers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@ public inline fun <reified A : Annotation> Resolver.getSymbolsWithAnnotation(inD
*
* @see getAnnotationsByType
*/
public inline fun <reified A : Annotation> KSAnnotated.getAnnotationsByType(): Sequence<KSAnnotation> {
val annotationKClass = A::class
return this.annotations.filter {
it.shortName.getShortName() == annotationKClass.simpleName && it.annotationType.resolve().declaration
.qualifiedName?.asString() == annotationKClass.qualifiedName
}
}
@OptIn(KspExperimental::class)
public inline fun <reified A : Annotation> KSAnnotated.getAnnotationsByType(): Sequence<A> =
getAnnotationsByType(A::class)

/**
* Returns an [KSAnnotation] from [A].
*
* @see getAnnotationsByType
*/
public inline fun <reified A : Annotation> KSAnnotated.getAnnotationByType(): KSAnnotation =
public inline fun <reified A : Annotation> KSAnnotated.getAnnotationByType(): A =
getAnnotationsByType<A>().first()

/**
Expand Down

0 comments on commit a40ddba

Please sign in to comment.