Skip to content
Open
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
19 changes: 19 additions & 0 deletions annotations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ plugins {
id("co.anitrend.support.query.builder.plugin")
}

// Ensure Kotlin module metadata is generated properly
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
compilerOptions {
// Ensure module metadata is generated
freeCompilerArgs.addAll(listOf(
"-Xjvm-default=all",
"-opt-in=kotlin.RequiresOptIn"
))
}
}

// Ensure JAR task includes proper metadata
tasks.jar {
manifest {
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
}
}

tasks.withType<GenerateModuleMetadata> {
dependsOn(":annotations:classesJar")
}
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask

plugins {
id("org.jetbrains.dokka")
}
buildscript {
repositories {
google()
Expand All @@ -19,3 +25,8 @@ allprojects {
}
}
}

tasks.withType(DokkaMultiModuleTask::class.java) {
outputDirectory.set(rootProject.file("dokka-docs"))
failOnWarning.set(false)
}
3 changes: 2 additions & 1 deletion 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 Down Expand Up @@ -29,6 +28,8 @@ dependencies {
/* Depend on the default Gradle API's since we want to build a custom plugin */
implementation(gradleApi())
implementation(localGroovy())

implementation(kotlin("test"))

/** Work around to include ../.gradle/LibrariesForLibs generated file for version catalog */
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
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,11 +1,13 @@
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.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
Expand Down Expand Up @@ -100,6 +102,11 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run {
}
}

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

tasks.withType(KotlinJvmCompile::class.java) {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
Expand Down
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 @@ -28,14 +28,7 @@ private fun addKotlinAndroidPlugin(project: Project, pluginContainer: PluginCont
pluginContainer.apply("kotlin-android")
}

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


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

class PropertiesReader(project: Project) {
class PropertiesReader(project: Project, path: String = "gradle/version.properties") {
@Suppress("NewApi")
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 Down
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,7 +13,7 @@ tasks.withType<com.android.build.gradle.internal.lint.AndroidLintAnalysisTask> {
dependencies {
implementation(project(":core"))

implementation(libs.androidx.sqliteKtx)
implementation(libs.androidx.sqlite.ktx)
}

tasks.withType<Test> {
Expand Down
60 changes: 37 additions & 23 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.13.0"

Expand All @@ -17,71 +17,85 @@ jetbrains-kotlin = "2.2.20"

io-mockk = "1.14.5"

spek2-spek = "2.0.19"
google-devtools-ksp = "2.2.0-2.0.2"

squareup-kotlinpoet = "2.2.0"
google-auto-service = "1.1.1"

kotlin-compile-testing = "0.8.0"

junit5 = "5.13.4"

[plugins]
android-junit5 = { id = "de.mannodermaus.android-junit5", version = "1.13.4.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" }
junit5-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
junit5-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }

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

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

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.9"
androidx-fragment = { module = "androidx.fragment:fragment", version = "1.8.9" }
androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version = "1.8.9" }

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.7.0" }
androidx-test-coreKtx = { module = "androidx.test:core-ktx", version = "1.7.0" }
androidx-test-core-ktx = { module = "androidx.test:core-ktx", version = "1.7.0" }
androidx-test-runner = { module = "androidx.test:runner", version = "1.7.0" }
androidx-test-rules = { module = "androidx.test:rules", version = "1.7.0" }

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-auto-service = { module = "com.google.auto.service:auto-service-annotations", version.ref = "google-auto-service" }
auto-service-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.2.0"
google-android-material = "com.google.android.material:material:1.13.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" }

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

squareup-kotlinpoet = "com.squareup:kotlinpoet:2.2.0"
squareup-kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "squareup-kotlinpoet" }
squareup-kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "squareup-kotlinpoet" }

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

gradle-plugins-android-junit5 = "de.mannodermaus.gradle.plugins:android-junit5:1.13.4.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" }
kotlin-compile-testing = { module = "dev.zacsweers.kctfork:core", version.ref = "kotlin-compile-testing" }
kotlin-compile-testing-ksp = { module = "dev.zacsweers.kctfork:ksp", version.ref ="kotlin-compile-testing" }
50 changes: 40 additions & 10 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,51 @@
import com.google.devtools.ksp.gradle.KspAATask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

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"))

implementation(libs.google.auto.service)
ksp(libs.auto.service.ksp)

compileOnly(libs.google.devtools.ksp.api)
compileOnly(libs.google.devtools.ksp)

api(libs.squareup.kotlinpoet)
compileOnly(libs.androidx.room.common)

testImplementation(project(":annotations"))
testImplementation(libs.androidx.room.common)
testImplementation(libs.google.devtools.ksp)
testImplementation(libs.google.devtools.ksp.api)
testImplementation(libs.kotlin.compile.testing)
testImplementation(libs.kotlin.compile.testing.ksp)
testImplementation(libs.junit5.api)
testRuntimeOnly(libs.junit5.engine)
}

tasks.withType<GenerateModuleMetadata> {
dependsOn(":processor:classesJar")
// Ensure KSP tasks wait for annotations to be fully built
tasks.withType<KspAATask> {
dependsOn(":annotations:jar")
mustRunAfter(":annotations:classesJar")
}

dependencies {
compileOnly(libs.google.auto.service)
kapt(libs.google.auto.service)
// Ensure compilation tasks wait for annotations
tasks.withType<KotlinCompile> {
dependsOn(":annotations:jar")
}

api(libs.squareup.kotlinpoet)
compileOnly(libs.androidx.room.common)
// Ensure test tasks wait for annotations
tasks.withType<Test> {
dependsOn(":annotations:jar")
}

implementation(project(":annotations"))
tasks.test {
useJUnitPlatform()
// Ensure test classpath includes annotations
dependsOn(":annotations:jar")
}
Loading
Loading