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