19 Commits
1.0.1 ... 1.0.2

Author SHA1 Message Date
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
141 changed files with 441 additions and 281 deletions

View File

@@ -64,6 +64,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

@@ -9,4 +9,14 @@
- 使用 `net.lingala.zip4j` 取代 JDK 默认创建压缩文档功能修复在 Windows 平台中 Gradle 8.0.2+ 版本创建的 JAR 损坏导致找不到生成的 Class 问题
- 重构自动生成代码部分的装载功能,增加可能找不到 Class 的错误提示
- 新增在设置了未定义版本的插件依赖条件下直接运行自动装配相关 Gradle Task 将抛出异常
- 修复可能的旧版本 Gradle 在使用 `repositories``content` 功能会抛出异常
- 修复可能的旧版本 Gradle 在使用 `repositories``content` 功能会抛出异常
## 1.0.2 | 2023.09.26
- 自动生成代码功能将始终输出源码文件,以方便在生成失败的时候进行调试
- 修复部分连续名称的依赖可能导致生成失败的问题
- 修复插件自身检查更新功能失效
- 修复 Gradle 生命周期问题,可能导致 `autowire` 方法的项目作用域不正确
- 改进并采用 Gradle 项目命名规范
- 新增依赖命名空间可启用或禁用生成功能,更新后需要参考文档自行迁移部分配置文件的节点名称否则会发生错误
- 新增使用 `<plugins>::``<libraries>::` 可以访问其它节点的依赖名称、别名并设置到 `version-ref` 功能

View File

@@ -11,4 +11,15 @@
- 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`
- 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`

View File

@@ -2,7 +2,7 @@
在开始使用之前,建议你仔细阅读此文档,以便你能更好地了解它的作用方式与功能。
你可以在项目的根目录找到 examples 中的 Demo并参考此文档食用效果更佳。
你可以在项目的根目录找到 samples 中的 Demo并参考此文档食用效果更佳。
## 工作原理
@@ -157,11 +157,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
# 依赖版本过滤器
# 如果你需要排除一些不希望被更新到的依赖版本 (例如测试版本) 可以手动进行配置
# 默认情况下过滤器已帮你自动排除测试版本,无需对此项进行配置
@@ -338,6 +346,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:
@@ -381,6 +392,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" 中存在的版本 (内置过滤器或排除列表)

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
@@ -166,11 +166,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
@@ -358,6 +368,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:
@@ -406,6 +419,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)

View File

@@ -1,13 +1,13 @@
# Project Configuration
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/HighCapable/SweetDependency
project.groupName=com.highcapable.sweetdependency
project.moduleName=sweet-dependency
project.version=1.0.1
project.version=1.0.2
project.licence.name=Apache License 2.0
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.email=qzmmcn@163.com
# Gradle Plugin Configuration

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.1"
id("com.highcapable.sweetproperty") version "1.0.2"
id("com.highcapable.sweetdependency") version "1.0.2"
id("com.highcapable.sweetproperty") version "1.0.3"
}
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

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

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,26 +140,33 @@ 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())
@@ -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
@@ -208,16 +233,17 @@ internal data class RootConfigDocument(
else if (artifact.version().isBlank.not() && artifact.versionRef.isNotBlank() && duplicate.not())
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

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

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

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

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

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

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.not()) it else it.drop(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/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

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,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/6.
* This file is created by fankes on 2023/6/6.
*/
package com.highcapable.sweetdependency.manager

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

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

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/21.
* This file is created by fankes on 2023/5/21.
*/
package com.highcapable.sweetdependency.manager.helper

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/13.
* This file is created by fankes on 2023/6/13.
*/
package com.highcapable.sweetdependency.manager.helper
@@ -76,9 +76,9 @@ internal object DependencyDeployHelper {
* @param settings 当前设置
*/
internal fun generateVersionCatalogs(settings: Settings) {
val pluginsNamespace = SweetDependencyConfigs.document.preferences().dependenciesNamespace.plugins()
runCatching {
settings.dependencyResolutionManagement.versionCatalogs.create(pluginsNamespace) {
val pluginsOption = SweetDependencyConfigs.document.preferences().dependenciesNamespace.plugins
if (pluginsOption.isEnable) runCatching {
settings.dependencyResolutionManagement.versionCatalogs.create(pluginsOption.name()) {
Dependencies.plugins().forEach { (dependencyName, artifact) ->
if (GradleTaskManager.isInternalRunningTask && artifact.version().isAutowire) SError.make(
"""
@@ -140,8 +140,14 @@ internal object DependencyDeployHelper {
* @param rootProject 当前根项目
*/
internal fun resolveAccessors(rootProject: Project) {
val librariesOption = SweetDependencyConfigs.document.preferences().dependenciesNamespace.libraries
if (librariesOption.isEnable.not()) {
accessorsPomData.relativePomPath.toFile().takeIf { it.exists() }?.deleteRecursively()
accessorsGenerator.clearGeneratedData()
return
}
if (Dependencies.isOutdate || accessorsDir.resolve(accessorsPomData.relativePomPath).isEmpty())
accessorsGenerator.build().compile(accessorsPomData, accessorsDir.absolutePath, accessorsGenerator.compileStubFiles)
accessorsGenerator.build(librariesOption.name()).compile(accessorsPomData, accessorsDir.absolutePath, accessorsGenerator.compileStubFiles)
rootProject.addDependencyToBuildScript(accessorsDir.absolutePath, accessorsPomData)
}
@@ -185,7 +191,7 @@ internal object DependencyDeployHelper {
}
/**
* 处理自动装配的依赖
* 处理自动装配的依赖
* @param project 当前项目 - 默认为 [ProjectTransaction.current]
* @param params 当前参数数组
* @return [Any]

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/6.
* This file is created by fankes on 2023/6/6.
*/
package com.highcapable.sweetdependency.manager.maven

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/6.
* This file is created by fankes on 2023/6/6.
*/
package com.highcapable.sweetdependency.manager.maven.entity

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