Skip to content

feat: add new symbol processor #280

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
28 changes: 11 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import co.anitrend.support.query.builder.buildSrc.plugins.resolver.handleDependencySelection
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask

plugins {
id("com.github.ben-manes.versions")
id("org.jetbrains.dokka")
}

buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath(libs.android.gradle.plugin)
classpath(libs.jetbrains.kotlin.gradle)
Expand All @@ -28,17 +32,7 @@ tasks {
}
}

tasks.named(
"dependencyUpdates",
DependencyUpdatesTask::class.java
).configure {
checkForGradleUpdate = false
outputFormatter = "json"
outputDir = "build/dependencyUpdates"
reportfileName = "report"
resolutionStrategy {
componentSelection {
all { handleDependencySelection() }
}
}
}
tasks.withType(DokkaMultiModuleTask::class.java) {
outputDirectory.set(rootProject.file("dokka-docs"))
failOnWarning.set(false)
}
4 changes: 0 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
`kotlin-dsl`
`maven-publish`
`version-catalog`
}

repositories {
Expand All @@ -25,9 +24,6 @@ dependencies {
/* Depend on the dokka plugin, since we want to access it in our plugin */
implementation(libs.jetbrains.dokka.gradle)

/** Dependency management */
implementation(libs.gradle.versions)

/** Spotless */
implementation(libs.spotless.gradle)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ internal object Modules {
}

enum class Processor(override val id: String) : Module {
Kapt("processor")
Kapt("processor"),
Ksp("processor")
}

enum class Common(override val id: String) : Module {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package co.anitrend.support.query.builder.buildSrc.plugins.components

import co.anitrend.support.query.builder.buildSrc.extension.*
import co.anitrend.support.query.builder.buildSrc.extension.baseAppExtension
import co.anitrend.support.query.builder.buildSrc.extension.baseExtension
import co.anitrend.support.query.builder.buildSrc.extension.isSampleModule
import co.anitrend.support.query.builder.buildSrc.extension.props
import com.android.build.gradle.internal.dsl.DefaultConfig
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.gradle.api.tasks.testing.Test
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import java.io.File


@Suppress("UnstableApiUsage")
private fun DefaultConfig.applyAdditionalConfiguration(project: Project) {
if (project.isSampleModule()) {
applicationId = "co.anitrend.support.query.builder.sample"
Expand Down Expand Up @@ -93,18 +94,22 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run {
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType(KotlinCompile::class.java) {
tasks.withType(KotlinCompilationTask::class.java) {
val compilerArgumentOptions = emptyList<String>()

kotlinOptions {
allWarningsAsErrors = false
freeCompilerArgs = compilerArgumentOptions
compilerOptions {
allWarningsAsErrors.set(false)
freeCompilerArgs.addAll(compilerArgumentOptions)
}
}

tasks.withType(Test::class.java) {
useJUnitPlatform()
}

tasks.withType(KotlinJvmCompile::class.java) {
kotlinOptions {
jvmTarget = "17"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package co.anitrend.support.query.builder.buildSrc.plugins.components

import co.anitrend.support.query.builder.buildSrc.extension.isKotlinLibraryGroup
import co.anitrend.support.query.builder.buildSrc.extension.isProcessorModule
import co.anitrend.support.query.builder.buildSrc.extension.isSampleModule
import org.gradle.api.Project
import org.gradle.api.plugins.PluginContainer
import co.anitrend.support.query.builder.buildSrc.extension.isSampleModule
import co.anitrend.support.query.builder.buildSrc.extension.isProcessorModule
import co.anitrend.support.query.builder.buildSrc.extension.isKotlinLibraryGroup

private fun addAndroidPlugin(project: Project, pluginContainer: PluginContainer) {
when {
Expand All @@ -29,13 +29,14 @@ private fun addKotlinAndroidPlugin(project: Project, pluginContainer: PluginCont
}

private fun addAnnotationProcessor(project: Project, pluginContainer: PluginContainer) {
if (project.isSampleModule() || project.isProcessorModule())
if (project.isSampleModule() || project.isProcessorModule()) {
pluginContainer.apply("kotlin-kapt")
}
}


internal fun Project.configurePlugins() {
addAndroidPlugin(project, plugins)
addKotlinAndroidPlugin(project, plugins)
addAnnotationProcessor(project, plugins)
//addAnnotationProcessor(project, plugins)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ enum class PropertyTypes(val key: String) {
VERSION("version"),
}

class PropertiesReader(project: Project) {
class PropertiesReader(project: Project, path: String = "gradle/version.properties") {
private val properties = Properties(2)

init {
val releaseFile = File(project.rootDir, "gradle/version.properties")
val releaseFile = File(project.rootDir, path)
if (!releaseFile.exists()) {
project.logger.error("Release file cannot be found in path: $releaseFile")
}
Expand All @@ -28,4 +28,4 @@ class PropertiesReader(project: Project) {
return properties.getProperty(type.key)
?: throw IllegalStateException("$type properties were not initialized")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
package co.anitrend.support.query.builder.buildSrc.plugins.resolver

import com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionWithCurrent

fun ComponentSelectionWithCurrent.handleDependencySelection() {
val reject = listOf("preview", "m", "rc", "alpha", "beta")
.map { qualifier ->
val pattern = "(?i).*[.-]$qualifier[.\\d-]*"
Regex(pattern, RegexOption.IGNORE_CASE)
}
.any { it.matches(candidate.version) }
if (reject)
reject("$candidate version does not fit acceptance criteria")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package co.anitrend.support.query.builder.buildSrc.plugins.strategy

import co.anitrend.support.query.builder.buildSrc.extension.*
import co.anitrend.support.query.builder.buildSrc.extension.implementation
import co.anitrend.support.query.builder.buildSrc.extension.isSampleModule
import co.anitrend.support.query.builder.buildSrc.extension.libs
import co.anitrend.support.query.builder.buildSrc.extension.test
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.DependencyHandler

Expand All @@ -12,13 +15,14 @@ internal class DependencyStrategy(private val project: Project) {

test(project.libs.junit)
test(project.libs.mockk)
test(project.libs.jetbrains.kotlin.test)
}

private fun DependencyHandler.applyLifeCycleDependencies() {
implementation(project.libs.androidx.lifecycle.extensions)
implementation(project.libs.androidx.lifecycle.runTimeKtx)
implementation(project.libs.androidx.lifecycle.liveDataKtx)
implementation(project.libs.androidx.lifecycle.liveDataCoreKtx)
implementation(project.libs.androidx.lifecycle.runTime.ktx)
implementation(project.libs.androidx.lifecycle.liveData.ktx)
implementation(project.libs.androidx.lifecycle.liveDataCore.ktx)
}

fun applyDependenciesOn(handler: DependencyHandler) {
Expand Down
2 changes: 1 addition & 1 deletion core-ext/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ tasks.withType<com.android.build.gradle.internal.lint.AndroidLintAnalysisTask> {
dependencies {
implementation(project(":core"))

implementation(libs.androidx.sqliteKtx)
implementation(libs.androidx.sqlite.ktx)
}
46 changes: 26 additions & 20 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
ktlint = "1.1.1"
ktlint = "1.5.0"

gradle-plugin = "8.10.1"

Expand All @@ -19,71 +19,77 @@ io-mockk = "1.14.2"

spek2-spek = "2.0.19"

google-devtools-ksp = "2.0.0-1.0.22"

[plugins]
android-junit5 = { id = "de.mannodermaus.android-junit5", version = "1.12.2.0" }
google-devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "google-devtools-ksp" }



[libraries]
timber = "com.jakewharton.timber:timber:5.0.1"
junit = "junit:junit:4.13.2"
timber = { module = "com.jakewharton.timber:timber", version = "5.0.1" }
junit = { module ="junit:junit", version = "4.13.2" }

android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "gradle-plugin" }

androidx-activityKtx = "androidx.activity:activity-ktx:1.10.1"
androidx-activity = { module = "androidx.activity:activity", version = "1.10.1" }
androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version = "1.10.1" }

androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-appcompatResources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidx-appcompat" }

androidx-constraintLayout = "androidx.constraintlayout:constraintlayout:2.2.1"

androidx-fragmentKtx = "androidx.fragment:fragment-ktx:1.8.7"
androidx-fragment = { module = "androidx.fragment:fragment", version = "1.8.7" }
androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version = "1.8.7" }

androidx-lifecycle-extensions = "androidx.lifecycle:lifecycle-extensions:2.2.0"
androidx-lifecycle-runTimeKtx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-liveDataKtx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-liveDataCoreKtx = { module = "androidx.lifecycle:lifecycle-livedata-core-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version = "2.2.0" }
androidx-lifecycle-runTime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-liveData-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-liveDataCore-ktx = { module = "androidx.lifecycle:lifecycle-livedata-core-ktx", version.ref = "androidx-lifecycle" }

androidx-navigation-fragmentKtx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "androidx-navigation" }
androidx-navigation-uiKtx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "androidx-navigation" }
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "androidx-navigation" }
androidx-navigation-fragment = { module = "androidx.navigation:navigation-fragment", version.ref = "androidx-navigation" }
androidx-navigation-ui = { module = "androidx.navigation:navigation-ui", version.ref = "androidx-navigation" }
androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "androidx-navigation" }

androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "androidx-room" }
androidx-room-common = { module = "androidx.room:room-common", version.ref = "androidx-room" }
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "androidx-room" }
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "androidx-room" }

androidx-sqlite = { module = "androidx.sqlite:sqlite", version.ref = "androidx-sqlite" }
androidx-sqliteKtx = { module = "androidx.sqlite:sqlite-ktx", version.ref = "androidx-sqlite" }
androidx-sqlite-ktx = { module = "androidx.sqlite:sqlite-ktx", version.ref = "androidx-sqlite" }

androidx-test-core = { module = "androidx.test:core", version = "1.6.1" }
androidx-test-coreKtx = { module = "androidx.test:core-ktx", version = "1.6.1" }
androidx-test-core-ktx = { module = "androidx.test:core-ktx", version = "1.6.1" }
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" }
androidx-test-rules = { module = "androidx.test:rules", version = "1.6.1" }

androidx-junitKtx = { module = "androidx.test.ext:junit-ktx", version.ref = "androidx-test-ext" }

google-auto-service = "com.google.auto.service:auto-service:1.1.1"
google-android-material = "com.google.android.material:material:1.12.0"

jetbrains-dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "jetbrains-dokka" }
jetbrains-kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "jetbrains-kotlin" }
jetbrains-kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "jetbrains-kotlin" }
jetbrains-kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "jetbrains-kotlin" }
jetbrains-kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "jetbrains-kotlin" }

mockk = { module = "io.mockk:mockk", version.ref = "io-mockk" }
mockk-android = { module = "io.mockk:mockk-android", version.ref = "io-mockk" }

gradle-versions = "com.github.ben-manes:gradle-versions-plugin:0.52.0"
spotless-gradle = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "7.0.2" }

spotless-gradle = "com.diffplug.spotless:spotless-plugin-gradle:7.0.4"
spotless-gradle = "com.diffplug.spotless:spotless-plugin-gradle:7.0.3"
pintrest-ktlint = { module = "com.pinterest:ktlint", version.ref = "ktlint" }

squareup-kotlinpoet = "com.squareup:kotlinpoet:2.2.0"

tschuchortdev-kotlin-compile-testing = "com.github.tschuchortdev:kotlin-compile-testing:1.6.0"
google-devtools-ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "google-devtools-ksp" }
kotlin-compile-testing-ksp = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version = "1.6.0" }

gradle-plugins-android-junit5 = "de.mannodermaus.gradle.plugins:android-junit5:1.12.2.0"

spek2-spek-dsl-jvm = { module = "org.spekframework.spek2:spek-dsl-jvm", version.ref = "spek2-spek" }
spek2-spek-runner-junit5 = { module = "org.spekframework.spek2:spek-runner-junit5", version.ref = "spek2-spek" }

pintrest-ktlint = { module = "com.pinterest:ktlint", version.ref = "ktlint" }
26 changes: 14 additions & 12 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
plugins {
id("co.anitrend.support.query.builder.plugin")
alias(libs.plugins.google.devtools.ksp)
}

tasks.withType<org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask> {
dependsOn(":annotations:classesJar")
}
dependencies {
implementation(project(":annotations"))

tasks.withType<GenerateModuleMetadata> {
dependsOn(":processor:classesJar")
}
api(libs.squareup.kotlinpoet)
compileOnly(libs.androidx.room.common)
implementation(libs.google.devtools.ksp.api)

dependencies {
compileOnly(libs.google.auto.service)
kapt(libs.google.auto.service)
testImplementation(libs.jetbrains.kotlin.test)
testImplementation(libs.kotlin.compile.testing.ksp)
}

api(libs.squareup.kotlinpoet)
compileOnly(libs.androidx.room.common)
tasks.withType(Test::class.java) {
dependsOn(":annotations:classesJar")
}

implementation(project(":annotations"))
tasks.test {
useJUnitPlatform()
}
Loading
Loading