-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
15 changed files
with
208 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.android.gradle.plugin) | ||
compileOnly(libs.kotlin.gradle.plugin) | ||
compileOnly(libs.detekt) | ||
compileOnly(libs.detekt.formatting) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("library") { | ||
id = "com.feedflow.library" | ||
implementationClass = "KmpLibraryConventionPlugin" | ||
} | ||
register("detekt") { | ||
id = "com.feedflow.detekt" | ||
implementationClass = "DetektConventionPlugin" | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
build-logic/convention/src/main/kotlin/DetektConventionPlugin.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,43 @@ | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension.Companion.DEFAULT_SRC_DIR_JAVA | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension.Companion.DEFAULT_SRC_DIR_KOTLIN | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension.Companion.DEFAULT_TEST_SRC_DIR_JAVA | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension.Companion.DEFAULT_TEST_SRC_DIR_KOTLIN | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class DetektConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("io.gitlab.arturbosch.detekt") | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
extensions.configure<DetektExtension> { | ||
config.setFrom("$rootDir/build-config/detekt-config.yml") | ||
parallel = true | ||
|
||
source.setFrom( | ||
files( | ||
"src", | ||
DEFAULT_SRC_DIR_JAVA, | ||
DEFAULT_TEST_SRC_DIR_JAVA, | ||
DEFAULT_SRC_DIR_KOTLIN, | ||
DEFAULT_TEST_SRC_DIR_KOTLIN, | ||
), | ||
) | ||
|
||
dependencies { | ||
add("detektPlugins", libs.findLibrary("detekt-formatting").get()) | ||
add("detektPlugins", libs.findLibrary("detekt-compose-rules").get()) | ||
} | ||
} | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
build-logic/convention/src/main/kotlin/KmpLibraryConventionPlugin.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,60 @@ | ||
import com.android.build.gradle.LibraryExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
||
class KmpLibraryConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.library") | ||
apply("org.jetbrains.kotlin.multiplatform") | ||
apply("com.feedflow.detekt") | ||
} | ||
configure<KotlinMultiplatformExtension> { | ||
androidTarget { | ||
compilations.all { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
} | ||
} | ||
} | ||
|
||
jvmToolchain(17) | ||
|
||
jvm() | ||
|
||
iosArm64() | ||
iosSimulatorArm64() | ||
|
||
@OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
compilerOptions { | ||
freeCompilerArgs.add("-Xexpect-actual-classes") | ||
} | ||
} | ||
|
||
configure<LibraryExtension> { | ||
compileSdk = version("android-compile-sdk").toInt() | ||
defaultConfig { | ||
minSdk = version("android-min-sdk").toInt() | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Project.version(key: String): String = extensions | ||
.getByType<VersionCatalogsExtension>() | ||
.named("libs") | ||
.findVersion(key) | ||
.get() | ||
.requiredVersion | ||
} |
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,14 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic" | ||
include(":convention") |
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
File renamed without changes.
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
Oops, something went wrong.