Skip to content

Commit

Permalink
Use AGP namespace attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecKazakova committed May 9, 2022
1 parent ed9e3cc commit 31e8776
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ package app.cash.sqldelight.gradle.android

import app.cash.sqldelight.VERSION
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.internal.manifest.parseManifest
import com.android.builder.errors.EvalIssueException
import com.android.builder.errors.IssueReporter
import org.gradle.api.GradleException
import org.gradle.api.Project
import java.util.function.BooleanSupplier

internal fun Project.packageName(): String {
val androidExtension = extensions.getByType(BaseExtension::class.java)
androidExtension.sourceSets
.map { it.manifest.srcFile }
.filter { it.exists() }
.forEach {
return parseManifest(
file = it,
manifestFileRequired = true,
manifestParsingAllowed = BooleanSupplier { true },
issueReporter = object : IssueReporter() {
override fun hasIssue(type: Type) = false
override fun reportIssue(type: Type, severity: Severity, exception: EvalIssueException) = throw exception
}
).packageName!!
}
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 @@ -13,6 +13,8 @@ repositories {
}

android {
namespace "com.example.sqldelight"

compileSdkVersion deps.versions.compileSdk.get() as int

lintOptions {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ sqldelight {
}

android {
namespace "com.example.sqldelight"

compileSdkVersion deps.versions.compileSdk.get() as int

defaultConfig {
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="app.cash.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 @@ -31,6 +31,8 @@ sqldelight {
}

android {
namespace "app.cash.sqldelight.integration"

compileSdkVersion deps.versions.compileSdk.get() as int

defaultConfig {
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="app.cash.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 @@ -15,6 +15,8 @@ repositories {
}

android {
namespace "app.cash.sqldelight.integration"

compileSdkVersion deps.versions.compileSdk.get() as int

defaultConfig {
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="app.cash.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,6 +13,8 @@ repositories {
}

android {
namespace "com.example.sqldelight"

compileSdkVersion deps.versions.compileSdk.get() as int

lintOptions {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ sqldelight {
}

android {
namespace "com.example.sqldelight"

compileSdkVersion deps.versions.compileSdk.get() as int

buildTypes {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sqldelight {
}

android {
namespace "app.cash.sqldelight.multiplatform.project"

compileSdkVersion deps.versions.compileSdk.get() as int

buildTypes {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ repositories {
}

android {
namespace "com.example"

compileSdkVersion deps.versions.compileSdk.get() as int

defaultConfig {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ repositories {
}

android {
namespace "com.example.sqldelight"

compileSdkVersion deps.versions.compileSdk.get() as int

lintOptions {
Expand Down

This file was deleted.

2 changes: 2 additions & 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,8 @@ repositories {
}

android {
namespace "com.example.sqldelight"

compileSdkVersion deps.versions.compileSdk.get() as int

lintOptions {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ repositories {
}

android {
namespace "com.example.sqldelight"

compileSdkVersion deps.versions.compileSdk.get() as int

defaultConfig {
Expand Down

This file was deleted.

0 comments on commit 31e8776

Please sign in to comment.