-
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.
Browse files
Browse the repository at this point in the history
Feat/#1 convention
- Loading branch information
Showing
63 changed files
with
919 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,20 @@ | ||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
import store.newsbriefing.app.buildlogic.config.Config | ||
|
||
plugins { | ||
alias(libs.plugins.androidApplication) | ||
alias(libs.plugins.kotlinAndroid) | ||
alias(libs.plugins.briefing.android.application) | ||
alias(libs.plugins.briefing.android.application.compose) | ||
} | ||
|
||
android { | ||
namespace = "com.dev.briefing" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.dev.briefing" | ||
minSdk = 28 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.1" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
namespace = Config.android.nameSpace | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core.designsystem) | ||
|
||
implementation(libs.core.ktx) | ||
implementation(libs.lifecycle.runtime.ktx) | ||
implementation(libs.activity.compose) | ||
implementation(platform(libs.compose.bom)) | ||
implementation(libs.ui) | ||
implementation(libs.ui.graphics) | ||
implementation(libs.ui.tooling.preview) | ||
implementation(libs.material3) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.test.ext.junit) | ||
androidTestImplementation(libs.espresso.core) | ||
androidTestImplementation(platform(libs.compose.bom)) | ||
androidTestImplementation(libs.ui.test.junit4) | ||
debugImplementation(libs.ui.tooling) | ||
debugImplementation(libs.ui.test.manifest) | ||
implementation(libs.androidx.appcompat) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(libs.androidx.compose.material3) | ||
implementation(libs.androidx.compose.foundation) | ||
implementation(libs.androidx.compose.ui.tooling.preview) | ||
} |
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,54 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
group = "store.newsbriefing.app.buildlogic" | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.android.gradlePlugin) | ||
compileOnly(libs.android.tools.common) | ||
compileOnly(libs.kotlin.gradlePlugin) | ||
compileOnly(libs.ksp.gradlePlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("androidApplicationCompose") { | ||
id = "store.newsbriefing.app.buildlogic.plugin.android.application.compose" | ||
implementationClass = | ||
"store.newsbriefing.app.buildlogic.plugin.AndroidApplicationComposeConventionPlugin" | ||
} | ||
register("androidApplication") { | ||
id = "store.newsbriefing.app.buildlogic.plugin.android.application" | ||
implementationClass = | ||
"store.newsbriefing.app.buildlogic.plugin.AndroidApplicationConventionPlugin" | ||
} | ||
register("androidLibrary") { | ||
id = "store.newsbriefing.app.buildlogic.plugin.android.library" | ||
implementationClass = | ||
"store.newsbriefing.app.buildlogic.plugin.AndroidLibraryConventionPlugin" | ||
} | ||
register("androidLibraryCompose") { | ||
id = "store.newsbriefing.app.buildlogic.plugin.android.library.compose" | ||
implementationClass = | ||
"store.newsbriefing.app.buildlogic.plugin.AndroidLibraryComposeConventionPlugin" | ||
} | ||
register("androidHilt") { | ||
id = "store.newsbriefing.app.buildlogic.plugin.android.hilt" | ||
implementationClass = | ||
"store.newsbriefing.app.buildlogic.plugin.AndroidHiltConventionPlugin" | ||
} | ||
register("jvmLibrary") { | ||
id = "store.newsbriefing.app.buildlogic.plugin.jvm.library" | ||
implementationClass = | ||
"store.newsbriefing.app.buildlogic.plugin.JvmLibraryConventionPlugin" | ||
} | ||
register("androidFeature") { | ||
id = "store.newsbriefing.app.buildlogic.plugin.android.feature" | ||
implementationClass = | ||
"store.newsbriefing.app.buildlogic.plugin.AndroidFeatureConventionPlugin" | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
build-logic/convention/src/main/kotlin/store/newsbriefing/app/buildlogic/config/Config.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,34 @@ | ||
package store.newsbriefing.app.buildlogic.config | ||
|
||
import org.gradle.api.JavaVersion | ||
|
||
object Config { | ||
val android = AndroidConfig( | ||
minSdkVersion = 28, | ||
targetSdkVersion = 34, | ||
compileSdkVersion = 34, | ||
applicationId = "com.dev.briefing", | ||
versionCode = 1, | ||
versionName = "1.0", | ||
nameSpace = "com.dev.briefing" | ||
) | ||
val jvm = JvmConfig( | ||
javaVersion = JavaVersion.VERSION_18, | ||
kotlinJvm = JavaVersion.VERSION_18.toString(), | ||
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn") | ||
) | ||
} | ||
data class AndroidConfig( | ||
val minSdkVersion : Int, | ||
val targetSdkVersion : Int, | ||
val compileSdkVersion : Int, | ||
val applicationId : String, | ||
val versionCode : Int, | ||
val versionName : String, | ||
val nameSpace: String | ||
) | ||
data class JvmConfig( | ||
val javaVersion : JavaVersion, | ||
val kotlinJvm : String, | ||
val freeCompilerArgs : List<String> | ||
) |
26 changes: 26 additions & 0 deletions
26
.../convention/src/main/kotlin/store/newsbriefing/app/buildlogic/extension/AndroidCompose.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,26 @@ | ||
package store.newsbriefing.app.buildlogic.extension | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureAndroidCompose( | ||
commonExtension: CommonExtension<*, *, *, *, *>, | ||
) { | ||
commonExtension.apply { | ||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = libs.findVersion("androidxComposeCompiler").get().toString() | ||
} | ||
|
||
dependencies { | ||
val bom = libs.findLibrary("compose-bom").get() | ||
add("implementation", platform(bom)) | ||
add("implementation", platform(bom)) | ||
|
||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...c/convention/src/main/kotlin/store/newsbriefing/app/buildlogic/extension/KotlinAndroid.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,52 @@ | ||
package store.newsbriefing.app.buildlogic.extension | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.provideDelegate | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import store.newsbriefing.app.buildlogic.config.Config | ||
|
||
|
||
internal fun Project.configureKotlinAndroid( | ||
commonExtension: CommonExtension<*, *, *, *, *>, | ||
) { | ||
// android scope | ||
commonExtension.apply { | ||
compileSdk = Config.android.compileSdkVersion | ||
|
||
defaultConfig { | ||
minSdk = Config.android.minSdkVersion | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_18 | ||
targetCompatibility = JavaVersion.VERSION_18 | ||
} | ||
} | ||
|
||
configureKotlin() | ||
|
||
dependencies { | ||
} | ||
} | ||
|
||
internal fun Project.configureKotlinJvm() { | ||
extensions.configure<JavaPluginExtension> { | ||
sourceCompatibility = JavaVersion.VERSION_18 | ||
targetCompatibility = JavaVersion.VERSION_18 | ||
} | ||
configureKotlin() | ||
} | ||
|
||
private fun Project.configureKotlin() { | ||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_18.toString() | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...nvention/src/main/kotlin/store/newsbriefing/app/buildlogic/extension/ProjectExtensions.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,9 @@ | ||
package store.newsbriefing.app.buildlogic.extension | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
val Project.libs | ||
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs") |
20 changes: 20 additions & 0 deletions
20
...lin/store/newsbriefing/app/buildlogic/plugin/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,20 @@ | ||
package store.newsbriefing.app.buildlogic.plugin | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.getByType | ||
import store.newsbriefing.app.buildlogic.extension.configureAndroidCompose | ||
|
||
class AndroidApplicationComposeConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.application") | ||
|
||
val extension = extensions.getByType<ApplicationExtension>() | ||
configureAndroidCompose(extension) | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ain/kotlin/store/newsbriefing/app/buildlogic/plugin/AndroidApplicationConventionPlugin.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,37 @@ | ||
package store.newsbriefing.app.buildlogic.plugin | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import store.newsbriefing.app.buildlogic.config.Config | ||
import store.newsbriefing.app.buildlogic.extension.configureKotlinAndroid | ||
|
||
class AndroidApplicationConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.application") | ||
apply("org.jetbrains.kotlin.android") | ||
} | ||
// android | ||
extensions.configure<ApplicationExtension> { | ||
// default config | ||
defaultConfig.apply { | ||
targetSdk = Config.android.targetSdkVersion | ||
applicationId = Config.android.applicationId | ||
versionCode = Config.android.versionCode | ||
versionName = Config.android.versionName | ||
} | ||
configureKotlinAndroid(this) | ||
|
||
packaging { | ||
resources { | ||
excludes.add("/META-INF/AL2.0") | ||
excludes.add("/META-INF/LGPL2.1") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...rc/main/kotlin/store/newsbriefing/app/buildlogic/plugin/AndroidFeatureConventionPlugin.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,28 @@ | ||
package store.newsbriefing.app.buildlogic.plugin | ||
|
||
import com.android.build.gradle.LibraryExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import store.newsbriefing.app.buildlogic.extension.libs | ||
|
||
class AndroidFeatureConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply { | ||
apply("store.newsbriefing.app.buildlogic.plugin.android.library") | ||
apply("store.newsbriefing.app.buildlogic.plugin.android.hilt") | ||
} | ||
|
||
dependencies { | ||
add("implementation", project(":core:ui")) | ||
add("implementation", project(":core:designsystem")) | ||
|
||
// add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get()) | ||
// add("implementation", libs.findLibrary("androidx.lifecycle.runtimeCompose").get()) | ||
// add("implementation", libs.findLibrary("androidx.lifecycle.viewModelCompose").get()) | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...n/src/main/kotlin/store/newsbriefing/app/buildlogic/plugin/AndroidHiltConventionPlugin.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,22 @@ | ||
package store.newsbriefing.app.buildlogic.plugin | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
import store.newsbriefing.app.buildlogic.extension.libs | ||
|
||
class AndroidHiltConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.google.devtools.ksp") | ||
apply("dagger.hilt.android.plugin") | ||
} | ||
|
||
dependencies { | ||
"implementation"(libs.findLibrary("hilt.android").get()) | ||
"ksp"(libs.findLibrary("hilt.compiler").get()) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.