IceBlizz6 / querydsl-ksp

KSP for QueryDSL
5 stars 1 forks source link

KSP for QueryDSL

Kotlin QueryDSL License

A Kotlin Symbol Processing (KSP) project that enables code generation for QueryDSL, providing a lightweight and efficient way to generate Q classes for QueryDSL usage in Kotlin projects.

Currently only supports jakarta annotations.

Feel free to give feedback if you want support for other annotations.

Setup

Gradle

Add the KSP plugin and dependency for the processor in your build.gradle.kts

plugins {
    kotlin("jvm") version "2.0.21"
    id("com.google.devtools.ksp") version "2.0.21-1.0.26"
}

repositories {
    maven { 
        url = uri("https://jitpack.io") 
    }
}

dependencies {
    implementation("com.querydsl:querydsl-core:5.1.0")
    ksp("com.github.IceBlizz6:querydsl-ksp:0.0.6")
}

And it may be necessary to make your IDE aware of KSP generated code

kotlin {
    sourceSets.main {
        kotlin.srcDir("build/generated/ksp/main/kotlin")
    }
    sourceSets.test {
        kotlin.srcDir("build/generated/ksp/test/kotlin")
    }
}

Settings (all optional)

Name Type Default Description
enable Boolean true Set to false will disable processing
indent String " " (4 spaces) Indent used in generated code files
prefix String "Q" Prefix applied to generated classes
suffix String "" Suffix applied to generated classes
packageSuffix String "" Suffix applied to package name of generated classes
excludedPackages String (comma separated list) "" List of packages that will be skipped in processing
excludedClasses String (comma separated list) "" List of classes that will not be processed
includedPackages String (comma separated list) "" List of packages included, empty means it will include everything
includedClasses String (comma separated list) "" List of classes included, empty means it will include all

Settings must be prefixed with 'querydsl.'

Add into your build.gradle.kts to configure.

// Example
ksp {
    arg("querydsl.prefix", "QQ")
    arg("querydsl.excludedPackages", "com.example, com.sample")
}

Note