-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
142 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
build-logic/convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
/** | ||
* Android application compose convention plugin | ||
* | ||
* If compose is required, then: | ||
* ``` | ||
* plugins { | ||
* id("com.android.application.compose") | ||
* } | ||
* ``` | ||
* | ||
* If not required: | ||
* ``` | ||
* plugins { | ||
* id("com.android.application") | ||
* } | ||
* ``` | ||
* | ||
* @constructor Create empty Android application compose convention plugin | ||
*/ | ||
class AndroidApplicationComposeConventionPlugin : BasePlugin() { | ||
override fun apply(target: Project) { | ||
log("apply target: ${target.displayName}") | ||
with(target) { | ||
if (!plugins.hasPlugin("com.android.application")) { | ||
pluginManager.apply("com.android.application") | ||
} | ||
extensions.getByType<BaseAppModuleExtension>().apply { | ||
configureAndroidCompose(this) | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
build-logic/convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import com.android.build.gradle.LibraryExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
/** | ||
* Android library compose convention plugin | ||
* | ||
* If compose is required, then: | ||
* ``` | ||
* plugins { | ||
* id("com.android.library.compose") | ||
* } | ||
* ``` | ||
* | ||
* If not required: | ||
* ``` | ||
* plugins { | ||
* id("com.android.library") | ||
* } | ||
* ``` | ||
* | ||
* @constructor Create empty Android library compose convention plugin | ||
*/ | ||
class AndroidLibraryComposeConventionPlugin : BasePlugin() { | ||
override fun apply(target: Project) { | ||
log("apply target: ${target.displayName}") | ||
with(target) { | ||
if (!plugins.hasPlugin("com.android.library")) { | ||
pluginManager.apply("com.android.library") | ||
} | ||
extensions.getByType<LibraryExtension>().apply { | ||
configureAndroidCompose(this) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import com.android.build.api.dsl.CommonExtension | ||
import com.android.build.api.dsl.Lint | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.PluginContainer | ||
import org.gradle.kotlin.dsl.configure | ||
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension | ||
|
||
internal fun Project.lintConfigure(): Lint.() -> Unit = { | ||
abortOnError = true | ||
warningsAsErrors = false | ||
ignoreTestSources = true | ||
checkDependencies = true | ||
checkReleaseBuilds = false // Full lint runs as part of 'build' task. | ||
htmlReport = true | ||
// baseline = rootProject.file("lint-config/lint-baseline.xml") | ||
// lintConfig = rootProject.file("lint-config/lint-default.xml") | ||
} | ||
|
||
internal fun PluginContainer.hasKotlinComposePlugin() = hasPlugin("org.jetbrains.kotlin.plugin.compose") | ||
|
||
/** | ||
* Configure Compose-specific options | ||
* | ||
* @param commonExtension | ||
* @param hasRedwood Is Redwood used? | ||
*/ | ||
fun Project.configureAndroidCompose( | ||
commonExtension: CommonExtension<*, *, *, *, *>, | ||
hasRedwood: Boolean = true | ||
) { | ||
if (!plugins.hasKotlinComposePlugin()) { | ||
pluginManager.apply("org.jetbrains.kotlin.plugin.compose") | ||
} | ||
|
||
commonExtension.apply { | ||
if (!hasRedwood) { | ||
// If you are using Redwood, you do not need to set this parameter. | ||
buildFeatures.compose = true | ||
} | ||
} | ||
|
||
extensions.configure<ComposeCompilerGradlePluginExtension> { | ||
enableStrongSkippingMode.set(true) | ||
reportsDestination.set(layout.buildDirectory.dir("compose_compiler")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters