mirror of
https://github.com/HighCapable/SweetDependency.git
synced 2025-09-04 01:35:46 +08:00
refactor: using new way to checking load build script class exists
This commit is contained in:
@@ -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()
|
||||
|
||||
/**
|
||||
* 获取指定项目部署的插件依赖数组 (实时)
|
||||
|
@@ -120,7 +120,7 @@ internal object DependencyDeployHelper {
|
||||
* @param rootProject 当前根项目
|
||||
*/
|
||||
internal fun resolveAccessors(rootProject: Project) {
|
||||
if (Dependencies.isOutdate || accessorsDir.isEmpty())
|
||||
if (Dependencies.isOutdate || accessorsDir.resolve(accessorsPomData.relativePomPath).isEmpty())
|
||||
accessorsGenerator.build().compile(accessorsPomData, accessorsDir.absolutePath, accessorsGenerator.compileStubFiles)
|
||||
rootProject.addDependencyToBuildScript(accessorsDir.absolutePath, accessorsPomData)
|
||||
}
|
||||
@@ -132,7 +132,14 @@ internal object DependencyDeployHelper {
|
||||
*/
|
||||
internal fun deployAccessors(project: Project, extension: ExtensionAware) =
|
||||
accessorsGenerator.librariesClasses.forEach { (name, className) ->
|
||||
extension.getOrCreate(name, project.loadBuildScriptClass(className))
|
||||
val accessorsClass = project.loadBuildScriptClass(className) ?: SError.make(
|
||||
"""
|
||||
Generated class "$className" not found, stop loading $project
|
||||
Please check whether the initialization process is interrupted and re-run Gradle Sync
|
||||
If this doesn't work, please manually delete the entire "${accessorsDir.absolutePath}" directory
|
||||
""".trimIndent()
|
||||
)
|
||||
extension.getOrCreate(name, accessorsClass)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user