10 Commits
1.0.2 ... 1.0.3

36 changed files with 100 additions and 90 deletions

2
.idea/kotlinc.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="KotlinJpsPluginSettings"> <component name="KotlinJpsPluginSettings">
<option name="version" value="1.9.10" /> <option name="version" value="1.9.20" />
</component> </component>
</project> </project>

View File

@@ -10,6 +10,11 @@
[English](https://github.com/HighCapable/SweetDependency/blob/master/README.md) | 简体中文 [English](https://github.com/HighCapable/SweetDependency/blob/master/README.md) | 简体中文
| <img src="https://github.com/HighCapable/.github/blob/main/img-src/logo.jpg?raw=true" width = "30" height = "30" alt="LOGO"/> | [HighCapable](https://github.com/HighCapable) |
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
这个项目属于上述组织,**点击上方链接关注这个组织**,发现更多好项目。
## 这是什么 ## 这是什么
这是一个用来管理 Gradle 依赖的 Gradle 插件,所有依赖集中管理并自动更新,解决了每个子项目都需要手动更新到相同版本依赖的问题。 这是一个用来管理 Gradle 依赖的 Gradle 插件,所有依赖集中管理并自动更新,解决了每个子项目都需要手动更新到相同版本依赖的问题。

View File

@@ -10,6 +10,11 @@ An easy autowire and manage dependencies Gradle plugin.
English | [简体中文](https://github.com/HighCapable/SweetDependency/blob/master/README-zh-CN.md) English | [简体中文](https://github.com/HighCapable/SweetDependency/blob/master/README-zh-CN.md)
| <img src="https://github.com/HighCapable/.github/blob/main/img-src/logo.jpg?raw=true" width = "30" height = "30" alt="LOGO"/> | [HighCapable](https://github.com/HighCapable) |
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
This project belongs to the above-mentioned organization, **click the link above to follow this organization** and discover more good projects.
## What's this ## What's this
This is a Gradle plugin for managing Gradle dependencies. This is a Gradle plugin for managing Gradle dependencies.

View File

@@ -20,3 +20,10 @@
- 改进并采用 Gradle 项目命名规范 - 改进并采用 Gradle 项目命名规范
- 新增依赖命名空间可启用或禁用生成功能,更新后需要参考文档自行迁移部分配置文件的节点名称否则会发生错误 - 新增依赖命名空间可启用或禁用生成功能,更新后需要参考文档自行迁移部分配置文件的节点名称否则会发生错误
- 新增使用 `<plugins>::``<libraries>::` 可以访问其它节点的依赖名称、别名并设置到 `version-ref` 功能 - 新增使用 `<plugins>::``<libraries>::` 可以访问其它节点的依赖名称、别名并设置到 `version-ref` 功能
## 1.0.3 | 2023.11.04
- 修复从 `1.0.0` 版本开始的一个本插件与 `Kotlin` 插件的 `Class` 冲突问题
- 更换 Kotlin Multiplatform 中的配置依赖 `autowire(...)` 写法为 `sweet.autowire(...)`
- 生成的代码使用 `@Nonnull` 标记以使其能够在 Kotlin DSL 脚本中识别为非空返回值类型
- 一些其它功能性的改进

View File

@@ -23,3 +23,10 @@
- Added dependencies namespace to enable or disable the generation function, after the update, you need to refer to the documentation to migrate the - Added dependencies namespace to enable or disable the generation function, after the update, you need to refer to the documentation to migrate the
node names of some configuration files yourself, otherwise errors will occur node names of some configuration files yourself, otherwise errors will occur
- Added the function of using `<plugins>::` or `<libraries>::` to access the dependencies name and alias of other nodes and set them to `version-ref` - Added the function of using `<plugins>::` or `<libraries>::` to access the dependencies name and alias of other nodes and set them to `version-ref`
## 1.0.3 | 2023.11.04
- Fix a `Class` conflict between this plugin and the `Kotlin` plugin starting from `1.0.0` version
- Change the configuration dependency `autowire(...)` in Kotlin Multiplatform to `sweet.autowire(...)`
- Generated code is marked with `@Nonnull` to make it recognized as a non-null return type in Kotlin DSL scripts
- Some other functional improvements

View File

@@ -80,12 +80,6 @@ plugins {
上述配置完成后,运行一次 Gradle Sync。 上述配置完成后,运行一次 Gradle Sync。
**可能遇到的问题**
如果在运行 Gradle Sync 后失败并报错 `Cannot have abstract method KotlinTarget. withSourcesJar()`,这可能是你当前项目的 Kotlin 插件版本的问题。
此问题为 Kotlin 插件从 `1.8.0+``1.9.0+` 升级导致的错误,解决方案为将 Kotlin 插件的版本修改为 `1.9.0+`
**特别注意** **特别注意**
`SweetDependency` 会替换 `pluginManagement``dependencyResolutionManagement` 中设置的存储库,如果你手动在这些方法块中配置了存储库,它们都将会无效。 `SweetDependency` 会替换 `pluginManagement``dependencyResolutionManagement` 中设置的存储库,如果你手动在这些方法块中配置了存储库,它们都将会无效。
@@ -815,14 +809,16 @@ dependencies {
在 Kotlin Multiplatform 中与一般依赖部署方式一致。 在 Kotlin Multiplatform 中与一般依赖部署方式一致。
为了解决可能的插件冲突,无论是 Kotlin 还是 Groovy都需要使用 `sweet.autowire`
> Kotlin DSL > Kotlin DSL
```kotlin ```kotlin
sourceSets { sourceSets {
val androidMain by getting { val androidMain by getting {
dependencies { dependencies {
implementation(autowire("androidx.core:core-ktx")) implementation(sweet.autowire("androidx.core:core-ktx"))
implementation(autowire("libs/*.jar")) implementation(sweet.autowire("libs/*.jar"))
} }
} }
} }

View File

@@ -81,15 +81,6 @@ Please replace `<version>` in the above code with the latest version in
After the above configuration is complete, run Gradle Sync once. After the above configuration is complete, run Gradle Sync once.
**Possible Problems**
If running Gradle Sync fails with the error `Cannot have abstract method KotlinTarget. withSourcesJar()`,
this may be a problem with the Kotlin plugin version of your current project.
This problem is an error caused by upgrading the Kotlin plugin from `1.8.0+``1.9.0+`.
The solution is to modify the version of the Kotlin plugin to `1.9.0+`.
**Pay Attention** **Pay Attention**
`SweetDependency` will replace the repositories set in `pluginManagement` and `dependencyResolutionManagement`, `SweetDependency` will replace the repositories set in `pluginManagement` and `dependencyResolutionManagement`,
@@ -872,14 +863,16 @@ dependencies {
In Kotlin Multiplatform, it is consistent with the general dependency deployment method. In Kotlin Multiplatform, it is consistent with the general dependency deployment method.
To resolve possible plugin conflicts, whether Kotlin or Groovy, you need to use `sweet.autowire`.
> Kotlin DSL > Kotlin DSL
```kotlin ```kotlin
sourceSets { sourceSets {
val androidMain by getting { val androidMain by getting {
dependencies { dependencies {
implementation(autowire("androidx.core:core-ktx")) implementation(sweet.autowire("androidx.core:core-ktx"))
implementation(autowire("libs/*.jar")) implementation(sweet.autowire("libs/*.jar"))
} }
} }
} }

View File

@@ -4,7 +4,7 @@ project.description=An easy autowire and manage dependencies Gradle plugin.
project.url=https://github.com/HighCapable/SweetDependency project.url=https://github.com/HighCapable/SweetDependency
project.groupName=com.highcapable.sweetdependency project.groupName=com.highcapable.sweetdependency
project.moduleName=sweet-dependency project.moduleName=sweet-dependency
project.version=1.0.2 project.version=1.0.3
project.licence.name=Apache License 2.0 project.licence.name=Apache License 2.0
project.licence.url=https://github.com/HighCapable/SweetDependency/blob/master/LICENSE project.licence.url=https://github.com/HighCapable/SweetDependency/blob/master/LICENSE
project.developer.id="0" project.developer.id="0"

View File

@@ -12,7 +12,7 @@ repositories:
plugins: plugins:
org.jetbrains.kotlin.jvm: org.jetbrains.kotlin.jvm:
alias: kotlin-jvm alias: kotlin-jvm
version: 1.9.10 version: 1.9.20
org.jetbrains.kotlin.plugin.serialization: org.jetbrains.kotlin.plugin.serialization:
alias: kotlin-serialization alias: kotlin-serialization
version-ref: kotlin-jvm version-ref: kotlin-jvm
@@ -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
@@ -32,7 +29,7 @@ libraries:
version: 0.55.0 version: 0.55.0
com.squareup.okhttp3: com.squareup.okhttp3:
okhttp: okhttp:
version: 4.11.0 version: 4.12.0
com.squareup: com.squareup:
javapoet: javapoet:
version: 1.13.0 version: 1.13.0

View File

@@ -8,7 +8,7 @@ pluginManagement {
plugins { plugins {
// Import the SweetDependency plugin here // Import the SweetDependency plugin here
// 在这里引入 SweetDependency 插件 // 在这里引入 SweetDependency 插件
id("com.highcapable.sweetdependency") version "1.0.1" id("com.highcapable.sweetdependency") version "1.0.2"
} }
sweetDependency { sweetDependency {
configFileName = "sweet-dependency-config.yaml" configFileName = "sweet-dependency-config.yaml"

View File

@@ -8,7 +8,7 @@ pluginManagement {
plugins { plugins {
// Import the SweetDependency plugin here // Import the SweetDependency plugin here
// 在这里引入 SweetDependency 插件 // 在这里引入 SweetDependency 插件
id("com.highcapable.sweetdependency") version "1.0.1" id("com.highcapable.sweetdependency") version "1.0.2"
} }
sweetDependency { sweetDependency {
configFileName = "sweet-dependency-config.yaml" configFileName = "sweet-dependency-config.yaml"

View File

@@ -7,8 +7,8 @@ pluginManagement {
} }
} }
plugins { plugins {
id("com.highcapable.sweetdependency") version "1.0.2" id("com.highcapable.sweetdependency") version "1.0.3"
id("com.highcapable.sweetproperty") version "1.0.3" id("com.highcapable.sweetproperty") version "1.0.4"
} }
sweetDependency { sweetDependency {
isEnableVerboseMode = false isEnableVerboseMode = false

View File

@@ -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)

View File

@@ -267,7 +267,7 @@ internal data class RepositoryDocument(
}; nodeName = name }; nodeName = name
if (url.isNotBlank() && path.isNotBlank()) SError.make("There can only be one \"url\" and \"path\" parameter of \"$name\"") if (url.isNotBlank() && path.isNotBlank()) SError.make("There can only be one \"url\" and \"path\" parameter of \"$name\"")
if (path.isNotBlank() && (path.startsWith("https://") || path.startsWith("http://"))) SError.make("Invalid repository path: $path") if (path.isNotBlank() && (path.startsWith("https://") || path.startsWith("http://"))) SError.make("Invalid repository path: $path")
if (url.isNotBlank() && url.startsWith("https://").not() && url.startsWith("http://").not()) SError.make("Invalid repository URL: $url") if (url.isNotBlank() && !url.startsWith("https://") && !url.startsWith("http://")) SError.make("Invalid repository URL: $url")
if (path.isNotBlank()) path = path.parseUnixFileSeparator() if (path.isNotBlank()) path = path.parseUnixFileSeparator()
} }
} }

View File

@@ -170,7 +170,7 @@ internal data class RootConfigDocument(
artifact.alias.checkingName("$typeName \"$dependencyName\" alias", isCheckMultiName = true) artifact.alias.checkingName("$typeName \"$dependencyName\" alias", isCheckMultiName = true)
artifact.versions().forEach { (name, _) -> name.checkingName("$typeName \"$dependencyName\" version alias") } artifact.versions().forEach { (name, _) -> name.checkingName("$typeName \"$dependencyName\" version alias") }
if (artifact.alias.isNotBlank()) if (artifact.alias.isNotBlank())
if (checkDuplicateAlias.contains(artifact.alias).not()) if (!checkDuplicateAlias.contains(artifact.alias))
checkDuplicateAlias[artifact.alias] = dependencyName.current checkDuplicateAlias[artifact.alias] = dependencyName.current
else SError.make( else SError.make(
"Duplicated alias \"${artifact.alias}\", " + "Duplicated alias \"${artifact.alias}\", " +
@@ -230,7 +230,7 @@ internal data class RootConfigDocument(
if (artifact.versionRef.isNotBlank()) if (artifact.versionRef.isNotBlank())
versions()[artifact.versionRef]?.also { artifact.version = it } ?: resolveVersionRef() versions()[artifact.versionRef]?.also { artifact.version = it } ?: resolveVersionRef()
else SError.make("Missing declared version when configuring $typeName \"$dependencyName\"") else SError.make("Missing declared version when configuring $typeName \"$dependencyName\"")
else if (artifact.version().isBlank.not() && artifact.versionRef.isNotBlank() && duplicate.not()) else if (!artifact.version().isBlank && artifact.versionRef.isNotBlank() && !duplicate)
SError.make("$firstTypeName \"$dependencyName\" can only have one \"version\" or \"version-ref\" node, please delete one") SError.make("$firstTypeName \"$dependencyName\" can only have one \"version\" or \"version-ref\" node, please delete one")
} }
currentDependencies.eachDependencies { dependencyName, artifact -> currentDependencies.eachDependencies { dependencyName, artifact ->

View File

@@ -64,7 +64,7 @@ internal data class VersionFilterDocument(
* 当前是否不存在排除列表 * 当前是否不存在排除列表
* @return [Boolean] * @return [Boolean]
*/ */
internal fun isNotEmpty() = isEmpty().not() internal fun isNotEmpty() = !isEmpty()
/** /**
* 依赖于当前 [version] 提供的版本并在 [all] 中排除 (不区分大小写) * 依赖于当前 [version] 提供的版本并在 [all] 中排除 (不区分大小写)
@@ -74,7 +74,7 @@ internal data class VersionFilterDocument(
* @return [ExclusionList] * @return [ExclusionList]
*/ */
internal fun depends(version: DependencyVersion) = clone().apply { internal fun depends(version: DependencyVersion) = clone().apply {
if (version.isAutowire.not() && version.isBlank.not()) all().removeAll { version.deployed.lowercase().contains(it.lowercase()) } if (!version.isAutowire && !version.isBlank) all().removeAll { version.deployed.lowercase().contains(it.lowercase()) }
} }
/** /**

View File

@@ -158,12 +158,12 @@ internal class RootConfigDocumentMapping internal constructor(private val config
} }
} }
pluginsContents.onEachIndexed { index, content -> pluginsContents.onEachIndexed { index, content ->
if ((content.trim().startsWith(VERSION_NODE_CONTENT) && content.startsWith(SPACE_OF_4)).not()) return@onEachIndexed if (!(content.trim().startsWith(VERSION_NODE_CONTENT) && content.startsWith(SPACE_OF_4))) return@onEachIndexed
pluginsMapping[pluginsLine].versionLine = index + pluginsStartLine pluginsMapping[pluginsLine].versionLine = index + pluginsStartLine
pluginsLine++ pluginsLine++
}.clear() }.clear()
librariesContents.onEachIndexed { index, content -> librariesContents.onEachIndexed { index, content ->
if ((content.trim().startsWith(VERSION_NODE_CONTENT) && content.startsWith(SPACE_OF_6)).not()) return@onEachIndexed if (!(content.trim().startsWith(VERSION_NODE_CONTENT) && content.startsWith(SPACE_OF_6))) return@onEachIndexed
librariesMapping[librariesLine].versionLine = index + librariesStartLine librariesMapping[librariesLine].versionLine = index + librariesStartLine
librariesLine++ librariesLine++
}.clear() }.clear()

View File

@@ -42,13 +42,13 @@ internal object Environment {
* 获取 [SweetDependency] 缓存存放目录 * 获取 [SweetDependency] 缓存存放目录
* @return [File] * @return [File]
*/ */
private val memoryDir get() = "${GradleHelper.rootDir.absolutePath}/$MEMORY_DIR_PATH".toFile().also { if (it.exists().not()) it.mkdirs() } private val memoryDir get() = "${GradleHelper.rootDir.absolutePath}/$MEMORY_DIR_PATH".toFile().also { if (!it.exists()) it.mkdirs() }
/** /**
* 获取 [SweetDependency] 功能存放目录 * 获取 [SweetDependency] 功能存放目录
* @return [File] * @return [File]
*/ */
private val resourcesDir get() = "${GradleHelper.rootDir.absolutePath}/$RESOURCES_DIR_PATH".toFile().also { if (it.exists().not()) it.mkdirs() } private val resourcesDir get() = "${GradleHelper.rootDir.absolutePath}/$RESOURCES_DIR_PATH".toFile().also { if (!it.exists()) it.mkdirs() }
/** /**
* 获取系统信息 * 获取系统信息

View File

@@ -51,7 +51,7 @@ internal open class ExternalDependencyDelegate internal constructor(
override fun getVersion(): String { override fun getVersion(): String {
val notation = spliceToDependencyNotation(groupId, artifactId) val notation = spliceToDependencyNotation(groupId, artifactId)
if (version == DependencyVersion.AUTOWIRE_VERSION_NAME && GradleTaskManager.isInternalRunningTask.not()) SError.make( if (version == DependencyVersion.AUTOWIRE_VERSION_NAME && !GradleTaskManager.isInternalRunningTask) SError.make(
""" """
This library "$notation" is not autowired and cannot be deployed This library "$notation" is not autowired and cannot be deployed
You can try the following solutions to resolve this problem: You can try the following solutions to resolve this problem:

View File

@@ -54,7 +54,7 @@ internal class DependencyVersion(internal var actual: String, optionalType: Opti
if (current.startsWith("<") && current.endsWith(">")) if (current.startsWith("<") && current.endsWith(">"))
if (current != NO_SPECIFIC_VERSION_NAME && current != LATEST_VERSION_NAME) if (current != NO_SPECIFIC_VERSION_NAME && current != LATEST_VERSION_NAME)
SError.make("The parameter \"$current\" is not recognized as any available function") SError.make("The parameter \"$current\" is not recognized as any available function")
if (isOptional.not()) when (optionalType) { if (!isOptional) when (optionalType) {
OptionalUpdateType.NONE -> {} OptionalUpdateType.NONE -> {}
OptionalUpdateType.NORMAL -> actual = "$OPTIONAL_VERSION_NORMAL_PREFIX$actual" OptionalUpdateType.NORMAL -> actual = "$OPTIONAL_VERSION_NORMAL_PREFIX$actual"
OptionalUpdateType.PERMANENT -> actual = "$OPTIONAL_VERSION_PERMANENT_PREFIX$actual" OptionalUpdateType.PERMANENT -> actual = "$OPTIONAL_VERSION_PERMANENT_PREFIX$actual"
@@ -102,7 +102,7 @@ internal class DependencyVersion(internal var actual: String, optionalType: Opti
* 如果为 [isNoSpecific] 则会返回空 * 如果为 [isNoSpecific] 则会返回空
* @return [String] * @return [String]
*/ */
internal val deployed get() = current.takeIf { isNoSpecific.not() } ?: "" internal val deployed get() = current.takeIf { !isNoSpecific } ?: ""
/** /**
* 获取存在版本 * 获取存在版本

View File

@@ -38,7 +38,7 @@ import org.gradle.api.plugins.ExtensionAware
*/ */
internal fun ExtensionAware.getOrCreate(name: String, clazz: Class<*>, vararg args: Any?) = name.toSafeExtName().let { sName -> internal fun ExtensionAware.getOrCreate(name: String, clazz: Class<*>, vararg args: Any?) = name.toSafeExtName().let { sName ->
runCatching { extensions.create(sName, clazz, *args).asExtension() }.getOrElse { runCatching { extensions.create(sName, clazz, *args).asExtension() }.getOrElse {
if ((it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true).not()) throw it if (!(it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true)) throw it
runCatching { extensions.getByName(sName).asExtension() }.getOrNull() ?: SError.make("Create or get extension failed with name \"$sName\"") runCatching { extensions.getByName(sName).asExtension() }.getOrNull() ?: SError.make("Create or get extension failed with name \"$sName\"")
} }
} }
@@ -51,7 +51,7 @@ internal fun ExtensionAware.getOrCreate(name: String, clazz: Class<*>, vararg ar
*/ */
internal inline fun <reified T> ExtensionAware.getOrCreate(name: String, vararg args: Any?) = name.toSafeExtName().let { sName -> internal inline fun <reified T> ExtensionAware.getOrCreate(name: String, vararg args: Any?) = name.toSafeExtName().let { sName ->
runCatching { extensions.create(sName, T::class.java, *args) as T }.getOrElse { runCatching { extensions.create(sName, T::class.java, *args) as T }.getOrElse {
if ((it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true).not()) throw it if (!(it is IllegalArgumentException && it.message?.startsWith("Cannot add extension with name") == true)) throw it
runCatching { extensions.getByName(sName) as? T? }.getOrNull() ?: SError.make("Create or get extension failed with name \"$sName\"") runCatching { extensions.getByName(sName) as? T? }.getOrNull() ?: SError.make("Create or get extension failed with name \"$sName\"")
} }
} }

View File

@@ -64,7 +64,7 @@ internal fun Project.fullName(isUseColon: Boolean = true): String {
project.parent?.also { if (it != it.rootProject) fetchChild(it) } project.parent?.also { if (it != it.rootProject) fetchChild(it) }
baseNames.add(project.name) baseNames.add(project.name)
}; fetchChild(project = this) }; fetchChild(project = this)
return buildString { baseNames.onEach { append(":$it") }.clear() }.let { if (isUseColon && isRoot.not()) it else it.drop(1) } return buildString { baseNames.onEach { append(":$it") }.clear() }.let { if (isUseColon && !isRoot) it else it.drop(1) }
} }
/** /**
@@ -115,7 +115,7 @@ internal fun Project.libraries(isUseCache: Boolean = true) =
* @return [Boolean] * @return [Boolean]
*/ */
fun Dependency.checkingValid() = when (this) { fun Dependency.checkingValid() = when (this) {
is ExternalDependency -> group.isNullOrBlank().not() && name.isNullOrBlank().not() is ExternalDependency -> !group.isNullOrBlank() && !name.isNullOrBlank()
is FileCollectionDependency -> runCatching { files.files.isNotEmpty() }.getOrNull() ?: false is FileCollectionDependency -> runCatching { files.files.isNotEmpty() }.getOrNull() ?: false
else -> true else -> true
} }
@@ -186,5 +186,5 @@ internal fun PluginDependenciesSpec.applyPlugin(alias: Any) = when (alias) {
private fun PluginManager.findPluginId(plugin: Plugin<*>) = runCatching { private fun PluginManager.findPluginId(plugin: Plugin<*>) = runCatching {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
val pluginIds = (this as PluginManagerInternal).findPluginIdForClass(GeneratedSubclasses.unpackType(plugin) as Class<Plugin<*>>) val pluginIds = (this as PluginManagerInternal).findPluginIdForClass(GeneratedSubclasses.unpackType(plugin) as Class<Plugin<*>>)
if (pluginIds.isEmpty.not()) pluginIds.get() else null if (!pluginIds.isEmpty) pluginIds.get() else null
}.getOrNull()?.id ?: "" }.getOrNull()?.id ?: ""

View File

@@ -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 || 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()
} }
@@ -161,7 +162,7 @@ internal object DependencyManager {
var updLbrariesCount = 0 var updLbrariesCount = 0
val needUpdateDependencies = mutableMapOf<String, Pair<DependencyName, DependencyVersion>>() val needUpdateDependencies = mutableMapOf<String, Pair<DependencyName, DependencyVersion>>()
findByType { _, artifact -> findByType { _, artifact ->
artifact.version().isNoSpecific.not() && (artifact.versionRef.isBlank() && !artifact.version().isNoSpecific && (artifact.versionRef.isBlank() &&
((updateMode.updateType == DependencyUpdateMode.UpdateType.UPDATE_ALL || ((updateMode.updateType == DependencyUpdateMode.UpdateType.UPDATE_ALL ||
(updateMode.updateType == DependencyUpdateMode.UpdateType.UPDATE_OPTIONAL && (updateMode.updateType == DependencyUpdateMode.UpdateType.UPDATE_OPTIONAL &&
(artifact.version().isOptional || artifact.version().isAutowire)) || (artifact.version().isOptional || artifact.version().isAutowire)) ||
@@ -212,7 +213,7 @@ internal object DependencyManager {
if (SweetDependencyConfigs.configs.isEnableDependenciesAutowireLog) if (SweetDependencyConfigs.configs.isEnableDependenciesAutowireLog)
logIfNeeded(msg = "Autowiring logs have been automatically written to: ${DependencyAutowireLogHelper.logFile}", SLog.LINK) logIfNeeded(msg = "Autowiring logs have been automatically written to: ${DependencyAutowireLogHelper.logFile}", SLog.LINK)
SweetDependencyConfigs.documentMapping.updateDependencies(needUpdateDependencies) SweetDependencyConfigs.documentMapping.updateDependencies(needUpdateDependencies)
if (isRunningOnSync.not()) SLog.warn( if (!isRunningOnSync) SLog.warn(
""" """
**************************** NOTICE **************************** **************************** NOTICE ****************************
${needUpdateDependencies.size} dependencies (plugins: $updPluginsCount, libraries: $updLbrariesCount) has been changed ${needUpdateDependencies.size} dependencies (plugins: $updPluginsCount, libraries: $updLbrariesCount) has been changed
@@ -315,9 +316,9 @@ internal object DependencyManager {
isAutoUpdate: Boolean, isAutoUpdate: Boolean,
result: (newVersion: DependencyVersion) -> Unit result: (newVersion: DependencyVersion) -> Unit
) = when { ) = when {
currentVersion.isAutowire.not() && versions.contains(currentVersion).not() -> !currentVersion.isAutowire && !versions.contains(currentVersion) ->
SLog.warn("$positionTagName > MISSING ${dependencyName.description} version $currentVersion, available are $versions") SLog.warn("$positionTagName > MISSING ${dependencyName.description} version $currentVersion, available are $versions")
currentVersion.isAutowire.not() && alternateVersions.isNotEmpty() && alternateVersions.all { versions.contains(it) }.not() -> !currentVersion.isAutowire && alternateVersions.isNotEmpty() && !alternateVersions.all { versions.contains(it) } ->
SLog.warn("$positionTagName > MISSING ${dependencyName.description} version alias $alternateVersions, available are $versions") SLog.warn("$positionTagName > MISSING ${dependencyName.description} version alias $alternateVersions, available are $versions")
latestVersion != currentVersion -> when { latestVersion != currentVersion -> when {
currentVersion.isAutowire -> { currentVersion.isAutowire -> {

View File

@@ -90,7 +90,7 @@ internal object RepositoryManager {
document.nodeName.noBlank()?.also { docName -> this.name = docName } document.nodeName.noBlank()?.also { docName -> this.name = docName }
if (this is AuthenticationSupported && document.credentials.let { it.username.isNotBlank() || it.password.isNotBlank() }) if (this is AuthenticationSupported && document.credentials.let { it.username.isNotBlank() || it.password.isNotBlank() })
credentials { this.username = document.credentials.username; this.password = document.credentials.password } credentials { this.username = document.credentials.username; this.password = document.credentials.password }
if (document.content.isEmpty().not()) content { if (!document.content.isEmpty()) content {
/** /**
* 使用 ":" 分割字符串 * 使用 ":" 分割字符串
* @param size 期望的个数 * @param size 期望的个数

View File

@@ -85,7 +85,7 @@ internal object Dependencies {
* 当前是否不存在依赖 * 当前是否不存在依赖
* @return [Boolean] * @return [Boolean]
*/ */
internal fun isNotEmpty() = isEmpty().not() internal fun isNotEmpty() = !isEmpty()
/** /**
* 查找是否存在指定的依赖 * 查找是否存在指定的依赖

View File

@@ -59,7 +59,7 @@ internal object Repositories {
* 当前是否不存在存储库 * 当前是否不存在存储库
* @return [Boolean] * @return [Boolean]
*/ */
internal fun isNotEmpty() = isEmpty().not() internal fun isNotEmpty() = !isEmpty()
/** /**
* 生成存储库数组 * 生成存储库数组

View File

@@ -50,7 +50,7 @@ internal object DependencyAutowireLogHelper {
* @param toVersion 最终版本 * @param toVersion 最终版本
*/ */
internal fun record(dependencyName: DependencyName, fromVersion: DependencyVersion, toVersion: DependencyVersion) { internal fun record(dependencyName: DependencyName, fromVersion: DependencyVersion, toVersion: DependencyVersion) {
if (SweetDependencyConfigs.configs.isEnableDependenciesAutowireLog.not()) return if (!SweetDependencyConfigs.configs.isEnableDependenciesAutowireLog) return
val versionInfo = if (fromVersion.isAutowire) val versionInfo = if (fromVersion.isAutowire)
"autowire version \"$toVersion\"" "autowire version \"$toVersion\""
else "update version \"$fromVersion\" -> \"$toVersion\"" else "update version \"$fromVersion\" -> \"$toVersion\""

View File

@@ -141,7 +141,7 @@ internal object DependencyDeployHelper {
*/ */
internal fun resolveAccessors(rootProject: Project) { internal fun resolveAccessors(rootProject: Project) {
val librariesOption = SweetDependencyConfigs.document.preferences().dependenciesNamespace.libraries val librariesOption = SweetDependencyConfigs.document.preferences().dependenciesNamespace.libraries
if (librariesOption.isEnable.not()) { if (!librariesOption.isEnable) {
accessorsPomData.relativePomPath.toFile().takeIf { it.exists() }?.deleteRecursively() accessorsPomData.relativePomPath.toFile().takeIf { it.exists() }?.deleteRecursively()
accessorsGenerator.clearGeneratedData() accessorsGenerator.clearGeneratedData()
return return
@@ -198,7 +198,7 @@ internal object DependencyDeployHelper {
*/ */
internal fun resolveAutowire(project: Project = ProjectTransaction.current, params: Array<out String>): Any { internal fun resolveAutowire(project: Project = ProjectTransaction.current, params: Array<out String>): Any {
if (params.isEmpty()) SError.make("The autowire function need a param to resolve library") if (params.isEmpty()) SError.make("The autowire function need a param to resolve library")
return if (params[0].let { it.contains("/").not() && it.contains("\\").not() && it.startsWith("(").not() && it.endsWith(")").not() }) { return if (params[0].let { !it.contains("/") && !it.contains("\\") && !it.startsWith("(") && !it.endsWith(")") }) {
if (params.size > 2) SError.make("The autowire function currently does not support more than 2 params of external dependency") if (params.size > 2) SError.make("The autowire function currently does not support more than 2 params of external dependency")
val entry = Dependencies.findLibraries { key, value -> params[0] == key.current || params[0] == value.alias }.single() val entry = Dependencies.findLibraries { key, value -> params[0] == key.current || params[0] == value.alias }.single()
?: SError.make("Failed to resolve library \"${params[0]}\", also tried alias") ?: SError.make("Failed to resolve library \"${params[0]}\", also tried alias")
@@ -210,7 +210,7 @@ internal object DependencyDeployHelper {
params.forEach { param -> params.forEach { param ->
val relativePath = if (param.startsWith("(") && param.endsWith(")")) param.replace("(", "").replace(")", "") else param val relativePath = if (param.startsWith("(") && param.endsWith(")")) param.replace("(", "").replace(")", "") else param
it.addAll(relativePath.toAbsoluteFilePaths(project.projectDir.absolutePath).onEach { path -> it.addAll(relativePath.toAbsoluteFilePaths(project.projectDir.absolutePath).onEach { path ->
if (path.toFile().isValidZip().not()) SError.make( if (!path.toFile().isValidZip()) SError.make(
""" """
Invalid library at file path $path Invalid library at file path $path
The file collection dependency needs to be a valid zip package The file collection dependency needs to be a valid zip package

View File

@@ -70,7 +70,7 @@ internal object MavenParser {
* @return [MavenMetadata] * @return [MavenMetadata]
*/ */
private fun String.toMetadata(currentVersion: DependencyVersion) = runCatching { private fun String.toMetadata(currentVersion: DependencyVersion) = runCatching {
if ((contains("<metadata ") || contains("<metadata>")).not() || endsWith("</metadata>").not()) return@runCatching MavenMetadata() if (!(contains("<metadata ") || contains("<metadata>")) || !endsWith("</metadata>")) return@runCatching MavenMetadata()
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(InputSource(StringReader(this))).let { document -> DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(InputSource(StringReader(this))).let { document ->
val lastUpdated = document.getElementsByTagName("lastUpdated").item(0)?.textContent?.toLongOrNull() ?: 0L val lastUpdated = document.getElementsByTagName("lastUpdated").item(0)?.textContent?.toLongOrNull() ?: 0L
val versionNodeList = document.getElementsByTagName("version") val versionNodeList = document.getElementsByTagName("version")

View File

@@ -42,7 +42,7 @@ internal fun ISweetDependencyConfigs.build() = configFilePath.loadOrCreateEmpty(
*/ */
private fun String.loadOrCreateEmpty(): RootConfigDocument { private fun String.loadOrCreateEmpty(): RootConfigDocument {
toFile().apply { toFile().apply {
if (name.endsWith(".yaml").not() && name.endsWith(".yml").not()) if (!name.endsWith(".yaml") && !name.endsWith(".yml"))
SError.make("Config file name must be end with \".yaml\" or \".yml\"") SError.make("Config file name must be end with \".yaml\" or \".yml\"")
}.createTemplateFileOrNot() }.createTemplateFileOrNot()
return Yaml.loadFromFile<RootConfigDocument>(path = this) return Yaml.loadFromFile<RootConfigDocument>(path = this)
@@ -56,11 +56,11 @@ private fun File.createTemplateFileOrNot() {
} }
runCatching { runCatching {
when { when {
exists().not() && parentFile.exists().not() -> { !exists() && !parentFile.exists() -> {
parentFile.mkdirs() parentFile.mkdirs()
createTemplateFile() createTemplateFile()
} }
exists().not() -> createTemplateFile() !exists() -> createTemplateFile()
exists() && isDirectory -> SError.make("Tries to create file path is a directory") exists() && isDirectory -> SError.make("Tries to create file path is a directory")
} }
}.onFailure { SError.make("Could not automatically created config file: $absolutePath", it) } }.onFailure { SError.make("Could not automatically created config file: $absolutePath", it) }

View File

@@ -44,6 +44,7 @@ import com.squareup.javapoet.MethodSpec
import com.squareup.javapoet.TypeSpec import com.squareup.javapoet.TypeSpec
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
import javax.annotation.Nonnull
import javax.lang.model.element.Modifier import javax.lang.model.element.Modifier
/** /**
@@ -100,7 +101,7 @@ internal class LibrariesAccessorsGenerator {
*/ */
private inline fun noRepeated(vararg tags: String, block: () -> Unit) { private inline fun noRepeated(vararg tags: String, block: () -> Unit) {
val allTag = tags.joinToString("-") val allTag = tags.joinToString("-")
if (usedSuccessiveTags.contains(allTag).not()) block() if (!usedSuccessiveTags.contains(allTag)) block()
usedSuccessiveTags.add(allTag) usedSuccessiveTags.add(allTag)
} }
@@ -205,6 +206,7 @@ internal class LibrariesAccessorsGenerator {
else -> "\"$accessors\" accessors" else -> "\"$accessors\" accessors"
}; addJavadoc("Resolve the $actual") }; addJavadoc("Resolve the $actual")
}.addModifiers(Modifier.PUBLIC, Modifier.FINAL) }.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addAnnotation(Nonnull::class.java)
.returns(className.capitalized().asClassType()) .returns(className.capitalized().asClassType())
.addStatement("return ${className.uncapitalized()}") .addStatement("return ${className.uncapitalized()}")
.build() .build()
@@ -228,6 +230,7 @@ internal class LibrariesAccessorsGenerator {
MethodSpec.methodBuilder("get${alias.uppercamelcase()}") MethodSpec.methodBuilder("get${alias.uppercamelcase()}")
.addJavadoc("Resolve the \"$dependency\" version alias \"$alias\"") .addJavadoc("Resolve the \"$dependency\" version alias \"$alias\"")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL) .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addAnnotation(Nonnull::class.java)
.returns(ExternalDependencyDelegate::class.java) .returns(ExternalDependencyDelegate::class.java)
.addStatement("return ${alias.camelcase()}") .addStatement("return ${alias.camelcase()}")
.build() .build()
@@ -432,6 +435,10 @@ internal class LibrariesAccessorsGenerator {
*/ */
internal val compileStubFiles get(): List<JavaFile> { internal val compileStubFiles get(): List<JavaFile> {
val stubFiles = mutableListOf<JavaFile>() val stubFiles = mutableListOf<JavaFile>()
val nonnullFile =
TypeSpec.annotationBuilder(Nonnull::class.java.simpleName)
.addModifiers(Modifier.PUBLIC)
.build().createJavaFile(Nonnull::class.java.packageName)
val iExtensionAccessorsFile = val iExtensionAccessorsFile =
TypeSpec.interfaceBuilder(IExtensionAccessors::class.java.simpleName) TypeSpec.interfaceBuilder(IExtensionAccessors::class.java.simpleName)
.addModifiers(Modifier.PUBLIC) .addModifiers(Modifier.PUBLIC)
@@ -447,6 +454,7 @@ internal class LibrariesAccessorsGenerator {
.addParameter(String::class.java, "version") .addParameter(String::class.java, "version")
.build() .build()
).build().createJavaFile(ExternalDependencyDelegate::class.java.packageName) ).build().createJavaFile(ExternalDependencyDelegate::class.java.packageName)
stubFiles.add(nonnullFile)
stubFiles.add(iExtensionAccessorsFile) stubFiles.add(iExtensionAccessorsFile)
stubFiles.add(externalDependencyDelegateFile) stubFiles.add(externalDependencyDelegateFile)
return stubFiles return stubFiles

View File

@@ -70,7 +70,7 @@ internal object PluginUpdateHelper {
* @return [String] * @return [String]
*/ */
private fun String.findLatest() = runCatching { private fun String.findLatest() = runCatching {
if ((contains("<metadata ") || contains("<metadata>")).not() || endsWith("</metadata>").not()) return@runCatching "" if (!(contains("<metadata ") || contains("<metadata>")) || !endsWith("</metadata>")) return@runCatching ""
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(InputSource(StringReader(this))).let { document -> DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(InputSource(StringReader(this))).let { document ->
document.getElementsByTagName("latest")?.let { if (it.length > 0) it.item(0)?.textContent ?: "" else "" } document.getElementsByTagName("latest")?.let { if (it.length > 0) it.item(0)?.textContent ?: "" else "" }
} }

View File

@@ -63,7 +63,7 @@ internal class SweetDependencyExtensionImpl : BaseExtensionImpl() {
""".trimIndent(), noTag = true """.trimIndent(), noTag = true
) )
} }
if (GradleHelper.version.let { it.startsWith("7.") || it.startsWith("8.") }.not()) SError.make( if (GradleHelper.version.let { it.startsWith("7.") || !it.startsWith("8.") }) SError.make(
"${SweetDependency.TAG} ${SweetDependency.VERSION} " + "${SweetDependency.TAG} ${SweetDependency.VERSION} " +
"does not support Gradle ${GradleHelper.version}, please update Gradle or plugin version" "does not support Gradle ${GradleHelper.version}, please update Gradle or plugin version"
) )
@@ -91,7 +91,7 @@ internal class SweetDependencyExtensionImpl : BaseExtensionImpl() {
*/ */
private fun configureProject(configs: ISweetDependencyConfigs) { private fun configureProject(configs: ISweetDependencyConfigs) {
SLog.isVerboseMode = configs.isEnableVerboseMode SLog.isVerboseMode = configs.isEnableVerboseMode
if (isPluginLoaded.not() || GradleHelper.isSyncMode.not()) SLog.verbose(SweetDependency.bannerContent, noTag = true) if (!isPluginLoaded || !GradleHelper.isSyncMode) SLog.verbose(SweetDependency.bannerContent, noTag = true)
if (isPluginLoaded) return if (isPluginLoaded) return
isPluginLoaded = true isPluginLoaded = true
SLog.verbose("Welcome to ${SweetDependency.TAG} ${SweetDependency.VERSION}! Using Gradle ${GradleHelper.version}") SLog.verbose("Welcome to ${SweetDependency.TAG} ${SweetDependency.VERSION}! Using Gradle ${GradleHelper.version}")

View File

@@ -56,7 +56,7 @@ internal fun String.parseUnixFileSeparator() = replace("\\", "/")
*/ */
internal fun String.toRelativeFilePath(basePath: String, rootPath: String = "") = internal fun String.toRelativeFilePath(basePath: String, rootPath: String = "") =
parseFileSeparator().runCatching { parseFileSeparator().runCatching {
if (rootPath.isNotBlank() && contains(rootPath).not()) return this if (rootPath.isNotBlank() && !contains(rootPath)) return this
return Paths.get(basePath).relativize(Paths.get(this)).toString() return Paths.get(basePath).relativize(Paths.get(this)).toString()
}.getOrNull() ?: parseFileSeparator() }.getOrNull() ?: parseFileSeparator()
@@ -107,8 +107,8 @@ internal fun String.toAbsoluteFilePaths(basePath: String) =
* @return [Boolean] * @return [Boolean]
*/ */
internal fun File.isValidZip(): Boolean { internal fun File.isValidZip(): Boolean {
if (isFile.not()) return true if (!isFile) return true
if (exists().not()) return false if (!exists()) return false
return runCatching { ZipFile(this).use {}; true }.getOrNull() ?: false return runCatching { ZipFile(this).use {}; true }.getOrNull() ?: false
} }
@@ -119,7 +119,7 @@ internal fun File.isValidZip(): Boolean {
* - 如果文件不存在 - 返回 true * - 如果文件不存在 - 返回 true
* @return [Boolean] * @return [Boolean]
*/ */
internal fun File.isEmpty() = exists().not() || isDirectory.not() || listFiles().isNullOrEmpty() internal fun File.isEmpty() = !exists() || !isDirectory || listFiles().isNullOrEmpty()
/** 删除目录下的空子目录 */ /** 删除目录下的空子目录 */
internal fun File.deleteEmptyRecursively() { internal fun File.deleteEmptyRecursively() {

View File

@@ -60,7 +60,7 @@ internal object CodeCompiler {
if (files.isEmpty()) { if (files.isEmpty()) {
if (outputDir.exists()) outputDir.deleteRecursively() if (outputDir.exists()) outputDir.deleteRecursively()
return return
} else outputDir.also { if (it.exists().not()) it.mkdirs() } } else outputDir.also { if (!it.exists()) it.mkdirs() }
val outputBuildDir = "$outputDirPath/build".toFile().also { if (it.exists()) it.deleteRecursively(); it.mkdirs() } val outputBuildDir = "$outputDirPath/build".toFile().also { if (it.exists()) it.deleteRecursively(); it.mkdirs() }
val outputClassesDir = "${outputBuildDir.absolutePath}/classes".toFile().apply { mkdirs() } val outputClassesDir = "${outputBuildDir.absolutePath}/classes".toFile().apply { mkdirs() }
val outputSourcesDir = "${outputBuildDir.absolutePath}/sources".toFile().apply { mkdirs() } val outputSourcesDir = "${outputBuildDir.absolutePath}/sources".toFile().apply { mkdirs() }
@@ -100,7 +100,7 @@ internal object CodeCompiler {
* @param sourcesDir 编译源码目录 * @param sourcesDir 编译源码目录
*/ */
private fun createJarAndPom(pomData: MavenPomData, outputDir: File, buildDir: File, classesDir: File, sourcesDir: File) { private fun createJarAndPom(pomData: MavenPomData, outputDir: File, buildDir: File, classesDir: File, sourcesDir: File) {
val pomDir = outputDir.resolve(pomData.relativePomPath).also { if (it.exists().not()) it.mkdirs() } val pomDir = outputDir.resolve(pomData.relativePomPath).also { if (!it.exists()) it.mkdirs() }
packageToJar(classesDir, pomDir, pomData, isSourcesJar = false) packageToJar(classesDir, pomDir, pomData, isSourcesJar = false)
packageToJar(sourcesDir, pomDir, pomData, isSourcesJar = true) packageToJar(sourcesDir, pomDir, pomData, isSourcesJar = true)
writePom(pomDir, pomData) writePom(pomDir, pomData)
@@ -160,7 +160,7 @@ internal object CodeCompiler {
* @throws SweetDependencyUnresolvedException 如果编译输出目录不存在 * @throws SweetDependencyUnresolvedException 如果编译输出目录不存在
*/ */
private fun packageToJar(buildDir: File, outputDir: File, pomData: MavenPomData, isSourcesJar: Boolean) { private fun packageToJar(buildDir: File, outputDir: File, pomData: MavenPomData, isSourcesJar: Boolean) {
if (buildDir.exists().not()) SError.make("Jar file output path not found: ${buildDir.absolutePath}") if (!buildDir.exists()) SError.make("Jar file output path not found: ${buildDir.absolutePath}")
val jarFile = outputDir.resolve("${pomData.artifactId}-${pomData.version}${if (isSourcesJar) "-sources" else ""}.jar") val jarFile = outputDir.resolve("${pomData.artifactId}-${pomData.version}${if (isSourcesJar) "-sources" else ""}.jar")
if (jarFile.exists()) jarFile.delete() if (jarFile.exists()) jarFile.delete()
ZipFile(jarFile).addFolder(buildDir, ZipParameters().apply { isIncludeRootFolder = false }) ZipFile(jarFile).addFolder(buildDir, ZipParameters().apply { isIncludeRootFolder = false })

View File

@@ -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
/** /**
* 自动装配插件依赖 * 自动装配插件依赖
@@ -42,10 +41,3 @@ fun PluginDependenciesSpec.autowire(vararg params: Any) = DependencyDeployHelper
* @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)