@@ -24,6 +24,7 @@ package com.highcapable.sweetdependency.manager
2424import com.highcapable.sweetdependency.document.PreferencesDocument
2525import com.highcapable.sweetdependency.document.RepositoryDocument
2626import com.highcapable.sweetdependency.exception.SweetDependencyUnresolvedException
27+ import com.highcapable.sweetdependency.gradle.helper.GradleHelper
2728import com.highcapable.sweetdependency.manager.const.AdditionalRepositories
2829import com.highcapable.sweetdependency.manager.content.Repositories
2930import com.highcapable.sweetdependency.plugin.config.content.SweetDependencyConfigs
@@ -100,9 +101,17 @@ internal object RepositoryManager {
100101 fun List<String>.forEachParams (size : Int , result : (List <String >) -> Unit ) = forEach {
101102 result(it.split(" :" ).also { e -> if (e.size != size) SError .make(" Missing argument in content configuration" ) })
102103 }
104+
105+ /* *
106+ * 对旧版本不兼容的方法打印警告信息
107+ * @param name 方法名称
108+ */
109+ fun warnIfNotSupport (name : String ) = SLog .warn(" Current Gradle ${GradleHelper .version} not support \" $name \" " )
103110 document.content.exclude.also {
104111 it.group().noEmpty()?.forEach { e -> excludeGroup(e) }
105- it.groupAndSubgroups().noEmpty()?.forEach { e -> excludeGroupAndSubgroups(e) }
112+ runCatching {
113+ it.groupAndSubgroups().noEmpty()?.forEach { e -> excludeGroupAndSubgroups(e) }
114+ }.onFailure { warnIfNotSupport(name = " excludeGroupAndSubgroups" ) }
106115 it.groupByRegex().noEmpty()?.forEach { e -> excludeGroupByRegex(e) }
107116 it.module().noEmpty()?.forEachParams(size = 2 ) { e -> excludeModule(e[0 ], e[1 ]) }
108117 it.moduleByRegex().noEmpty()?.forEachParams(size = 2 ) { e -> excludeModuleByRegex(e[0 ], e[1 ]) }
@@ -111,7 +120,9 @@ internal object RepositoryManager {
111120 }
112121 document.content.include.also {
113122 it.group().noEmpty()?.forEach { e -> includeGroup(e) }
114- it.groupAndSubgroups().noEmpty()?.forEach { e -> includeGroupAndSubgroups(e) }
123+ runCatching {
124+ it.groupAndSubgroups().noEmpty()?.forEach { e -> includeGroupAndSubgroups(e) }
125+ }.onFailure { warnIfNotSupport(name = " includeGroupAndSubgroups" ) }
115126 it.groupByRegex().noEmpty()?.forEach { e -> includeGroupByRegex(e) }
116127 it.module().noEmpty()?.forEachParams(size = 2 ) { e -> includeModule(e[0 ], e[1 ]) }
117128 it.moduleByRegex().noEmpty()?.forEachParams(size = 2 ) { e -> includeModuleByRegex(e[0 ], e[1 ]) }
0 commit comments