50 Commits
1.0.0 ... 1.0.4

Author SHA1 Message Date
10e3915197 Bump version to 1.0.4 2023-11-14 00:32:47 +08:00
70aa40a5b1 docs: update guide 2023-11-14 00:22:52 +08:00
86e06bab69 feat: add dependencies autowire debug info 2023-11-14 00:22:46 +08:00
f0331ffee7 feat: update runtime debug info 2023-11-13 23:15:02 +08:00
6ff5801cb7 docs: update guide 2023-11-13 22:52:15 +08:00
d697a59c26 feat: add enable or disable dependencyResolutionManagement function 2023-11-13 22:52:07 +08:00
d896554421 chore: bump "com.highcapable.sweetproperty" version to 1.0.5 2023-11-08 15:06:07 +08:00
68dfdbf648 chore: update samples 2023-11-04 03:00:35 +08:00
2f47d72904 Bump version to 1.0.3 2023-11-04 02:19:14 +08:00
9b1b1050cf chore: update project files 2023-11-04 02:18:52 +08:00
49a9a70df3 chore: bump "com.highcapable.sweetproperty" version to 1.0.4 2023-11-04 02:18:30 +08:00
3304a1afef feat: use @Nonnull better for Kotlin code 2023-11-03 23:10:39 +08:00
111312463e chore: update dependencies 2023-11-03 22:37:03 +08:00
6963f1ca36 docs: update guide 2023-11-03 22:35:15 +08:00
609cbe644d refactor: replace not to ! 2023-11-03 22:27:18 +08:00
5d3642c1a3 refactor: remove kotlin-gradle-api and add sweet extension to kotlin mpp 2023-11-03 22:16:48 +08:00
7071951aa5 chore: update promotion 2023-10-24 22:22:23 +08:00
5dd68af7b5 chore: update samples 2023-09-26 08:46:10 +08:00
f92dcfa446 Bump version to 1.0.2 2023-09-26 08:35:44 +08:00
222ea51ac7 chore: bump "com.highcapable.sweetproperty" version to 1.0.3 2023-09-26 08:28:17 +08:00
2e298071d3 refactor: standardize Gradle project naming 2023-09-26 06:33:46 +08:00
87928e9af6 docs: update guide 2023-09-26 05:29:26 +08:00
fb5727fec7 feat: add dependencies version ref scope reference function 2023-09-26 05:29:10 +08:00
6627e99564 style: fix comment 2023-09-26 04:30:38 +08:00
7fe824bab5 fix: Gradle lifecycle problem 2023-09-26 04:29:57 +08:00
46683cfb2e feat: replace "/" to "or" 2023-09-26 04:28:11 +08:00
586499c4f4 docs: update guide 2023-09-26 04:13:33 +08:00
78527bb302 feat: add enable / disable auto generate dependencies namespace function 2023-09-26 04:13:07 +08:00
f767fb6694 fix: checking update function 2023-09-26 03:40:37 +08:00
f2949d9039 fix: constructor maybe not first statement every time 2023-09-26 02:05:03 +08:00
43c7c35309 refactor: unconditionally to output the sources even got an error 2023-09-26 01:59:54 +08:00
4e18f9f011 style: rename examples to samples 2023-09-21 00:20:08 +08:00
15282cb16d docs: fix description 2023-09-16 00:28:31 +08:00
afe30a9ec1 docs: fix code comment 2023-09-14 05:43:39 +08:00
800d97dace docs: update comments 2023-09-12 13:55:03 +08:00
9209be3ea0 chore: optimize SweetProperty configs 2023-09-08 13:13:22 +08:00
fab9eee279 docs: update readme zh-cn 2023-09-08 12:22:40 +08:00
2b81ae41b2 Bump version to 1.0.1 2023-09-07 01:46:46 +08:00
c44dc6f4c3 chore: update samples 2023-09-07 01:38:42 +08:00
a56d2ed895 fix: legacy Gradle maybe crashed when using "excludeGroupAndSubgroups" and "includeGroupAndSubgroups" 2023-09-07 01:09:47 +08:00
301283a1d0 chore: bump "com.highcapable.sweetproperty" version to 1.0.2 2023-09-07 00:40:00 +08:00
710a597454 docs: update guide 2023-09-06 21:36:47 +08:00
e9a71f29ef refactor: using fixed version for plugins deployed and disallowed non-autowire version deployed 2023-09-06 20:20:38 +08:00
a6770e3e03 fix: project url wrong 2023-09-06 20:12:29 +08:00
6fedc9ef50 refactor: using new way to checking load build script class exists 2023-09-06 19:33:17 +08:00
ff0ae7f0ab refactor: using relative pom path to resolve generated dependencies jar 2023-09-06 19:32:00 +08:00
a2ca412ec9 refactor: replace packaging jar method using "net.lingala.zip4j" 2023-09-06 02:26:41 +08:00
7e419b758f chore: bump "com.highcapable.sweetproperty" version to 1.0.1 2023-09-04 02:42:09 +08:00
9b014cdb77 docs: add readme badge link 2023-09-04 01:05:44 +08:00
de339a49f6 docs: update readme badge 2023-09-04 00:58:47 +08:00
145 changed files with 819 additions and 441 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

