Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/android-spotless.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: android-spotless

on:
on:
push:
branches: [ develop ]
pull_request:
Expand All @@ -12,16 +12,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
- name: set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'adopt'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run spotless check
- name: Run spotless check
run: ./gradlew spotlessCheck
6 changes: 3 additions & 3 deletions .github/workflows/android-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: android-test

on:
on:
push:
branches: [ develop ]
pull_request:
Expand All @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
- name: set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'adopt'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle-dokka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
- name: set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'adopt'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/version-updater.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: version-updater
on:
repository_dispatch:
types: [version-update-and-push]
Expand Down
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.0.8
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ A simple yet comprehensive sql **select** query builder with featuring an annota

## Why This Project Exists?

While [Room](https://developer.android.com/reference/androidx/room/Room) offers an excelent service loader based approach to generate an ORM layer for android application through static annotated queries, if you need to have some form of dynamic queries that might be user generated at runtime you would have to consider using [SupportSQLiteQueryBuilder](https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder) to generate dynamic queries. However the [SupportSQLiteQueryBuilder](https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder) API does a great job of constructing fairly simple queries, but lacks a fluent builder style API with joins, unions and large chains. In addition to this you have to write out table and column names as plain strings which is not only cumbersome but also error prone and adds additional overhead as you'd have to make sure that any changes you make to the entity related names are reflected throughout all your query builder references.
While [Room](https://developer.android.com/reference/androidx/room/Room) offers an excellent service loader based approach to generate an ORM layer for android application through static annotated queries, if you need to have some form of dynamic queries that might be user generated at runtime you would have to consider using [SupportSQLiteQueryBuilder](https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder) to generate dynamic queries. However the [SupportSQLiteQueryBuilder](https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder) API does a great job of constructing fairly simple queries, but lacks a fluent builder style API with joins, unions and large chains. In addition to this you have to write out table and column names as plain strings which is not only cumbersome but also error prone and adds additional overhead as you'd have to make sure that any changes you make to the entity related names are reflected throughout all your query builder references.

**support-query-builder** aims to solve these problems and comes in the form of 3 libraries with the following features:
- **annotations** - Annotation only which is used to inform the **processor** of entities to inspect
- **core** - The main query builder library for constructing queries
- **core-ext** - Contains helper extention functions for the `core` modules, specifically `asSupportSQLiteQuery`
- **processor** - Kotlin annotation proccessor that generates kotlin object classes that mirror your Room entity annotations supporting inspection `@Entity`, `@ColumnInfo` and `@Embedded`
- **core:ext** - Contains helper extension functions for the `core` modules, specifically `asSupportSQLiteQuery`
- **processor** - Kotlin annotation processor that generates kotlin object classes that mirror your Room entity annotations supporting inspection `@Entity`, `@ColumnInfo` and `@Embedded`


See a list of changes from [releases](https://github.com/AniTrend/support-query-builder/releases)
Expand Down
33 changes: 5 additions & 28 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import co.anitrend.support.query.builder.buildSrc.plugins.resolver.handleDependencySelection
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

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

buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath(libs.android.gradle.plugin)
classpath(libs.jetbrains.kotlin.gradle)
Expand All @@ -21,24 +19,3 @@ allprojects {
}
}
}

tasks {
val clean by registering(Delete::class) {
delete(rootProject.layout.buildDirectory.get())
}
}

tasks.named(
"dependencyUpdates",
DependencyUpdatesTask::class.java
).configure {
checkForGradleUpdate = false
outputFormatter = "json"
outputDir = "build/dependencyUpdates"
reportfileName = "report"
resolutionStrategy {
componentSelection {
all { handleDependencySelection() }
}
}
}
7 changes: 1 addition & 6 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ plugins {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven {
setUrl("https://www.jitpack.io")
}
maven {
setUrl("https://plugins.gradle.org/m2/")
}
}

dependencies {
Expand All @@ -25,9 +23,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 @@ -22,7 +22,7 @@ internal object Modules {
enum class Common(override val id: String) : Module {
Annotation("annotations"),
Core("core"),
Ext("core-ext"),
Ext("core:ext"),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import co.anitrend.support.query.builder.buildSrc.extension.baseExtension
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.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 All @@ -24,10 +24,10 @@ private fun DefaultConfig.applyAdditionalConfiguration(project: Project) {
}

internal fun Project.configureAndroid(): Unit = baseExtension().run {
compileSdkVersion(34)
compileSdkVersion(35)
defaultConfig {
minSdk = 23
targetSdk = 34
targetSdk = 35
versionCode = props[PropertyTypes.CODE].toInt()
versionName = props[PropertyTypes.VERSION]
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -89,22 +89,20 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

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

kotlinOptions {
allWarningsAsErrors = false
freeCompilerArgs = compilerArgumentOptions
tasks.withType(KotlinCompilationTask::class.java) {
compilerOptions {
allWarningsAsErrors.set(false)
freeCompilerArgs.set(emptyList())
}
}

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

import co.anitrend.support.query.builder.buildSrc.extension.isCoreExtModule
import co.anitrend.support.query.builder.buildSrc.extension.props
import co.anitrend.support.query.builder.buildSrc.extension.publishingExtension
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.jvm.tasks.Jar
import org.gradle.api.Project

internal fun Project.configureMaven() {
publishingExtension().publications {
components.collectionSchema.elements.forEach {
logger.lifecycle("${it.name} - ${it.publicType}")
}
val component = components.findByName("java")

logger.lifecycle("Configuring maven publication options for ${project.path}:maven with component -> ${component?.name}")
create("maven", org.gradle.api.publish.maven.MavenPublication::class.java) {
create("maven", MavenPublication::class.java) {
groupId = "co.anitrend.query.builder"
artifactId = project.name
version = props[co.anitrend.support.query.builder.buildSrc.plugins.components.PropertyTypes.VERSION]
version = props[PropertyTypes.VERSION]

from(component)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum class PropertyTypes(val key: String) {
}

class PropertiesReader(project: Project) {
@Suppress("NewApi")
private val properties = Properties(2)

init {
Expand All @@ -28,4 +29,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
Expand Up @@ -7,7 +7,6 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getValue


@Suppress("UnstableApiUsage")
internal fun Project.configureSources() {
val mainSourceSets = when {
!isKotlinLibraryGroup() -> baseExtension().sourceSets["main"].java.srcDirs
Expand Down

This file was deleted.

5 changes: 5 additions & 0 deletions core-ext/build.gradle.kts β†’ core/ext/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ dependencies {

implementation(libs.androidx.sqliteKtx)
}

tasks.withType<Test> {
useJUnitPlatform()
failOnNoDiscoveredTests = false
}
File renamed without changes.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ kapt.incremental.apt=true

# Improved file system watcher
# https://blog.gradle.org/introducing-file-system-watching
org.gradle.vfs.watch=true
org.gradle.vfs.watch=true
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ jetbrains-kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin"
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 = "com.diffplug.spotless:spotless-plugin-gradle:7.2.1"

squareup-kotlinpoet = "com.squareup:kotlinpoet:2.2.0"
Expand Down
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.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
}

tasks.withType<com.android.build.gradle.tasks.JavaPreCompileTask> {
dependsOn(":annotations:classesJar", ":processor:classesJar", ":core:classesJar", ":core-ext:classesJar")
dependsOn(":annotations:classesJar", ":processor:classesJar", ":core:classesJar", ":core:ext:classesJar")
}

dependencies {
Expand Down Expand Up @@ -35,6 +35,6 @@ dependencies {

implementation(project(":annotations"))
implementation(project(":core"))
implementation(project(":core-ext"))
implementation(project(":core:ext"))
kapt(project(":processor"))
}
5 changes: 3 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pluginManagement {
repositories {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven {
setUrl("https://www.jitpack.io")
}
Expand All @@ -11,7 +12,7 @@ pluginManagement {
rootProject.name= "support-query-builder"
include(
":core",
":core-ext",
":core:ext",
":annotations",
":processor",
)
Expand Down
Loading