Skip to content

Commit

Permalink
Kotlin 1.7.20 compatible release for 1.5.3 users (#3567)
Browse files Browse the repository at this point in the history
* Kotlin 1.7.20 compatible release for 1.5.3 users

* Use AGP namespace attribute

(cherry picked from commit 1a004ac)

* TemporaryFixture

* Update AndroidManifest.xml
  • Loading branch information
Alec Strong committed Oct 5, 2022
1 parent 258a92f commit 4611b57
Show file tree
Hide file tree
Showing 29 changed files with 54 additions and 54 deletions.
17 changes: 1 addition & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.grammarkit.tasks.GenerateParser

buildscript {
apply from: "$rootDir/gradle/dependencies.gradle"

Expand Down Expand Up @@ -59,23 +57,10 @@ allprojects {
targetCompatibility = JavaVersion.VERSION_1_8
}

configurations {
grammar
}

dependencies {
grammar deps.intellij.indexing
grammar deps.intellij.analysisImpl
grammar deps.intellij.asm
}

tasks.withType(GenerateParser).configureEach {
classpath = configurations.grammar + configurations.compileOnly
}

configurations.all {
exclude group: 'com.jetbrains.rd'
exclude group: 'com.github.jetbrains', module: 'jetCheck'
exclude group: 'org.roaringbitmap'
}

group = GROUP
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ext.deps = [
kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",
dokka: "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}",
intellij: "org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.1.2",
grammarKitComposer: "com.alecstrong:grammar-kit-composer:0.1.5",
grammarKitComposer: "com.alecstrong:grammar-kit-composer:0.1.10",
publish: "com.vanniktech:gradle-maven-publish-plugin:0.14.2",
spotless: "com.diffplug.spotless:spotless-plugin-gradle:5.17.1",
changelog: "org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.3.1",
Expand Down
5 changes: 4 additions & 1 deletion sqldelight-compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ sourceSets {
main.java.srcDir "gen"
}

grammarKit {
intellijRelease.set(versions.idea)
}

dependencies {
api deps.sqlitePsi

Expand Down Expand Up @@ -49,7 +53,6 @@ task pluginVersion {
versionFile.parentFile.mkdirs()
versionFile.text = """// Generated file. Do not edit!
package com.squareup.sqldelight
val VERSION = "${project.version}"
"""
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
package com.squareup.sqldelight.gradle.android

import com.android.build.gradle.BaseExtension
import com.android.ide.common.symbols.getPackageNameFromManifest
import org.gradle.api.GradleException
import org.gradle.api.Project

internal fun Project.packageName(): String {
val androidExtension = extensions.getByType(BaseExtension::class.java)
androidExtension.sourceSets
.map { it.manifest.srcFile }
.filter { it.exists() }
.forEach {
return getPackageNameFromManifest(it)
}
throw IllegalStateException("No source sets available")
return androidExtension.namespace ?: throw GradleException(
"""
|SqlDelight requires a package name to be set. This can be done via the android namespace:
|
|android {
| namespace "com.example.mypackage"
|}
|
|or the sqldelight configuration:
|
|sqldelight {
| MyDatabase {
| packageName = "com.example.mypackage"
| }
|}
""".trimMargin()
)
}

internal fun Project.sqliteVersion(): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.SourceDirectorySet
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
Expand Down Expand Up @@ -47,14 +47,14 @@ internal fun SqlDelightDatabase.sources(): List<Source> {
}

// Kotlin project.
val sourceSets = project.extensions.getByName("sourceSets") as SourceSetContainer
val sourceSets = (project.extensions.getByName("kotlin") as KotlinProjectExtension).sourceSets
return listOf(
Source(
type = KotlinPlatformType.jvm,
name = "main",
sourceSets = listOf("main"),
sourceDirectorySet = sourceSets.getByName("main").kotlin!!,
)
sourceDirectorySet = sourceSets.getByName("main").kotlin,
),
)
}

Expand Down Expand Up @@ -91,18 +91,18 @@ private fun BaseExtension.sources(project: Project): List<Source> {
is LibraryExtension -> libraryVariants
else -> throw IllegalStateException("Unknown Android plugin $this")
}
val kotlinSourceSets = (project.extensions.getByName("kotlin") as KotlinProjectExtension).sourceSets
val sourceSets = sourceSets
.associate { sourceSet ->
sourceSet.name to sourceSet.kotlin
sourceSet.name to kotlinSourceSets.getByName(sourceSet.name).kotlin
}

return variants.map { variant ->
Source(
type = KotlinPlatformType.androidJvm,
name = variant.name,
variantName = variant.name,
sourceDirectorySet = sourceSets[variant.name]
?: throw IllegalStateException("Couldn't find ${variant.name} in $sourceSets"),
sourceDirectorySet = sourceSets[variant.name]!!,
sourceSets = variant.sourceSets.map { it.name },
registerGeneratedDirectory = { outputDirectoryProvider ->
variant.addJavaSourceFoldersToModel(outputDirectoryProvider.get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repositories {

android {
compileSdkVersion versions.compileSdk
namespace "com.example.sqldelight"

lintOptions {
textReport true
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sqldelight {

android {
compileSdkVersion versions.compileSdk
namespace "com.squareup.sqldelight.integration"

defaultConfig {
minSdkVersion versions.minSdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sqldelight {

android {
compileSdkVersion versions.compileSdk
namespace "com.squareup.sqldelight.integration"

defaultConfig {
minSdkVersion versions.minSdk
Expand All @@ -41,4 +42,4 @@ android {
packagingOptions {
exclude 'LICENSE.txt'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.squareup.sqldelight.integration">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-sdk android:minSdkVersion="9"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ dependencies {

sqldelight {
QueryWrapper {

}
}

android {
compileSdkVersion versions.compileSdk
namespace "com.squareup.sqldelight.integration"

defaultConfig {
minSdkVersion versions.minSdk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.squareup.sqldelight.integration">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-sdk android:minSdkVersion="9"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repositories {

android {
compileSdkVersion versions.compileSdk
namespace "com.squareup.sqldelight.integration"

defaultConfig {
minSdkVersion versions.minSdk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.squareup.sqldelight.integration">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-sdk android:minSdkVersion="9"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.gradle.tooling.GradleConnector
import java.io.File

internal class TemporaryFixture : AutoCloseable {
val fixtureRoot = File("src/test/temporary-fixture").absoluteFile
val fixtureRoot = File("src/test/temporary-fixture-${System.identityHashCode(this)}").absoluteFile

init {
fixtureRoot.mkdir()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repositories {

android {
compileSdkVersion versions.compileSdk
namespace "com.example.sqldelight"

lintOptions {
textReport true
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sqldelight {

android {
compileSdkVersion versions.compileSdk
namespace "com.example.sqldelight"

buildTypes {
release {}
Expand All @@ -33,4 +34,4 @@ dependencies {
implementation project(path: ':MultiplatformProject')
implementation "com.squareup.sqldelight:sqlite-driver:${com.squareup.sqldelight.VersionKt.VERSION}"
implementation deps.truth
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.squareup.sqldelight.android.project"/>
<manifest/>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sqldelight {

android {
compileSdkVersion versions.compileSdk
namespace "com.squareup.sqldelight.multiplatform.project"

buildTypes {
release {}
Expand All @@ -36,4 +37,4 @@ kotlin {

targetFromPreset(presets.iosX64, 'iosX64')
targetFromPreset(presets.android, 'androidLib')
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.squareup.sqldelight.multiplatform.project"/>
<manifest/>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repositories {

android {
compileSdkVersion versions.compileSdk
namespace "com.example"

defaultConfig {
minSdkVersion 30
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ repositories {

android {
compileSdkVersion versions.compileSdk
namespace "com.example.sqldelight"

lintOptions {
textReport true
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions sqldelight-gradle-plugin/src/test/variants/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

android {
compileSdkVersion versions.compileSdk
namespace "com.example.sqldelight"

lintOptions {
textReport true
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

android {
compileSdkVersion versions.compileSdk
namespace "com.example.sqldelight"

defaultConfig {
applicationId "com.sample"
Expand Down

This file was deleted.

0 comments on commit 4611b57

Please sign in to comment.