@@ -1,8 +1,8 @@
# Sweet Dependency # Sweet Dependency
[![Blank](https://img.shields.io/badge/license-Apache2.0-blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE) [![GitHub license](https://img.shields.io/github/license/HighCapable/SweetDependency?color=blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE)
![Blank](https://img.shields.io/badge/version-v1.0.0-green) [![GitHub release](https://img.shields.io/github/v/release/HighCapable/SweetDependency?display_name=release&logo=github&color=green)](https://github.com/HighCapable/SweetDependency/releases)
[![Telegram](https://img.shields.io/badge/Discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev) [![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev)
<img src="https://github.com/HighCapable/SweetDependency/blob/master/img-src/icon.png?raw=true" width = "100" height = "100" alt="LOGO"/> <img src="https://github.com/HighCapable/SweetDependency/blob/master/img-src/icon.png?raw=true" width = "100" height = "100" alt="LOGO"/>
@@ -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 插件,所有依赖集中管理并自动更新,解决了每个子项目都需要手动更新到相同版本依赖的问题。
@@ -64,6 +69,12 @@
本项目同样使用了 **SweetProperty** 本项目同样使用了 **SweetProperty**
## 捐赠支持
工作不易,无意外情况此项目将继续维护下去,提供更多可能,欢迎打赏。
<img src="https://github.com/fankes/fankes/blob/main/img-src/payment_code.jpg?raw=true" width = "500" alt="Payment Code"/>
## Star History ## Star History
![Star History Chart](https://api.star-history.com/svg?repos=HighCapable/SweetDependency&type=Date) ![Star History Chart](https://api.star-history.com/svg?repos=HighCapable/SweetDependency&type=Date)

View File

@@ -1,8 +1,8 @@
# Sweet Dependency # Sweet Dependency
[![Blank](https://img.shields.io/badge/license-Apache2.0-blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE) [![GitHub license](https://img.shields.io/github/license/HighCapable/SweetDependency?color=blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE)
![Blank](https://img.shields.io/badge/version-v1.0.0-green) [![GitHub release](https://img.shields.io/github/v/release/HighCapable/SweetDependency?display_name=release&logo=github&color=green)](https://github.com/HighCapable/SweetDependency/releases)
[![Telegram](https://img.shields.io/badge/Discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev) [![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev)
<img src="https://github.com/HighCapable/SweetDependency/blob/master/img-src/icon.png?raw=true" width = "100" height = "100" alt="LOGO"/> <img src="https://github.com/HighCapable/SweetDependency/blob/master/img-src/icon.png?raw=true" width = "100" height = "100" alt="LOGO"/>
@@ -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

@@ -3,3 +3,33 @@
## 1.0.0 | 2023.09.03 ## 1.0.0 | 2023.09.03
- 首个版本提交至 Maven - 首个版本提交至 Maven
## 1.0.1 | 2023.09.07
- 使用 `net.lingala.zip4j` 取代 JDK 默认创建压缩文档功能修复在 Windows 平台中 Gradle 8.0.2+ 版本创建的 JAR 损坏导致找不到生成的 Class 问题
- 重构自动生成代码部分的装载功能,增加可能找不到 Class 的错误提示
- 新增在设置了未定义版本的插件依赖条件下直接运行自动装配相关 Gradle Task 将抛出异常
- 修复可能的旧版本 Gradle 在使用 `repositories``content` 功能会抛出异常
## 1.0.2 | 2023.09.26
- 自动生成代码功能将始终输出源码文件,以方便在生成失败的时候进行调试
- 修复部分连续名称的依赖可能导致生成失败的问题
- 修复插件自身检查更新功能失效
- 修复 Gradle 生命周期问题,可能导致 `autowire` 方法的项目作用域不正确
- 改进并采用 Gradle 项目命名规范
- 新增依赖命名空间可启用或禁用生成功能,更新后需要参考文档自行迁移部分配置文件的节点名称否则会发生错误
- 新增使用 `<plugins>::``<libraries>::` 可以访问其它节点的依赖名称、别名并设置到 `version-ref` 功能
## 1.0.3 | 2023.11.04
- 修复从 `1.0.0` 版本开始的一个本插件与 `Kotlin` 插件的 `Class` 冲突问题
- 更换 Kotlin Multiplatform 中的配置依赖 `autowire(...)` 写法为 `sweet.autowire(...)`
- 生成的代码使用 `@Nonnull` 标记以使其能够在 Kotlin DSL 脚本中识别为非空返回值类型
- 一些其它功能性的改进
## 1.0.4 | 2023.11.14
- 新增 `isUseDependencyResolutionManagement` 选项,默认启用,现在你可以选择是否允许插件使用 `dependencyResolutionManagement` 配置库依赖
- 新增 `isDebug` 选项,默认不启用,你可以启用此选项来在自动装配时输出详细的依赖搜索信息
- 一些其它功能性的改进

View File

@@ -3,3 +3,37 @@
## 1.0.0 | 2023.09.03 ## 1.0.0 | 2023.09.03
- The first version is submitted to Maven - The first version is submitted to Maven
## 1.0.1 | 2023.09.07
- Use `net.lingala.zip4j` to replace JDK's default function of creating compressed files and fix the problem that the JAR created by Gradle 8.0.2+
version on Windows platform is broken and the generated classes cannot be found
- Refactor the loading function of the automatically generated code part, and add an error message that classes may not be found
- Added an exception will be thrown when running the autowire related Gradle task directly
under the condition of setting an undefined version of plugins
- Fix possible old version of Gradle throwing exception when using `content` function of `repositories`
## 1.0.2 | 2023.09.26
- The automatic code generation function will always output source code files to facilitate debugging when the generation fails
- Fix dependencies with some consecutive names may cause generation failure
- Fix plugin own update function
- Fix Gradle lifecycle problem that may cause the project scope of the `autowire` method to be incorrect
- Improve and adopt Gradle project naming convention
- 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
- 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
## 1.0.4 | 2023.11.14
- Added `isUseDependencyResolutionManagement` option, enabled by default, now you can choose whether to allow plugins to
use `dependencyResolutionManagement` to configure library dependencies
- Added `isDebug` option, not enabled by default, you can enable this option to output detailed dependency search information during autowiring
- Some other functional improvements

View File

@@ -2,7 +2,7 @@
在开始使用之前,建议你仔细阅读此文档,以便你能更好地了解它的作用方式与功能。 在开始使用之前,建议你仔细阅读此文档,以便你能更好地了解它的作用方式与功能。
你可以在项目的根目录找到 examples 中的 Demo并参考此文档食用效果更佳。 你可以在项目的根目录找到 samples 中的 Demo并参考此文档食用效果更佳。
## 工作原理 ## 工作原理
@@ -31,6 +31,9 @@
如果你的项目依然在使用 `buildscript` 的方式进行管理,请迁移到新方式,否则会发生错误。 如果你的项目依然在使用 `buildscript` 的方式进行管理,请迁移到新方式,否则会发生错误。
如果你的项目不能使用 `dependencyResolutionManagement` 进行管理,你可以参考此页面最下方的 [自定义选项](#自定义选项)
通过配置 `isUseDependencyResolutionManagement = false` 来使用传统的库依赖管理方式。
## 快速开始 ## 快速开始
首先,打开你根项目的 `settings.gradle``settings.gradle.kts` 首先,打开你根项目的 `settings.gradle``settings.gradle.kts`
@@ -151,11 +154,19 @@ preferences:
# 没有命名空间implementation(com.mydemo.test.test) # 没有命名空间implementation(com.mydemo.test.test)
# 存在命名空间implementation(libs.com.mydemo.test.test) # 存在命名空间implementation(libs.com.mydemo.test.test)
dependencies-namespace: dependencies-namespace:
plugins:
# 如果你希望关闭自动生成,可以设置为 false
# 在决定关闭时请确保构建脚本中已不存在自动生成的代码,防止发生错误
enable: true
# 插件依赖必须存在命名空间,如果不设置,其默认为 "libs" # 插件依赖必须存在命名空间,如果不设置,其默认为 "libs"
plugins: libs name: libs
libraries:
# 如果你希望关闭自动生成,可以设置为 false
# 在决定关闭时请确保构建脚本中已不存在自动生成的代码,防止发生错误
enable: true
# 库依赖的命名空间可选 # 库依赖的命名空间可选
# 如果你不需要库依赖的命名空间,请删除此节点 # 如果你不需要库依赖的命名空间,请删除此节点
libraries: libs name: libs
# 依赖版本过滤器 # 依赖版本过滤器
# 如果你需要排除一些不希望被更新到的依赖版本 (例如测试版本) 可以手动进行配置 # 如果你需要排除一些不希望被更新到的依赖版本 (例如测试版本) 可以手动进行配置
# 默认情况下过滤器已帮你自动排除测试版本,无需对此项进行配置 # 默认情况下过滤器已帮你自动排除测试版本,无需对此项进行配置
@@ -332,6 +343,9 @@ plugins:
org.jetbrains.kotlin.android: org.jetbrains.kotlin.android:
alias: kotlin-android alias: kotlin-android
version: 1.8.10 version: 1.8.10
com.google.devtools.ksp:
alias: kotlin-ksp
version: 1.8.10-1.0.9
# 配置需要使用的库依赖 # 配置需要使用的库依赖
libraries: libraries:
@@ -375,6 +389,12 @@ libraries:
# 注意:如果你声明了 "version-ref",此依赖将在自动装配和更新中被排除 # 注意:如果你声明了 "version-ref",此依赖将在自动装配和更新中被排除
# 注意:如果你声明了 "version-ref""auto-update"、"repositories"、"version-filter" 将无效 # 注意:如果你声明了 "version-ref""auto-update"、"repositories"、"version-filter" 将无效
version-ref: <this>::core # 或 "androidx.core:core" 以及 "androidx-core" (别名) version-ref: <this>::core # 或 "androidx.core:core" 以及 "androidx-core" (别名)
com.google.devtools.ksp:
symbol-processing-api:
# 如果你想引用一个不属于当前作用域 ("libraries") 的依赖或别名,你需要声明其所属的作用域
# 例如引用 "plugins" 作用域中的依赖别名 "kotlin-ksp",你需要使用 "<plugins>::" 作为开头进行声明
# 同理,在 "plugins" 作用域中需要使用 "<libraries>::" 作为开头进行声明
version-ref: <plugins>::kotlin-ksp # 或 "<plugins>::com.google.devtools.ksp"
com.squareup.okhttp3: com.squareup.okhttp3:
okhttp: okhttp:
# 如果你在版本中声明了一个 "version-filter" 中存在的版本 (内置过滤器或排除列表) # 如果你在版本中声明了一个 "version-filter" 中存在的版本 (内置过滤器或排除列表)
@@ -792,14 +812,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"))
} }
} }
} }
@@ -1127,9 +1149,18 @@ sweetDependency {
// 启用 SweetDependency设置为 false 将禁用所有功能 // 启用 SweetDependency设置为 false 将禁用所有功能
isEnable = true isEnable = true
// 是否启用调试模式
// 默认不启用,启用后将在自动装配时输出详细的依赖搜索信息
isDebug = false
// SweetDependency 配置文件名称 // SweetDependency 配置文件名称
configFileName = "sweet-dependency-config.yaml" configFileName = "sweet-dependency-config.yaml"
// 是否使用 Settings.dependencyResolutionManagement 管理库依赖
// 此功能默认启用,如果你的项目必须存在自定义的 "repositories" 方法块,请关闭此功能
// 注意:关闭后配置文件中的 "repositories-mode" 选项将不再有效
isUseDependencyResolutionManagement = true
// 是否启用依赖自动装配日志 // 是否启用依赖自动装配日志
// 此功能默认启用,会在当前根项目 (Root Project) 的 ".gradle/sweet-dependency" 目录下创建日志文件 // 此功能默认启用,会在当前根项目 (Root Project) 的 ".gradle/sweet-dependency" 目录下创建日志文件
isEnableDependenciesAutowireLog = true isEnableDependenciesAutowireLog = true
@@ -1145,7 +1176,9 @@ sweetDependency {
```groovy ```groovy
sweetDependency { sweetDependency {
enable true enable true
debug false
configFileName 'sweet-dependency-config.yaml' configFileName 'sweet-dependency-config.yaml'
useDependencyResolutionManagement true
enableDependenciesAutowireLog true enableDependenciesAutowireLog true
enableVerboseMode true enableVerboseMode true
} }

View File

@@ -2,7 +2,7 @@
Before you start using it, it is recommended that you read this document carefully so that you can better understand how it works and its functions. Before you start using it, it is recommended that you read this document carefully so that you can better understand how it works and its functions.
You can find the demo in examples in the root directory of the project, and refer to this document for better use. You can find the demo in samples in the root directory of the project, and refer to this document for better use.
## Working Principle ## Working Principle
@@ -32,6 +32,10 @@ Note that `SweetDependency` supports at least Gradle `7.x.x` and is managed usin
If your project is still managed using the `buildscript` method, please migrate to the new method, otherwise errors will occur. If your project is still managed using the `buildscript` method, please migrate to the new method, otherwise errors will occur.
If your project cannot be managed using `dependencyResolutionManagement`, you can refer to the [Custom Preferences](#custom-preferences)
at the bottom of this page,
use traditional library dependency management by configuring `isUseDependencyResolutionManagement = false`.
## Quick Start ## Quick Start
First, open `settings.gradle` or `settings.gradle.kts` of your root project. First, open `settings.gradle` or `settings.gradle.kts` of your root project.
@@ -157,11 +161,21 @@ preferences:
# No namespace: implementation(com.mydemo.test.test) # No namespace: implementation(com.mydemo.test.test)
# Has namespace: implementation(libs.com.mydemo.test.test) # Has namespace: implementation(libs.com.mydemo.test.test)
dependencies-namespace: dependencies-namespace:
plugins:
# If you want to turn off automatic generation, you can set it to false
# Note: When deciding to close,
# make sure that there is no automatically generated code in the build script to prevent errors
enable: true
# Plugin dependencies namespace must exist, if not set, the default is "libs" # Plugin dependencies namespace must exist, if not set, the default is "libs"
plugins: libs name: libs
libraries: libs
# If you want to turn off automatic generation, you can set it to false
# Note: When deciding to close,
# make sure that there is no automatically generated code in the build script to prevent errors
enable: true
# Library dependencies namespace is optional # Library dependencies namespace is optional
# If you don't need the namespace of library dependencies, delete this node # If you don't need the namespace of library dependencies, delete this node
libraries: libs name: libs
# Dependencies version filter # Dependencies version filter
# If you need to exclude some dependency versions that you don't want to be updated to (such as test versions), # If you need to exclude some dependency versions that you don't want to be updated to (such as test versions),
# you can configure them manually # you can configure them manually
@@ -349,6 +363,9 @@ plugins:
org.jetbrains.kotlin.android: org.jetbrains.kotlin.android:
alias: kotlin-android alias: kotlin-android
version: 1.8.10 version: 1.8.10
com.google.devtools.ksp:
alias: kotlin-ksp
version: 1.8.10-1.0.9
# Configure libraries that need to be used # Configure libraries that need to be used
libraries: libraries:
@@ -397,6 +414,14 @@ libraries:
# Note: If you declare "version-ref", this dependency will be excluded from autowiring and updating # Note: If you declare "version-ref", this dependency will be excluded from autowiring and updating
# Note: If you declare "version-ref", "auto-update", "repositories", "version-filter" will not work # Note: If you declare "version-ref", "auto-update", "repositories", "version-filter" will not work
version-ref: <this>::core # Or "androidx.core:core" and "androidx-core" (alias) version-ref: <this>::core # Or "androidx.core:core" and "androidx-core" (alias)
com.google.devtools.ksp:
symbol-processing-api:
# If you want to reference a dependency or alias that does not belong to the current scope ("libraries"),
# you need to declare the scope it belongs to
# For example, to reference the dependency alias "kotlin-ksp" in the "plugins" scope,
# you need to use "<plugins>::" as the beginning of the declaration
# Similarly, you need to use "<libraries>::" as the beginning of the declaration in the "plugins" scope
version-ref: <plugins>::kotlin-ksp # Or "<plugins>::com.google.devtools.ksp"
com.squareup.okhttp3: com.squareup.okhttp3:
okhttp: okhttp:
# If you declare a version in the version that exists in "version-filter" (internal filter or exclude list) # If you declare a version in the version that exists in "version-filter" (internal filter or exclude list)
@@ -842,14 +867,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"))
} }
} }
} }
@@ -1193,9 +1220,20 @@ sweetDependency {
// Enable SweetDependency, set to false will disable all functions // Enable SweetDependency, set to false will disable all functions
isEnable = true isEnable = true
// Whether to enable debug mode
// Not enabled by default,
// if enabled, detailed dependencies search information will be output during autowiring
isDebug = false
// SweetDependency configuration file name // SweetDependency configuration file name
configFileName = "sweet-dependency-config.yaml" configFileName = "sweet-dependency-config.yaml"
// Whether to use Settings.dependencyResolutionManagement to manage library dependencies
// This function is enabled by default,
// if your project must have a custom "repositories" method block, please disable this function
// Note: The "repositories-mode" option in the configuration file will no longer be effective after disabled
isUseDependencyResolutionManagement = true
// Whether to enable dependency autowiring logging // Whether to enable dependency autowiring logging
// This function is enabled by default and will create a log file in the ".gradle/sweet-dependency" directory of the current root project // This function is enabled by default and will create a log file in the ".gradle/sweet-dependency" directory of the current root project
isEnableDependenciesAutowireLog = true isEnableDependenciesAutowireLog = true
@@ -1212,7 +1250,9 @@ sweetDependency {
```groovy ```groovy
sweetDependency { sweetDependency {
enable true enable true
debug false
configFileName 'sweet-dependency-config.yaml' configFileName 'sweet-dependency-config.yaml'
useDependencyResolutionManagement true
enableDependenciesAutowireLog true enableDependenciesAutowireLog true
enableVerboseMode true enableVerboseMode true
} }

View File

@@ -1,13 +1,13 @@
# Project Configuration # Project Configuration
project.name=SweetDependency project.name=SweetDependency
project.description=An easy autowire and manage dependencies Gradle plugin project.description=An easy autowire and manage dependencies Gradle plugin.
project.url=https://github.com/fankes/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.0 project.version=1.0.4
project.licence.name=Apache License 2.0 project.licence.name=Apache License 2.0
project.licence.url=https://github.com/fankes/HighCapable/SweetDependency/blob/master/LICENSE project.licence.url=https://github.com/HighCapable/SweetDependency/blob/master/LICENSE
project.developer.id=0 project.developer.id="0"
project.developer.name=fankes project.developer.name=fankes
project.developer.email=qzmmcn@163.com project.developer.email=qzmmcn@163.com
# Gradle Plugin Configuration # Gradle Plugin Configuration

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,10 @@ 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
net.lingala.zip4j:
zip4j:
version: 2.11.5

View File

@@ -5,12 +5,12 @@ plugins {
android { android {
namespace = "com.highcapable.sweetdependency.demo_app" namespace = "com.highcapable.sweetdependency.demo_app"
compileSdk = 33 compileSdk = 34
defaultConfig { defaultConfig {
applicationId = "com.highcapable.sweetdependency.demo_app" applicationId = "com.highcapable.sweetdependency.demo_app"
minSdk = 24 minSdk = 24
targetSdk = 33 targetSdk = 34
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -5,11 +5,10 @@ plugins {
android { android {
namespace = "com.highcapable.sweetdependency.demo_library" namespace = "com.highcapable.sweetdependency.demo_library"
compileSdk = 33 compileSdk = 34
defaultConfig { defaultConfig {
minSdk = 24 minSdk = 24
targetSdk = 33
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro") consumerProguardFiles("consumer-rules.pro")
} }

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

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.0" id("com.highcapable.sweetdependency") version "1.0.4"
} }
sweetDependency { sweetDependency {
configFileName = "sweet-dependency-config.yaml" configFileName = "sweet-dependency-config.yaml"

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

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.0" id("com.highcapable.sweetdependency") version "1.0.4"
} }
sweetDependency { sweetDependency {
configFileName = "sweet-dependency-config.yaml" configFileName = "sweet-dependency-config.yaml"

View File

@@ -1,4 +1,3 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement { pluginManagement {
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
@@ -8,8 +7,8 @@ pluginManagement {
} }
} }
plugins { plugins {
id("com.highcapable.sweetdependency") version "1.0.0" id("com.highcapable.sweetdependency") version "1.0.4"
id("com.highcapable.sweetproperty") version "1.0.0" id("com.highcapable.sweetproperty") version "1.0.5"
} }
sweetDependency { sweetDependency {
isEnableVerboseMode = false isEnableVerboseMode = false
@@ -21,10 +20,7 @@ sweetProperty {
isEnableRestrictedAccess = true isEnableRestrictedAccess = true
} }
} }
rootProject { sourcesCode { isEnable = false } } rootProject { all { isEnable = false } }
project("sweetdependency-gradle-plugin") {
buildScript { isEnableTypeAutoConversion = false }
}
} }
rootProject.name = "SweetDependency" rootProject.name = "SweetDependency"
include(":sweetdependency-gradle-plugin") include(":sweetdependency-gradle-plugin")

View File

@@ -22,11 +22,11 @@ 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)
implementation(com.squareup.javapoet) implementation(com.squareup.javapoet)
implementation(net.lingala.zip4j.zip4j)
} }
gradlePlugin { gradlePlugin {

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/17. * This file is created by fankes on 2023/5/17.
*/ */
package com.highcapable.sweetdependency package com.highcapable.sweetdependency

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/18. * This file is created by fankes on 2023/5/18.
*/ */
@file:Suppress("unused") @file:Suppress("unused")

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/17. * This file is created by fankes on 2023/5/17.
*/ */
package com.highcapable.sweetdependency.document package com.highcapable.sweetdependency.document
@@ -48,30 +48,43 @@ internal data class PreferencesDocument(
internal var versionFilter: VersionFilterDocument = VersionFilterDocument() internal var versionFilter: VersionFilterDocument = VersionFilterDocument()
) : IYamlDocument { ) : IYamlDocument {
/**
* 依赖命名空间文档实体
* @param plugins 插件依赖
* @param libraries 库依赖
*/
@Serializable @Serializable
internal data class DependenciesNamespaceDocument( internal data class DependenciesNamespaceDocument(
@SerialName("plugins") @SerialName("plugins")
var plugins: String = "libs", var plugins: NamespaceOptionDocument = NamespaceOptionDocument(name = "libs"),
@SerialName("libraries") @SerialName("libraries")
var libraries: String = "" var libraries: NamespaceOptionDocument = NamespaceOptionDocument()
) : IYamlDocument { ) : IYamlDocument {
init { init {
if (plugins.isNotBlank() && libraries.isNotBlank() && plugins == libraries) if (plugins.name.isNotBlank() && libraries.name.isNotBlank() && plugins.name == libraries.name)
SError.make("Duplicated dependencies namespace \"$plugins\"") SError.make("Duplicated dependencies namespace \"$plugins\"")
} }
}
/** /**
* 获取插件依赖命名空间 * 命名空间选项文档实体
* @return [String] * @param isEnable 是否启用
* @param name 名称
*/ */
internal fun plugins() = plugins.apply { checkingName("plugins namespace", isCheckExtName = true) }.camelcase() @Serializable
internal data class NamespaceOptionDocument(
@SerialName("enable")
var isEnable: Boolean = true,
@SerialName("name")
var name: String = ""
) : IYamlDocument {
/** /**
* 获取库依赖命名空间 * 获取名称
* @return [String] * @return [String]
*/ */
internal fun libraries() = libraries.apply { checkingName("libraries namespace", isCheckExtName = true) }.camelcase() internal fun name() = name.apply { checkingName("dependencies namespace", isCheckExtName = true) }.camelcase()
} }
/** /**

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/17. * This file is created by fankes on 2023/5/17.
*/ */
package com.highcapable.sweetdependency.document package com.highcapable.sweetdependency.document
@@ -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

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/17. * This file is created by fankes on 2023/5/17.
*/ */
@file:Suppress("MemberVisibilityCanBePrivate") @file:Suppress("MemberVisibilityCanBePrivate")
@@ -29,7 +29,6 @@ import com.highcapable.sweetdependency.document.factory.RepositoryList
import com.highcapable.sweetdependency.document.factory.checkingName import com.highcapable.sweetdependency.document.factory.checkingName
import com.highcapable.sweetdependency.document.factory.convertToDependencyAmbiguousName import com.highcapable.sweetdependency.document.factory.convertToDependencyAmbiguousName
import com.highcapable.sweetdependency.gradle.entity.DependencyName import com.highcapable.sweetdependency.gradle.entity.DependencyName
import com.highcapable.sweetdependency.gradle.entity.DependencyVersion
import com.highcapable.sweetdependency.utils.capitalize import com.highcapable.sweetdependency.utils.capitalize
import com.highcapable.sweetdependency.utils.debug.SError import com.highcapable.sweetdependency.utils.debug.SError
import com.highcapable.sweetdependency.utils.findDuplicates import com.highcapable.sweetdependency.utils.findDuplicates
@@ -141,30 +140,37 @@ internal data class RootConfigDocument(
* @param duplicate 允许重复 - 忽略处理后版本重复的异常 - 默认否 * @param duplicate 允许重复 - 忽略处理后版本重复的异常 - 默认否
* @return [DependencyMap] * @return [DependencyMap]
*/ */
internal fun plugins(duplicate: Boolean = false) = createPlugins().resolveDependencies(typeName = "plugin", duplicate) internal fun plugins(duplicate: Boolean = false) = resolveDependencies(typeName = "plugin", duplicate)
/** /**
* 获取当前库依赖数组 * 获取当前库依赖数组
* @param duplicate 允许重复 - 忽略处理后版本重复的异常 - 默认否 * @param duplicate 允许重复 - 忽略处理后版本重复的异常 - 默认否
* @return [DependencyMap] * @return [DependencyMap]
*/ */
internal fun libraries(duplicate: Boolean = false) = createLibraries().resolveDependencies(typeName = "library", duplicate) internal fun libraries(duplicate: Boolean = false) = resolveDependencies(typeName = "library", duplicate)
/** /**
* 处理依赖数组 * 处理依赖数组
* @param typeName 依赖类型名称 * @param typeName 依赖类型名称
* @param duplicate 允许重复 - 忽略处理后版本重复的异常 - 默认否 * @param duplicate 允许重复 - 忽略处理后版本重复的异常 - 默认否
* @return [DependencyMap]
*/ */
private fun DependencyMap.resolveDependencies(typeName: String, duplicate: Boolean = false) = apply { private fun resolveDependencies(typeName: String, duplicate: Boolean = false): DependencyMap {
val plugins = createPlugins()
val libraries = createLibraries()
val currentDependencies = when (typeName) {
"plugin" -> plugins
"library" -> libraries
else -> SError.make("Unknown dependency type \"$typeName\"")
}
val firstTypeName = typeName.capitalize() val firstTypeName = typeName.capitalize()
val checkDuplicateAlias = mutableMapOf<String, String>() val checkDuplicateAlias = mutableMapOf<String, String>()
val refLibraries = mutableListOf<Triple<DependencyName, String, DependencyVersion>>()
val ambiguousNames = mutableListOf<String>() val ambiguousNames = mutableListOf<String>()
eachDependencies { dependencyName, artifact -> currentDependencies.eachDependencies { dependencyName, artifact ->
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}\", " +
@@ -177,27 +183,46 @@ internal data class RootConfigDocument(
) )
if (artifact.versionRef.isNotBlank() && artifact.versionRef.startsWith("<this>::")) if (artifact.versionRef.isNotBlank() && artifact.versionRef.startsWith("<this>::"))
artifact.versionRef = artifact.versionRef.replace("<this>:", dependencyName.groupId) artifact.versionRef = artifact.versionRef.replace("<this>:", dependencyName.groupId)
refLibraries.add(Triple(dependencyName, artifact.alias, artifact.version()))
} }
eachDependencies { dependencyName, artifact -> currentDependencies.eachDependencies { dependencyName, artifact ->
/** 处理版本引用 */ /** 处理版本引用 */
fun resolveVersionRef() { fun resolveVersionRef() {
refLibraries.firstOrNull { artifact.versionRef.let { e -> e == it.first.current || e == it.second } }?.also { var scopeName = typeName
if (dependencyName == it.first || dependencyName.current == it.second) val versionRef = artifact.versionRef.replace("<plugins>::", "").replace("<libraries>::", "")
when {
artifact.versionRef.startsWith("<plugins>::") -> {
scopeName = "plugins"
plugins
}
artifact.versionRef.startsWith("<libraries>::") -> {
scopeName = "libraries"
libraries
}
else -> {
scopeName = when (typeName) {
"plugin" -> "plugins"
"library" -> "libraries"
else -> "unknown"
}; currentDependencies
}
}.filter { (dependencyName, artifact) ->
versionRef.let { it == dependencyName.current || it == artifact.alias }
}.entries.firstOrNull()?.also { (resolveDependencyName, resolveArtifact) ->
if (dependencyName == resolveDependencyName || dependencyName.current == resolveArtifact.alias)
SError.make("$firstTypeName \"$dependencyName\" declared \"version-ref\" from itself (recursive call found)") SError.make("$firstTypeName \"$dependencyName\" declared \"version-ref\" from itself (recursive call found)")
when { when {
it.third.isNoSpecific -> SError.make( resolveArtifact.version().isNoSpecific -> SError.make(
"$firstTypeName \"${it.first}\" does not specify a version, so it can no longer be " + "$firstTypeName \"$resolveDependencyName\" does not specify a version, so it can no longer be " +
"declared as \"version-ref\" by $typeName \"$dependencyName\"" "declared as \"version-ref\" by $typeName \"$dependencyName\""
) )
it.third.isBlank -> SError.make( resolveArtifact.version().isBlank -> SError.make(
"$firstTypeName \"${it.first}\" already has \"version-ref\" declared, so it can no longer" + "$firstTypeName \"$resolveDependencyName\" already has \"version-ref\" declared, so it can no longer" +
" be declared as \"version-ref\" by $typeName \"$dependencyName\" (recursive call found)" " be declared as \"version-ref\" by $typeName \"$dependencyName\" (recursive call found)"
) )
}; artifact.updateVersion(it.third) }; artifact.updateVersion(resolveArtifact.version())
} ?: SError.make( } ?: SError.make(
"Could not found any versions or dependencies associated with " + "Could not found any versions or $scopeName associated with " +
"version-ref \"${artifact.versionRef}\" of $typeName \"$dependencyName\"" "version-ref \"$versionRef\" of $typeName \"$dependencyName\""
) )
} }
if (artifact.version().isNoSpecific) return@eachDependencies if (artifact.version().isNoSpecific) return@eachDependencies
@@ -205,19 +230,20 @@ 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")
} }
eachDependencies { dependencyName, artifact -> currentDependencies.eachDependencies { dependencyName, artifact ->
ambiguousNames.add(dependencyName.ambiguousName()) ambiguousNames.add(dependencyName.ambiguousName())
if (artifact.alias.isNotBlank()) { if (artifact.alias.isNotBlank()) {
artifact.alias.checkingName("$typeName \"$dependencyName\" alias", isCheckMultiName = true) artifact.alias.checkingName("$typeName \"$dependencyName\" alias", isCheckMultiName = true)
ambiguousNames.add(artifact.alias.convertToDependencyAmbiguousName()) ambiguousNames.add(artifact.alias.convertToDependencyAmbiguousName())
}; this[dependencyName] = artifact }; currentDependencies[dependencyName] = artifact
} }
if (ambiguousNames.hasDuplicate()) ambiguousNames.findDuplicates().forEach { if (ambiguousNames.hasDuplicate()) ambiguousNames.findDuplicates().forEach {
SError.make("Found ambiguous name \"$it\" in declared dependencies, please checking your $typeName aliases that your declared") SError.make("Found ambiguous name \"$it\" in declared dependencies, please checking your $typeName aliases that your declared")
} else ambiguousNames.clear() } else ambiguousNames.clear()
return currentDependencies
} }
/** /**

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/9. * This file is created by fankes on 2023/6/9.
*/ */
package com.highcapable.sweetdependency.document package com.highcapable.sweetdependency.document
@@ -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

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/31. * This file is created by fankes on 2023/5/31.
*/ */
package com.highcapable.sweetdependency.document.factory package com.highcapable.sweetdependency.document.factory

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/1. * This file is created by fankes on 2023/6/1.
*/ */
package com.highcapable.sweetdependency.document.mapping package com.highcapable.sweetdependency.document.mapping
@@ -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

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/1. * This file is created by fankes on 2023/6/1.
*/ */
package com.highcapable.sweetdependency.document.mapping.entity package com.highcapable.sweetdependency.document.mapping.entity

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/28. * This file is created by fankes on 2023/6/28.
*/ */
package com.highcapable.sweetdependency.environment package com.highcapable.sweetdependency.environment
@@ -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

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/31. * This file is created by fankes on 2023/5/31.
*/ */
package com.highcapable.sweetdependency.exception package com.highcapable.sweetdependency.exception

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/26. * This file is created by fankes on 2023/5/26.
*/ */
package com.highcapable.sweetdependency.gradle.delegate package com.highcapable.sweetdependency.gradle.delegate
@@ -47,10 +47,10 @@ internal object GradleDelegate {
callOnSettingsLoaded(settings) callOnSettingsLoaded(settings)
settings.gradle.settingsEvaluated { callOnSettingsEvaluate(settings = this) } settings.gradle.settingsEvaluated { callOnSettingsEvaluate(settings = this) }
settings.gradle.projectsLoaded { settings.gradle.projectsLoaded {
callOnProjectLoaded(rootProject, isRoot = true) rootProject.beforeEvaluate { callOnProjectLoaded(project = this, isRoot = true) }
rootProject.afterEvaluate { callOnProjectEvaluate(project = this, isRoot = true) } rootProject.afterEvaluate { callOnProjectEvaluate(project = this, isRoot = true) }
rootProject.subprojects.forEach { rootProject.subprojects.forEach {
callOnProjectLoaded(it, isRoot = false) it.beforeEvaluate { callOnProjectLoaded(project = this, isRoot = false) }
it.afterEvaluate { callOnProjectEvaluate(project = this, isRoot = false) } it.afterEvaluate { callOnProjectEvaluate(project = this, isRoot = false) }
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/29. * This file is created by fankes on 2023/5/29.
*/ */
package com.highcapable.sweetdependency.gradle.delegate package com.highcapable.sweetdependency.gradle.delegate

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/25. * This file is created by fankes on 2023/6/25.
*/ */
@file:Suppress("USELESS_ELVIS", "KotlinRedundantDiagnosticSuppress") @file:Suppress("USELESS_ELVIS", "KotlinRedundantDiagnosticSuppress")
@@ -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

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/8/16. * This file is created by fankes on 2023/8/16.
*/ */
@file:Suppress("unused", "MemberVisibilityCanBePrivate") @file:Suppress("unused", "MemberVisibilityCanBePrivate")

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/8/18. * This file is created by fankes on 2023/8/18.
*/ */
package com.highcapable.sweetdependency.gradle.entity package com.highcapable.sweetdependency.gradle.entity

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/16. * This file is created by fankes on 2023/6/16.
*/ */
@file:Suppress("MemberVisibilityCanBePrivate") @file:Suppress("MemberVisibilityCanBePrivate")
@@ -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"
@@ -78,13 +78,31 @@ internal class DependencyVersion(internal var actual: String, optionalType: Opti
else -> current else -> current
} }
/**
* 获取固定存在的版本
*
* 满足以下情况
*
* - [isBlank]
* - [isNoSpecific]
*
* 这些情况都会返回 [AUTOWIRE_VERSION_NAME]
*
* 其余情况会返回 [current]
* @return [String]
*/
internal val fixed get() = when {
isBlank || isNoSpecific -> AUTOWIRE_VERSION_NAME
else -> current
}
/** /**
* 获取部署版本 * 获取部署版本
* *
* 如果为 [isNoSpecific] 则会返回空 * 如果为 [isNoSpecific] 则会返回空
* @return [String] * @return [String]
*/ */
internal val deployed get() = current.takeIf { isNoSpecific.not() } ?: "" internal val deployed get() = current.takeIf { !isNoSpecific } ?: ""
/** /**
* 获取存在版本 * 获取存在版本

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/23. * This file is created by fankes on 2023/6/23.
*/ */
package com.highcapable.sweetdependency.gradle.entity package com.highcapable.sweetdependency.gradle.entity

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/27. * This file is created by fankes on 2023/5/27.
*/ */
@file:Suppress("unused", "USELESS_CAST", "KotlinRedundantDiagnosticSuppress") @file:Suppress("unused", "USELESS_CAST", "KotlinRedundantDiagnosticSuppress")
@@ -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

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/2. * This file is created by fankes on 2023/6/2.
*/ */
@file:Suppress("USELESS_ELVIS", "KotlinRedundantDiagnosticSuppress", "UselessCallOnNotNull") @file:Suppress("USELESS_ELVIS", "KotlinRedundantDiagnosticSuppress", "UselessCallOnNotNull")
@@ -49,10 +49,11 @@ import org.gradle.plugin.use.PluginDependency
/** /**
* 获取指定项目的完整名称 * 获取指定项目的完整名称
* @param isUseColon 是否在子项目前使用冒号 - 默认是
* @return [String] * @return [String]
*/ */
internal val Project.fullName internal fun Project.fullName(isUseColon: Boolean = true): String {
get(): String { val isRoot = this == rootProject
val baseNames = mutableListOf<String>() val baseNames = mutableListOf<String>()
/** /**
@@ -62,9 +63,8 @@ internal val Project.fullName
fun fetchChild(project: Project) { fun fetchChild(project: Project) {
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) it else it.drop(1) }
return buildString { baseNames.onEach { append(":$it") }.clear() }.drop(1)
} }
/** /**
@@ -85,9 +85,9 @@ internal fun Project.addDependencyToBuildScript(repositoryPath: String, pomData:
/** /**
* 装载构建脚本的 [Class] * 装载构建脚本的 [Class]
* @param name [Class] 完整名称 * @param name [Class] 完整名称
* @return [Class] * @return [Class] or null
*/ */
internal fun Project.loadBuildScriptClass(name: String) = buildscript.classLoader.loadClass(name) internal fun Project.loadBuildScriptClass(name: String) = runCatching { buildscript.classLoader.loadClass(name) }.getOrNull()
/** /**
* 获取指定项目部署的插件依赖数组 (实时) * 获取指定项目部署的插件依赖数组 (实时)
@@ -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

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/19. * This file is created by fankes on 2023/5/19.
*/ */
@file:Suppress("MemberVisibilityCanBePrivate") @file:Suppress("MemberVisibilityCanBePrivate")

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/26. * This file is created by fankes on 2023/5/26.
*/ */
package com.highcapable.sweetdependency.gradle.proxy package com.highcapable.sweetdependency.gradle.proxy

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/28. * This file is created by fankes on 2023/5/28.
*/ */
@file:Suppress("USELESS_ELVIS", "KotlinRedundantDiagnosticSuppress") @file:Suppress("USELESS_ELVIS", "KotlinRedundantDiagnosticSuppress")

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/8/17. * This file is created by fankes on 2023/8/17.
*/ */
package com.highcapable.sweetdependency.gradle.wrapper package com.highcapable.sweetdependency.gradle.wrapper

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/10. * This file is created by fankes on 2023/6/10.
*/ */
package com.highcapable.sweetdependency.gradle.wrapper.type package com.highcapable.sweetdependency.gradle.wrapper.type

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/16. * This file is created by fankes on 2023/5/16.
*/ */
package com.highcapable.sweetdependency.manager package com.highcapable.sweetdependency.manager
@@ -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
@@ -252,7 +253,19 @@ internal object DependencyManager {
forEachIndexed { index, entry -> forEachIndexed { index, entry ->
val currentVersionFilterExclusionList = versionFilterExclusionList.depends(currentVersion) val currentVersionFilterExclusionList = versionFilterExclusionList.depends(currentVersion)
val availableVersions = mutableListOf<DependencyVersion>() val availableVersions = mutableListOf<DependencyVersion>()
poms.add(MavenParser.acquire(dependencyName, entry, currentVersion)) poms.add(MavenParser.acquire(dependencyName, entry, currentVersion).also {
if (!SweetDependencyConfigs.configs.isDebug) return@also
val isNotFound = it.versions.isEmpty()
logDoneOrWarn("$positionTagName > OBTAIN (${index + 1}/$size) ${dependencyName.description}", isNotFound)
logDoneOrWarn(
"""
- Repository (${entry.nodeName}): ${it.url}
- Last Updated: ${it.lastUpdated}
- Versions: ${it.versions}
- Adopted Versions: ${currentVersionFilterExclusionList.filter(it.versions)}
""".trimIndent(), isNotFound, noTag = true
)
})
if (index == lastIndex) poms.noEmpty() if (index == lastIndex) poms.noEmpty()
?.sortedByDescending { it.lastUpdated } ?.sortedByDescending { it.lastUpdated }
?.let { if (it.all { e -> e.lastUpdated <= 0L }) it.sortedByDescending { e -> e.versions.size } else it } ?.let { if (it.all { e -> e.lastUpdated <= 0L }) it.sortedByDescending { e -> e.versions.size } else it }
@@ -315,9 +328,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 -> {
@@ -332,4 +345,13 @@ internal object DependencyManager {
} }
else -> SLog.info("$positionTagName > UP-TO-DATE ${dependencyName.description} version $currentVersion", SLog.DONE) else -> SLog.info("$positionTagName > UP-TO-DATE ${dependencyName.description} version $currentVersion", SLog.DONE)
} }
/**
* 打印完成或警告 Log
* @param msg 消息内容
* @param isWarn 是否为警告模式 - 默认否
* @param noTag 无标签 - 默认否
*/
private fun logDoneOrWarn(msg: String, isWarn: Boolean = false, noTag: Boolean = false) =
if (isWarn) SLog.warn(msg, noTag = noTag) else SLog.info(msg, SLog.DONE, noTag = noTag)
} }

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/29. * This file is created by fankes on 2023/6/29.
*/ */
@file:Suppress("MemberVisibilityCanBePrivate") @file:Suppress("MemberVisibilityCanBePrivate")

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,13 +17,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/6. * This file is created by fankes on 2023/6/6.
*/ */
package com.highcapable.sweetdependency.manager package com.highcapable.sweetdependency.manager
import com.highcapable.sweetdependency.document.PreferencesDocument import com.highcapable.sweetdependency.document.PreferencesDocument
import com.highcapable.sweetdependency.document.RepositoryDocument import com.highcapable.sweetdependency.document.RepositoryDocument
import com.highcapable.sweetdependency.document.factory.RepositoryList
import com.highcapable.sweetdependency.exception.SweetDependencyUnresolvedException import com.highcapable.sweetdependency.exception.SweetDependencyUnresolvedException
import com.highcapable.sweetdependency.gradle.helper.GradleHelper
import com.highcapable.sweetdependency.manager.const.AdditionalRepositories import com.highcapable.sweetdependency.manager.const.AdditionalRepositories
import com.highcapable.sweetdependency.manager.content.Repositories import com.highcapable.sweetdependency.manager.content.Repositories
import com.highcapable.sweetdependency.plugin.config.content.SweetDependencyConfigs import com.highcapable.sweetdependency.plugin.config.content.SweetDependencyConfigs
@@ -32,6 +34,7 @@ import com.highcapable.sweetdependency.utils.debug.SLog
import com.highcapable.sweetdependency.utils.noBlank import com.highcapable.sweetdependency.utils.noBlank
import com.highcapable.sweetdependency.utils.noEmpty import com.highcapable.sweetdependency.utils.noEmpty
import com.highcapable.sweetdependency.utils.toFile import com.highcapable.sweetdependency.utils.toFile
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.RepositoryHandler import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.ArtifactRepository import org.gradle.api.artifacts.repositories.ArtifactRepository
import org.gradle.api.artifacts.repositories.AuthenticationSupported import org.gradle.api.artifacts.repositories.AuthenticationSupported
@@ -45,32 +48,27 @@ import org.gradle.api.initialization.resolve.RepositoriesMode as GradleRepositor
*/ */
internal object RepositoryManager { internal object RepositoryManager {
/** 当前存储库数组 */
private var repositories: RepositoryList = mutableListOf()
/**
* 当前是否使用 [Settings.dependencyResolutionManagement] 管理库依赖
* @return [Boolean]
*/
private val isUseDependencyResolutionManagement get() = SweetDependencyConfigs.configs.isUseDependencyResolutionManagement
/** /**
* 生成并应用存储库数组 * 生成并应用存储库数组
* @param settings 当前设置 * @param settings 当前设置
*/ */
internal fun generateAndApply(settings: Settings) { internal fun generateAndApply(settings: Settings) {
val repositories = SweetDependencyConfigs.document.repositories() repositories = SweetDependencyConfigs.document.repositories()
Repositories.generate(repositories) Repositories.generate(repositories)
/**
* 应用存储库数组到 Gradle
* @param isPlugins 当前应用类型是否为插件依赖
*/
fun RepositoryHandler.apply(isPlugins: Boolean) = repositories.forEach {
if (it.isIncludeScope(isPlugins)) when (it.nodeType) {
RepositoryDocument.RepositoryType.GOOGLE -> google { applyToArtifact(it) }
RepositoryDocument.RepositoryType.MAVEN_CENTRAL -> mavenCentral { applyToArtifact(it) }
RepositoryDocument.RepositoryType.MAVEN_LOCAL -> mavenLocal { applyToArtifact(it) }
RepositoryDocument.RepositoryType.MAVEN -> maven { applyToArtifact(it) }
RepositoryDocument.RepositoryType.GRADLE_PLUGIN_PORTAL -> gradlePluginPortal { applyToArtifact(it) }
else -> {}
}
}
settings.pluginManagement { settings.pluginManagement {
this.repositories.clear() this.repositories.clear()
this.repositories.apply(isPlugins = true) this.repositories.apply(isPlugins = true)
} }
settings.dependencyResolutionManagement { if (isUseDependencyResolutionManagement) settings.dependencyResolutionManagement {
this.repositoriesMode.set(when (SweetDependencyConfigs.document.preferences().repositoriesMode) { this.repositoriesMode.set(when (SweetDependencyConfigs.document.preferences().repositoriesMode) {
PreferencesDocument.RepositoriesMode.PREFER_PROJECT -> GradleRepositoriesMode.PREFER_PROJECT PreferencesDocument.RepositoriesMode.PREFER_PROJECT -> GradleRepositoriesMode.PREFER_PROJECT
PreferencesDocument.RepositoriesMode.PREFER_SETTINGS -> GradleRepositoriesMode.PREFER_SETTINGS PreferencesDocument.RepositoriesMode.PREFER_SETTINGS -> GradleRepositoriesMode.PREFER_SETTINGS
@@ -81,6 +79,33 @@ internal object RepositoryManager {
} }
} }
/**
* 应用存储库数组
* @param rootProject 当前根项目
*/
internal fun apply(rootProject: Project) {
if (!isUseDependencyResolutionManagement)
rootProject.allprojects {
this.repositories.clear()
this.repositories.apply(isPlugins = false)
}
}
/**
* 应用存储库数组到 Gradle
* @param isPlugins 当前应用类型是否为插件依赖
*/
private fun RepositoryHandler.apply(isPlugins: Boolean) = repositories.forEach {
if (it.isIncludeScope(isPlugins)) when (it.nodeType) {
RepositoryDocument.RepositoryType.GOOGLE -> google { applyToArtifact(it) }
RepositoryDocument.RepositoryType.MAVEN_CENTRAL -> mavenCentral { applyToArtifact(it) }
RepositoryDocument.RepositoryType.MAVEN_LOCAL -> mavenLocal { applyToArtifact(it) }
RepositoryDocument.RepositoryType.MAVEN -> maven { applyToArtifact(it) }
RepositoryDocument.RepositoryType.GRADLE_PLUGIN_PORTAL -> gradlePluginPortal { applyToArtifact(it) }
else -> {}
}
}
/** /**
* 应用存储库到 [ArtifactRepository] * 应用存储库到 [ArtifactRepository]
* @param document 存储库配置项文档实体 * @param document 存储库配置项文档实体
@@ -89,7 +114,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 期望的个数
@@ -100,9 +125,17 @@ internal object RepositoryManager {
fun List<String>.forEachParams(size: Int, result: (List<String>) -> Unit) = forEach { fun List<String>.forEachParams(size: Int, result: (List<String>) -> Unit) = forEach {
result(it.split(":").also { e -> if (e.size != size) SError.make("Missing argument in content configuration") }) result(it.split(":").also { e -> if (e.size != size) SError.make("Missing argument in content configuration") })
} }
/**
* 对旧版本不兼容的方法打印警告信息
* @param name 方法名称
*/
fun warnIfNotSupport(name: String) = SLog.warn("Current Gradle ${GradleHelper.version} not support \"$name\"")
document.content.exclude.also { document.content.exclude.also {
it.group().noEmpty()?.forEach { e -> excludeGroup(e) } it.group().noEmpty()?.forEach { e -> excludeGroup(e) }
runCatching {
it.groupAndSubgroups().noEmpty()?.forEach { e -> excludeGroupAndSubgroups(e) } it.groupAndSubgroups().noEmpty()?.forEach { e -> excludeGroupAndSubgroups(e) }
}.onFailure { warnIfNotSupport(name = "excludeGroupAndSubgroups") }
it.groupByRegex().noEmpty()?.forEach { e -> excludeGroupByRegex(e) } it.groupByRegex().noEmpty()?.forEach { e -> excludeGroupByRegex(e) }
it.module().noEmpty()?.forEachParams(size = 2) { e -> excludeModule(e[0], e[1]) } it.module().noEmpty()?.forEachParams(size = 2) { e -> excludeModule(e[0], e[1]) }
it.moduleByRegex().noEmpty()?.forEachParams(size = 2) { e -> excludeModuleByRegex(e[0], e[1]) } it.moduleByRegex().noEmpty()?.forEachParams(size = 2) { e -> excludeModuleByRegex(e[0], e[1]) }
@@ -111,7 +144,9 @@ internal object RepositoryManager {
} }
document.content.include.also { document.content.include.also {
it.group().noEmpty()?.forEach { e -> includeGroup(e) } it.group().noEmpty()?.forEach { e -> includeGroup(e) }
runCatching {
it.groupAndSubgroups().noEmpty()?.forEach { e -> includeGroupAndSubgroups(e) } it.groupAndSubgroups().noEmpty()?.forEach { e -> includeGroupAndSubgroups(e) }
}.onFailure { warnIfNotSupport(name = "includeGroupAndSubgroups") }
it.groupByRegex().noEmpty()?.forEach { e -> includeGroupByRegex(e) } it.groupByRegex().noEmpty()?.forEach { e -> includeGroupByRegex(e) }
it.module().noEmpty()?.forEachParams(size = 2) { e -> includeModule(e[0], e[1]) } it.module().noEmpty()?.forEachParams(size = 2) { e -> includeModule(e[0], e[1]) }
it.moduleByRegex().noEmpty()?.forEachParams(size = 2) { e -> includeModuleByRegex(e[0], e[1]) } it.moduleByRegex().noEmpty()?.forEachParams(size = 2) { e -> includeModuleByRegex(e[0], e[1]) }

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/16. * This file is created by fankes on 2023/5/16.
*/ */
package com.highcapable.sweetdependency.manager.const package com.highcapable.sweetdependency.manager.const

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/18. * This file is created by fankes on 2023/5/18.
*/ */
package com.highcapable.sweetdependency.manager.const package com.highcapable.sweetdependency.manager.const

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/6/25. * This file is created by fankes on 2023/6/25.
*/ */
@file:Suppress("unused", "MemberVisibilityCanBePrivate") @file:Suppress("unused", "MemberVisibilityCanBePrivate")
@@ -85,7 +85,7 @@ internal object Dependencies {
* 当前是否不存在依赖 * 当前是否不存在依赖
* @return [Boolean] * @return [Boolean]
*/ */
internal fun isNotEmpty() = isEmpty().not() internal fun isNotEmpty() = !isEmpty()
/** /**
* 查找是否存在指定的依赖 * 查找是否存在指定的依赖

View File

@@ -1,5 +1,5 @@
/* /*
* SweetDependency - An easy autowire and manage dependencies Gradle plugin * SweetDependency - An easy autowire and manage dependencies Gradle plugin.
* Copyright (C) 2019-2023 HighCapable * Copyright (C) 2019-2023 HighCapable
* https://github.com/HighCapable/SweetDependency * https://github.com/HighCapable/SweetDependency
* *
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* This file is Created by fankes on 2023/5/16. * This file is created by fankes on 2023/5/16.
*/ */
package com.highcapable.sweetdependency.manager.content package com.highcapable.sweetdependency.manager.content
@@ -59,7 +59,7 @@ internal object Repositories {
* 当前是否不存在存储库 * 当前是否不存在存储库
* @return [Boolean] * @return [Boolean]
*/ */
internal fun isNotEmpty() = isEmpty().not() internal fun isNotEmpty() = !isEmpty()
/** /**
* 生成存储库数组 * 生成存储库数组

Some files were not shown because too many files have changed in this diff Show More