-
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.
Merge pull request #6 from boranfrkn/ConventionPluginExtensions
created extensions for convention plugins
- Loading branch information
Showing
3 changed files
with
41 additions
and
15 deletions.
There are no files selected for viewing
33 changes: 28 additions & 5 deletions
33
build-logic/src/main/java/com/furkanboran/build_logic/Extensions.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 |
---|---|---|
@@ -1,14 +1,37 @@ | ||
package com.furkanboran.build_logic | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.MinimalExternalModuleDependency | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.api.plugins.ExtensionAware | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.jetbrains.kotlin.gradle.plugin.KaptExtension | ||
|
||
val Project.libs | ||
private val Project.libs | ||
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
fun Project.kapt(block: KaptExtension.() -> Unit): Unit = | ||
(this as ExtensionAware).extensions.configure("kapt", block) | ||
private fun Project.findLibrary(libName: String): Provider<MinimalExternalModuleDependency> { | ||
return libs.findLibrary(libName).get() | ||
} | ||
|
||
fun Project.addImplementation(libName: String) { | ||
dependencies.add("implementation", findLibrary(libName)) | ||
} | ||
|
||
fun Project.addDebugImplementation(libName: String) { | ||
dependencies.add("debugImplementation", findLibrary(libName)) | ||
} | ||
|
||
fun Project.addKaptImplementation(libName: String) { | ||
dependencies.add("kapt", findLibrary(libName)) | ||
} | ||
|
||
fun Project.addPlatformImplementation(libName: String) { | ||
dependencies { | ||
dependencies.add( | ||
"implementation", | ||
platform(findLibrary(libName)) | ||
) | ||
} | ||
} |
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
7 changes: 4 additions & 3 deletions
7
build-logic/src/main/java/com/furkanboran/build_logic/hilt-convention.gradle.kts
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,10 +1,11 @@ | ||
import com.furkanboran.build_logic.libs | ||
import com.furkanboran.build_logic.addImplementation | ||
import com.furkanboran.build_logic.addKaptImplementation | ||
|
||
plugins { | ||
kotlin("kapt") | ||
} | ||
|
||
dependencies { | ||
add("implementation", libs.findLibrary("hiltAndroid").get()) | ||
add("kapt", libs.findLibrary("hiltCompiler").get()) | ||
addImplementation("hiltAndroid") | ||
addKaptImplementation("hiltCompiler") | ||
} |