-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle.kts
130 lines (115 loc) · 3.27 KB
/
settings.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* 根项目名称 */
rootProject.name = "spring-boot-plus"
//enableFeaturePreview("VERSION_CATALOGS")
//dependencyResolutionManagement {
// versionCatalogs {
//
// create("libs") {
// library("spring-boot", "org.springframework.boot", "spring-boot-gradle-plugin").version("2.5.0")
// }
// }
//}
/* 插件管理 */
pluginManagement {
/* 插件仓库 */
repositories {
gradlePluginPortal()
maven {
url = uri("https://repo.spring.io/plugins-release")
}
}
resolutionStrategy {
eachPlugin {
// println(">>>>>>>>>>>> ${requested.id.id} ")
// println(">>>>>>>>>>>> ${requested.id.namespace} ")
// println(">>>>>>>>>>>> ${requested.id.name} ")
// if (requested.id.namespace == "com.example") {
// useModule("com.example:sample-plugins:1.0.0")
// }
}
}
/* 插件版本管理 */
plugins {
id("org.asciidoctor.jvm.convert") version "3.1.0"
id("org.asciidoctor.jvm.convert") version "3.1.0"
id("com.github.shalousun.smart-doc") version "2.2.2"
// id("org.springframework.boot") version "2.3.5.RELEASE"
// id("io.spring.dependency-management") version "1.0.11.RELEASE"
}
}
/**
* 获取所有项目信息
*/
val projectInfos = fileTree(rootDir) {
val excludes = gradle.startParameter.projectProperties["excludeProjects"]?.split(",")
include("**/*.gradle", "**/*.gradle.kts")
exclude("build", "**/gradle", "settings.gradle", "buildSrc", "/build.gradle", ".*", "out")
}.files.stream()
/* 非根项目 */
.filter { file -> !file.parentFile.relativeTo(rootDir).name.isNullOrEmpty() }
.map { file -> ProjectInfo(rootDir, file) }
.sorted()
.collect(java.util.stream.Collectors.toList())
.filter { info -> !Regex(".*(examples|restful|dingtalk).*$").matches(info.name) }
projectInfos.forEach {
include(it.path)
}
/**
* 更新项目信息
*/
projectInfos.forEach {
val project = project(it.dir)
project.name = it.name
project.projectDir = it.dir
project.buildFileName = it.buildFileName
}
/**
* 项目详细信息
* @author Wu Yujie
* @email [email protected]
* @time 2022/08/06 12:18
*/
class ProjectInfo(rootFile: File, buildFile: File) : Comparable<ProjectInfo> {
/**
* 项目所在目录
*/
val dir: File
/**
* gradle build 文件名称
*/
val buildFileName: String
/**
* 项目路径
*/
val path: String
/**
* 项目名称
*/
var name: String
init {
dir = buildFile.parentFile
buildFileName = buildFile.name
val isDefaultName = buildFile.name == "build.gradle" || buildFile.name == "build.gradle.kts"
val isKotlin = buildFile.name.endsWith(".kts")
val paths = dir.relativeTo(rootFile).path.split(File.separator)
path = ":${paths.joinToString(":")}"
name = if (!isDefaultName) {
if (isKotlin) {
buildFile.name.replace(".gradle.kts", "")
} else {
buildFile.name.replace(".gradle", "")
}
} else {
"${rootFile.name}-${paths.joinToString("-")}"
}
}
override fun compareTo(other: ProjectInfo): Int {
return this.path.compareTo(other.path)
}
override fun toString(): String {
return "Project Name\t\t-> ${name}\n" +
"Project Path\t\t-> ${path}\n" +
"Project Dir\t\t\t-> ${dir.absolutePath}\n" +
"buildFileName\t\t-> ${buildFileName}\n"
}
}