mirror of
https://github.com/HighCapable/SweetDependency.git
synced 2025-09-04 01:35:46 +08:00
refactor: remove kotlin-gradle-api and add sweet extension to kotlin mpp
This commit is contained in:
@@ -21,9 +21,6 @@ plugins:
|
||||
version: 0.25.3
|
||||
|
||||
libraries:
|
||||
org.jetbrains.kotlin:
|
||||
kotlin-gradle-plugin-api:
|
||||
version: 1.9.10
|
||||
org.snakeyaml:
|
||||
snakeyaml-engine:
|
||||
version: 2.7
|
||||
|
@@ -22,7 +22,6 @@ kotlin {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(org.jetbrains.kotlin.kotlin.gradle.plugin.api)
|
||||
implementation(org.snakeyaml.snakeyaml.engine)
|
||||
implementation(com.charleskorn.kaml.kaml)
|
||||
implementation(com.squareup.okhttp3.okhttp)
|
||||
|
@@ -92,11 +92,12 @@ internal object DependencyManager {
|
||||
*/
|
||||
internal fun deploy(rootProject: Project) {
|
||||
/**
|
||||
* 为 Groovy 创建扩展方法
|
||||
* 为自动装配创建扩展方法
|
||||
* @param extension 当前扩展实例
|
||||
* @param isGroovyOnly 是否仅为 Groovy 创建 - 默认是
|
||||
*/
|
||||
fun Project.deployForGroovy(extension: ExtensionAware) {
|
||||
if (buildFile.name.endsWith(".gradle"))
|
||||
fun Project.deployAutowire(extension: ExtensionAware, isGroovyOnly: Boolean = true) {
|
||||
if (isGroovyOnly.not() || (isGroovyOnly && buildFile.name.endsWith(".gradle")))
|
||||
extension.getOrCreate<SweetDependencyAutowireExtension>(SweetDependencyAutowireExtension.NAME, this)
|
||||
}
|
||||
|
||||
@@ -110,14 +111,14 @@ internal object DependencyManager {
|
||||
fun Project.deployForKotlinMultiplatform() =
|
||||
waitForPluginAdded("org.jetbrains.kotlin.multiplatform") {
|
||||
get("kotlin").also { extension ->
|
||||
deployForGroovy(extension)
|
||||
deployAutowire(extension, isGroovyOnly = false)
|
||||
deployEach(extension)
|
||||
}
|
||||
}
|
||||
|
||||
/** 部署到当前项目 */
|
||||
fun Project.deploy() {
|
||||
deployForGroovy(dependencies)
|
||||
deployAutowire(dependencies)
|
||||
deployEach(dependencies)
|
||||
deployForKotlinMultiplatform()
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@ import com.highcapable.sweetdependency.manager.helper.DependencyDeployHelper
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
import org.gradle.plugin.use.PluginDependenciesSpec
|
||||
import org.gradle.plugin.use.PluginDependencySpec
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||
|
||||
/**
|
||||
* 自动装配插件依赖
|
||||
@@ -41,11 +40,4 @@ fun PluginDependenciesSpec.autowire(vararg params: Any) = DependencyDeployHelper
|
||||
* @param params 参数数组
|
||||
* @return [Any]
|
||||
*/
|
||||
fun DependencyHandler.autowire(vararg params: String) = DependencyDeployHelper.resolveAutowire(params = params)
|
||||
|
||||
/**
|
||||
* 自动装配依赖
|
||||
* @param params 参数数组
|
||||
* @return [Any]
|
||||
*/
|
||||
fun KotlinDependencyHandler.autowire(vararg params: String) = DependencyDeployHelper.resolveAutowire(project, params)
|
||||
fun DependencyHandler.autowire(vararg params: String) = DependencyDeployHelper.resolveAutowire(params = params)
|
Reference in New Issue
Block a user