42 Commits
1.0.0 ... 1.0.3

Author SHA1 Message Date
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 662 additions and 416 deletions

2
.idea/kotlinc.xml generated
View File

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

View File

@@ -1,8 +1,8 @@
# Sweet Dependency
[![Blank](https://img.shields.io/badge/license-Apache2.0-blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE)
![Blank](https://img.shields.io/badge/version-v1.0.0-green)
[![Telegram](https://img.shields.io/badge/Discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev)
[![GitHub license](https://img.shields.io/github/license/HighCapable/SweetDependency?color=blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE)
[![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)
<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) | 简体中文
| <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 插件,所有依赖集中管理并自动更新,解决了每个子项目都需要手动更新到相同版本依赖的问题。
@@ -64,6 +69,12 @@
本项目同样使用了 **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 Chart](https://api.star-history.com/svg?repos=HighCapable/SweetDependency&type=Date)

View File

@@ -1,8 +1,8 @@
# Sweet Dependency
[![Blank](https://img.shields.io/badge/license-Apache2.0-blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE)
![Blank](https://img.shields.io/badge/version-v1.0.0-green)
[![Telegram](https://img.shields.io/badge/Discussion-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev)
[![GitHub license](https://img.shields.io/github/license/HighCapable/SweetDependency?color=blue)](https://github.com/HighCapable/SweetDependency/blob/master/LICENSE)
[![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)
<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)
| <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
This is a Gradle plugin for managing Gradle dependencies.

View File

@@ -2,4 +2,28 @@
## 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 脚本中识别为非空返回值类型
- 一些其它功能性的改进

View File

@@ -2,4 +2,31 @@
## 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

View File

@@ -2,7 +2,7 @@
在开始使用之前,建议你仔细阅读此文档,以便你能更好地了解它的作用方式与功能。
你可以在项目的根目录找到 examples 中的 Demo并参考此文档食用效果更佳。
你可以在项目的根目录找到 samples 中的 Demo并参考此文档食用效果更佳。
## 工作原理
@@ -151,11 +151,19 @@ preferences:
# 没有命名空间implementation(com.mydemo.test.test)
# 存在命名空间implementation(libs.com.mydemo.test.test)
dependencies-namespace:
# 插件依赖必须存在命名空间,如果不设置,其默认为 "libs"
plugins: libs
# 库依赖的命名空间可选
# 如果你不需要库依赖的命名空间,请删除此节点
libraries: libs
plugins:
# 如果你希望关闭自动生成,可以设置为 false
# 在决定关闭时请确保构建脚本中已不存在自动生成的代码,防止发生错误
enable: true
# 插件依赖必须存在命名空间,如果不设置,其默认为 "libs"
name: libs
libraries:
# 如果你希望关闭自动生成,可以设置为 false
# 在决定关闭时请确保构建脚本中已不存在自动生成的代码,防止发生错误
enable: true
# 库依赖的命名空间可选
# 如果你不需要库依赖的命名空间,请删除此节点
name: libs
# 依赖版本过滤器
# 如果你需要排除一些不希望被更新到的依赖版本 (例如测试版本) 可以手动进行配置
# 默认情况下过滤器已帮你自动排除测试版本,无需对此项进行配置
@@ -332,6 +340,9 @@ plugins:
org.jetbrains.kotlin.android:
alias: kotlin-android
version: 1.8.10
com.google.devtools.ksp:
alias: kotlin-ksp
version: 1.8.10-1.0.9
# 配置需要使用的库依赖
libraries:
@@ -375,6 +386,12 @@ libraries:
# 注意:如果你声明了 "version-ref",此依赖将在自动装配和更新中被排除
# 注意:如果你声明了 "version-ref""auto-update"、"repositories"、"version-filter" 将无效
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:
okhttp:
# 如果你在版本中声明了一个 "version-filter" 中存在的版本 (内置过滤器或排除列表)
@@ -792,14 +809,16 @@ dependencies {
在 Kotlin Multiplatform 中与一般依赖部署方式一致。
为了解决可能的插件冲突,无论是 Kotlin 还是 Groovy都需要使用 `sweet.autowire`
> Kotlin DSL
```kotlin
sourceSets {
val androidMain by getting {
dependencies {
implementation(autowire("androidx.core:core-ktx"))
implementation(autowire("libs/*.jar"))
implementation(sweet.autowire("androidx.core:core-ktx"))
implementation(sweet.autowire("libs/*.jar"))
}
}
}

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.
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
@@ -157,11 +157,21 @@ preferences:
# No namespace: implementation(com.mydemo.test.test)
# Has namespace: implementation(libs.com.mydemo.test.test)
dependencies-namespace:
# Plugin dependencies namespace must exist, if not set, the default is "libs"
plugins: libs
# Library dependencies namespace is optional
# If you don't need the namespace of library dependencies, delete this node
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"
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
# If you don't need the namespace of library dependencies, delete this node
name: libs
# Dependencies version filter
# 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
@@ -349,6 +359,9 @@ plugins:
org.jetbrains.kotlin.android:
alias: kotlin-android
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
libraries:
@@ -397,6 +410,14 @@ libraries:
# 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
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:
okhttp:
# If you declare a version in the version that exists in "version-filter" (internal filter or exclude list)
@@ -842,14 +863,16 @@ dependencies {
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
sourceSets {
val androidMain by getting {
dependencies {
implementation(autowire("androidx.core:core-ktx"))
implementation(autowire("libs/*.jar"))
implementation(sweet.autowire("androidx.core:core-ktx"))
implementation(sweet.autowire("libs/*.jar"))
}
}
}

View File

@@ -1,13 +1,13 @@
# Project Configuration
project.name=SweetDependency
project.description=An easy autowire and manage dependencies Gradle plugin
project.url=https://github.com/fankes/HighCapable/SweetDependency
project.description=An easy autowire and manage dependencies Gradle plugin.
project.url=https://github.com/HighCapable/SweetDependency
project.groupName=com.highcapable.sweetdependency
project.moduleName=sweet-dependency
project.version=1.0.0
project.version=1.0.3
project.licence.name=Apache License 2.0
project.licence.url=https://github.com/fankes/HighCapable/SweetDependency/blob/master/LICENSE
project.developer.id=0
project.licence.url=https://github.com/HighCapable/SweetDependency/blob/master/LICENSE
project.developer.id="0"
project.developer.name=fankes
project.developer.email=qzmmcn@163.com
# Gradle Plugin Configuration

View File

@@ -12,7 +12,7 @@ repositories:
plugins:
org.jetbrains.kotlin.jvm:
alias: kotlin-jvm
version: 1.9.10
version: 1.9.20
org.jetbrains.kotlin.plugin.serialization:
alias: kotlin-serialization
version-ref: kotlin-jvm
@@ -21,9 +21,6 @@ plugins:
version: 0.25.3
libraries:
org.jetbrains.kotlin:
kotlin-gradle-plugin-api:
version: 1.9.10
org.snakeyaml:
snakeyaml-engine:
version: 2.7
@@ -32,7 +29,10 @@ libraries:
version: 0.55.0
com.squareup.okhttp3:
okhttp:
version: 4.11.0
version: 4.12.0
com.squareup:
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 {
namespace = "com.highcapable.sweetdependency.demo_app"
compileSdk = 33
compileSdk = 34
defaultConfig {
applicationId = "com.highcapable.sweetdependency.demo_app"
minSdk = 24
targetSdk = 33
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

View File

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

View File

@@ -1,5 +1,5 @@
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
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View File

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

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
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
zipStorePath=wrapper/dists

View File

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

View File

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

View File

@@ -22,11 +22,11 @@ kotlin {
}
dependencies {
implementation(org.jetbrains.kotlin.kotlin.gradle.plugin.api)
implementation(org.snakeyaml.snakeyaml.engine)
implementation(com.charleskorn.kaml.kaml)
implementation(com.squareup.okhttp3.okhttp)
implementation(com.squareup.javapoet)
implementation(net.lingala.zip4j.zip4j)
}
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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -48,30 +48,43 @@ internal data class PreferencesDocument(
internal var versionFilter: VersionFilterDocument = VersionFilterDocument()
) : IYamlDocument {
/**
* 依赖命名空间文档实体
* @param plugins 插件依赖
* @param libraries 库依赖
*/
@Serializable
internal data class DependenciesNamespaceDocument(
@SerialName("plugins")
var plugins: String = "libs",
var plugins: NamespaceOptionDocument = NamespaceOptionDocument(name = "libs"),
@SerialName("libraries")
var libraries: String = ""
var libraries: NamespaceOptionDocument = NamespaceOptionDocument()
) : IYamlDocument {
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\"")
}
}
/**
* 命名空间选项文档实体
* @param isEnable 是否启用
* @param name 名称
*/
@Serializable
internal data class NamespaceOptionDocument(
@SerialName("enable")
var isEnable: Boolean = true,
@SerialName("name")
var name: String = ""
) : IYamlDocument {
/**
* 获取插件依赖命名空间
* 获取名称
* @return [String]
*/
internal fun plugins() = plugins.apply { checkingName("plugins namespace", isCheckExtName = true) }.camelcase()
/**
* 获取库依赖命名空间
* @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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -267,7 +267,7 @@ internal data class RepositoryDocument(
}; nodeName = 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 (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()
}
}

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")
@@ -29,7 +29,6 @@ import com.highcapable.sweetdependency.document.factory.RepositoryList
import com.highcapable.sweetdependency.document.factory.checkingName
import com.highcapable.sweetdependency.document.factory.convertToDependencyAmbiguousName
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.debug.SError
import com.highcapable.sweetdependency.utils.findDuplicates
@@ -141,30 +140,37 @@ internal data class RootConfigDocument(
* @param duplicate 允许重复 - 忽略处理后版本重复的异常 - 默认否
* @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 允许重复 - 忽略处理后版本重复的异常 - 默认否
* @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 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 checkDuplicateAlias = mutableMapOf<String, String>()
val refLibraries = mutableListOf<Triple<DependencyName, String, DependencyVersion>>()
val ambiguousNames = mutableListOf<String>()
eachDependencies { dependencyName, artifact ->
currentDependencies.eachDependencies { dependencyName, artifact ->
artifact.alias.checkingName("$typeName \"$dependencyName\" alias", isCheckMultiName = true)
artifact.versions().forEach { (name, _) -> name.checkingName("$typeName \"$dependencyName\" version alias") }
if (artifact.alias.isNotBlank())
if (checkDuplicateAlias.contains(artifact.alias).not())
if (!checkDuplicateAlias.contains(artifact.alias))
checkDuplicateAlias[artifact.alias] = dependencyName.current
else SError.make(
"Duplicated alias \"${artifact.alias}\", " +
@@ -177,27 +183,46 @@ internal data class RootConfigDocument(
)
if (artifact.versionRef.isNotBlank() && artifact.versionRef.startsWith("<this>::"))
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() {
refLibraries.firstOrNull { artifact.versionRef.let { e -> e == it.first.current || e == it.second } }?.also {
if (dependencyName == it.first || dependencyName.current == it.second)
var scopeName = typeName
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)")
when {
it.third.isNoSpecific -> SError.make(
"$firstTypeName \"${it.first}\" does not specify a version, so it can no longer be " +
resolveArtifact.version().isNoSpecific -> SError.make(
"$firstTypeName \"$resolveDependencyName\" does not specify a version, so it can no longer be " +
"declared as \"version-ref\" by $typeName \"$dependencyName\""
)
it.third.isBlank -> SError.make(
"$firstTypeName \"${it.first}\" already has \"version-ref\" declared, so it can no longer" +
resolveArtifact.version().isBlank -> SError.make(
"$firstTypeName \"$resolveDependencyName\" already has \"version-ref\" declared, so it can no longer" +
" be declared as \"version-ref\" by $typeName \"$dependencyName\" (recursive call found)"
)
}; artifact.updateVersion(it.third)
}; artifact.updateVersion(resolveArtifact.version())
} ?: SError.make(
"Could not found any versions or dependencies associated with " +
"version-ref \"${artifact.versionRef}\" of $typeName \"$dependencyName\""
"Could not found any versions or $scopeName associated with " +
"version-ref \"$versionRef\" of $typeName \"$dependencyName\""
)
}
if (artifact.version().isNoSpecific) return@eachDependencies
@@ -205,19 +230,20 @@ internal data class RootConfigDocument(
if (artifact.versionRef.isNotBlank())
versions()[artifact.versionRef]?.also { artifact.version = it } ?: resolveVersionRef()
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")
}
eachDependencies { dependencyName, artifact ->
currentDependencies.eachDependencies { dependencyName, artifact ->
ambiguousNames.add(dependencyName.ambiguousName())
if (artifact.alias.isNotBlank()) {
artifact.alias.checkingName("$typeName \"$dependencyName\" alias", isCheckMultiName = true)
ambiguousNames.add(artifact.alias.convertToDependencyAmbiguousName())
}; this[dependencyName] = artifact
}; currentDependencies[dependencyName] = artifact
}
if (ambiguousNames.hasDuplicate()) ambiguousNames.findDuplicates().forEach {
SError.make("Found ambiguous name \"$it\" in declared dependencies, please checking your $typeName aliases that your declared")
} 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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -64,7 +64,7 @@ internal data class VersionFilterDocument(
* 当前是否不存在排除列表
* @return [Boolean]
*/
internal fun isNotEmpty() = isEmpty().not()
internal fun isNotEmpty() = !isEmpty()
/**
* 依赖于当前 [version] 提供的版本并在 [all] 中排除 (不区分大小写)
@@ -74,7 +74,7 @@ internal data class VersionFilterDocument(
* @return [ExclusionList]
*/
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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -158,12 +158,12 @@ internal class RootConfigDocumentMapping internal constructor(private val config
}
}
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
pluginsLine++
}.clear()
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
librariesLine++
}.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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -42,13 +42,13 @@ internal object Environment {
* 获取 [SweetDependency] 缓存存放目录
* @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] 功能存放目录
* @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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -47,10 +47,10 @@ internal object GradleDelegate {
callOnSettingsLoaded(settings)
settings.gradle.settingsEvaluated { callOnSettingsEvaluate(settings = this) }
settings.gradle.projectsLoaded {
callOnProjectLoaded(rootProject, isRoot = true)
rootProject.beforeEvaluate { callOnProjectLoaded(project = this, isRoot = true) }
rootProject.afterEvaluate { callOnProjectEvaluate(project = this, isRoot = true) }
rootProject.subprojects.forEach {
callOnProjectLoaded(it, isRoot = false)
it.beforeEvaluate { callOnProjectLoaded(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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")
@@ -51,7 +51,7 @@ internal open class ExternalDependencyDelegate internal constructor(
override fun getVersion(): String {
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
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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")
@@ -54,7 +54,7 @@ internal class DependencyVersion(internal var actual: String, optionalType: Opti
if (current.startsWith("<") && current.endsWith(">"))
if (current != NO_SPECIFIC_VERSION_NAME && current != LATEST_VERSION_NAME)
SError.make("The parameter \"$current\" is not recognized as any available function")
if (isOptional.not()) when (optionalType) {
if (!isOptional) when (optionalType) {
OptionalUpdateType.NONE -> {}
OptionalUpdateType.NORMAL -> actual = "$OPTIONAL_VERSION_NORMAL_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
}
/**
* 获取固定存在的版本
*
* 满足以下情况
*
* - [isBlank]
* - [isNoSpecific]
*
* 这些情况都会返回 [AUTOWIRE_VERSION_NAME]
*
* 其余情况会返回 [current]
* @return [String]
*/
internal val fixed get() = when {
isBlank || isNoSpecific -> AUTOWIRE_VERSION_NAME
else -> current
}
/**
* 获取部署版本
*
* 如果为 [isNoSpecific] 则会返回空
* @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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")
@@ -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 ->
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\"")
}
}
@@ -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 ->
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\"")
}
}

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")
@@ -49,23 +49,23 @@ import org.gradle.plugin.use.PluginDependency
/**
* 获取指定项目的完整名称
* @param isUseColon 是否在子项目前使用冒号 - 默认是
* @return [String]
*/
internal val Project.fullName
get(): String {
val baseNames = mutableListOf<String>()
internal fun Project.fullName(isUseColon: Boolean = true): String {
val isRoot = this == rootProject
val baseNames = mutableListOf<String>()
/**
* 递归子项目
* @param project 当前项目
*/
fun fetchChild(project: Project) {
project.parent?.also { if (it != it.rootProject) fetchChild(it) }
baseNames.add(project.name)
}
fetchChild(project = this)
return buildString { baseNames.onEach { append(":$it") }.clear() }.drop(1)
}
/**
* 递归子项目
* @param project 当前项目
*/
fun fetchChild(project: Project) {
project.parent?.also { if (it != it.rootProject) fetchChild(it) }
baseNames.add(project.name)
}; fetchChild(project = this)
return buildString { baseNames.onEach { append(":$it") }.clear() }.let { if (isUseColon && !isRoot) it else it.drop(1) }
}
/**
* 向构建脚本添加自定义依赖
@@ -85,9 +85,9 @@ internal fun Project.addDependencyToBuildScript(repositoryPath: String, pomData:
/**
* 装载构建脚本的 [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]
*/
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
else -> true
}
@@ -186,5 +186,5 @@ internal fun PluginDependenciesSpec.applyPlugin(alias: Any) = when (alias) {
private fun PluginManager.findPluginId(plugin: Plugin<*>) = runCatching {
@Suppress("UNCHECKED_CAST")
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 ?: ""

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -92,11 +92,12 @@ internal object DependencyManager {
*/
internal fun deploy(rootProject: Project) {
/**
* 为 Groovy 创建扩展方法
* 为自动装配创建扩展方法
* @param extension 当前扩展实例
* @param isGroovyOnly 是否仅为 Groovy 创建 - 默认是
*/
fun Project.deployForGroovy(extension: ExtensionAware) {
if (buildFile.name.endsWith(".gradle"))
fun Project.deployAutowire(extension: ExtensionAware, isGroovyOnly: Boolean = true) {
if (!isGroovyOnly || buildFile.name.endsWith(".gradle"))
extension.getOrCreate<SweetDependencyAutowireExtension>(SweetDependencyAutowireExtension.NAME, this)
}
@@ -110,14 +111,14 @@ internal object DependencyManager {
fun Project.deployForKotlinMultiplatform() =
waitForPluginAdded("org.jetbrains.kotlin.multiplatform") {
get("kotlin").also { extension ->
deployForGroovy(extension)
deployAutowire(extension, isGroovyOnly = false)
deployEach(extension)
}
}
/** 部署到当前项目 */
fun Project.deploy() {
deployForGroovy(dependencies)
deployAutowire(dependencies)
deployEach(dependencies)
deployForKotlinMultiplatform()
}
@@ -161,7 +162,7 @@ internal object DependencyManager {
var updLbrariesCount = 0
val needUpdateDependencies = mutableMapOf<String, Pair<DependencyName, DependencyVersion>>()
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_OPTIONAL &&
(artifact.version().isOptional || artifact.version().isAutowire)) ||
@@ -212,7 +213,7 @@ internal object DependencyManager {
if (SweetDependencyConfigs.configs.isEnableDependenciesAutowireLog)
logIfNeeded(msg = "Autowiring logs have been automatically written to: ${DependencyAutowireLogHelper.logFile}", SLog.LINK)
SweetDependencyConfigs.documentMapping.updateDependencies(needUpdateDependencies)
if (isRunningOnSync.not()) SLog.warn(
if (!isRunningOnSync) SLog.warn(
"""
**************************** NOTICE ****************************
${needUpdateDependencies.size} dependencies (plugins: $updPluginsCount, libraries: $updLbrariesCount) has been changed
@@ -315,9 +316,9 @@ internal object DependencyManager {
isAutoUpdate: Boolean,
result: (newVersion: DependencyVersion) -> Unit
) = when {
currentVersion.isAutowire.not() && versions.contains(currentVersion).not() ->
!currentVersion.isAutowire && !versions.contains(currentVersion) ->
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")
latestVersion != currentVersion -> when {
currentVersion.isAutowire -> {

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,13 +17,14 @@
* See the License for the specific language governing permissions and
* 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
import com.highcapable.sweetdependency.document.PreferencesDocument
import com.highcapable.sweetdependency.document.RepositoryDocument
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.content.Repositories
import com.highcapable.sweetdependency.plugin.config.content.SweetDependencyConfigs
@@ -89,7 +90,7 @@ internal object RepositoryManager {
document.nodeName.noBlank()?.also { docName -> this.name = docName }
if (this is AuthenticationSupported && document.credentials.let { it.username.isNotBlank() || it.password.isNotBlank() })
credentials { this.username = document.credentials.username; this.password = document.credentials.password }
if (document.content.isEmpty().not()) content {
if (!document.content.isEmpty()) content {
/**
* 使用 ":" 分割字符串
* @param size 期望的个数
@@ -100,9 +101,17 @@ internal object RepositoryManager {
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") })
}
/**
* 对旧版本不兼容的方法打印警告信息
* @param name 方法名称
*/
fun warnIfNotSupport(name: String) = SLog.warn("Current Gradle ${GradleHelper.version} not support \"$name\"")
document.content.exclude.also {
it.group().noEmpty()?.forEach { e -> excludeGroup(e) }
it.groupAndSubgroups().noEmpty()?.forEach { e -> excludeGroupAndSubgroups(e) }
runCatching {
it.groupAndSubgroups().noEmpty()?.forEach { e -> excludeGroupAndSubgroups(e) }
}.onFailure { warnIfNotSupport(name = "excludeGroupAndSubgroups") }
it.groupByRegex().noEmpty()?.forEach { e -> excludeGroupByRegex(e) }
it.module().noEmpty()?.forEachParams(size = 2) { e -> excludeModule(e[0], e[1]) }
it.moduleByRegex().noEmpty()?.forEachParams(size = 2) { e -> excludeModuleByRegex(e[0], e[1]) }
@@ -111,7 +120,9 @@ internal object RepositoryManager {
}
document.content.include.also {
it.group().noEmpty()?.forEach { e -> includeGroup(e) }
it.groupAndSubgroups().noEmpty()?.forEach { e -> includeGroupAndSubgroups(e) }
runCatching {
it.groupAndSubgroups().noEmpty()?.forEach { e -> includeGroupAndSubgroups(e) }
}.onFailure { warnIfNotSupport(name = "includeGroupAndSubgroups") }
it.groupByRegex().noEmpty()?.forEach { e -> includeGroupByRegex(e) }
it.module().noEmpty()?.forEachParams(size = 2) { e -> includeModule(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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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

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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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")
@@ -85,7 +85,7 @@ internal object Dependencies {
* 当前是否不存在依赖
* @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
* https://github.com/HighCapable/SweetDependency
*
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* 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
@@ -59,7 +59,7 @@ internal object Repositories {
* 当前是否不存在存储库
* @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