-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
133 lines (116 loc) · 5.03 KB
/
build.gradle
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
131
132
133
plugins {
id("org.openrewrite.rewrite").version("6.29.3")
}
import org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint
import org.gradle.api.internal.catalog.DependencyModel
import groovy.xml.XmlParser
import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors
group = 'io.github.honhimw'
version = libs.versions.version.get()
allprojects {
configurations {
using {
visible false
canBeResolved false
canBeConsumed false
canBeDeclared true
}
}
afterEvaluate {
plugins.withType(JavaPlugin).every {
configurations {
compileClasspath { extendsFrom using }
runtimeClasspath { extendsFrom using }
annotationProcessor { extendsFrom using }
testCompileClasspath { extendsFrom using }
testRuntimeClasspath { extendsFrom using }
testAnnotationProcessor { extendsFrom using }
}
}
plugins.withType(JavaLibraryPlugin).every {
configurations {
compileOnly { extendsFrom annotationProcessor }
testCompileOnly { extendsFrom testAnnotationProcessor }
}
}
}
}
def modules = subprojects.findAll {
it.buildFile.exists()
}
def bom = project(':i-spring-enhance-bom')
def libraries = modules - bom - project(':i-spring-web-test')
configure(libraries) {
apply from: rootProject.file('buildSrc/library.gradle')
dependencies {
using platform(bom)
}
jar {
enabled(true)
archiveClassifier = ''
}
}
tasks.register('deployAll') {
group 'deploy'
dependsOn ':i-common-utilities:publishToMavenLocal'
dependsOn ':i-core:publishToMavenLocal'
dependsOn ':i-spring-enhance-bom:publishToMavenLocal'
dependsOn ':i-spring-auto-configure:publishToMavenLocal'
dependsOn ':i-spring-extend:publishToMavenLocal'
dependsOn ':i-spring-boot-project:publishToMavenLocal'
dependsOn ':i-spring-web-config-core:publishToMavenLocal'
dependsOn ':i-spring-web-config-starter:publishToMavenLocal'
dependsOn ':i-spring-cache-core:publishToMavenLocal'
dependsOn ':i-spring-cache-starter:publishToMavenLocal'
dependsOn ':i-spring-data-ddd:i-spring-ddd-common:publishToMavenLocal'
dependsOn ':i-spring-data-ddd:i-spring-ddd-jpa:publishToMavenLocal'
dependsOn ':i-spring-data-ddd:i-spring-ddd-starter:publishToMavenLocal'
}
apply from: rootProject.file('buildSrc/rewrite.gradle')
tasks.register('checkLibrariesUpdate') {
def pool = Executors.newFixedThreadPool(4)
def libsDef = [
'spring-boot-dependencies' : buildModel('org.springframework.boot', 'spring-boot-dependencies', 'spring-boot-dependencies', libs.versions.spring.boot.dependencies.get()),
'spring-cloud-dependencies' : buildModel('org.springframework.cloud', 'spring-cloud-dependencies', 'spring-cloud-dependencies', libs.versions.spring.cloud.dependencies.get()),
'spring-cloud-alibaba-dependencies': buildModel('com.alibaba.cloud', 'spring-cloud-alibaba-dependencies', 'spring-cloud-alibaba-dependencies', libs.versions.spring.cloud.alibaba.dependencies.get()),
'springdoc-openapi' : buildModel('org.springdoc', 'springdoc-openapi', 'springdoc-openapi', libs.versions.springdoc.openapi.get()),
]
libsDef.putAll(defInLibs())
def countDownLatch = new CountDownLatch(libsDef.size())
println "Start check libraries update, libraries count: ${libsDef.size()}"
libsDef.each {
def dependency = it.value
pool.execute {
def latestVersion = getLatestVersion(dependency.group, dependency.name)
if (dependency.version.requiredVersion != latestVersion) {
println "$dependency.versionRef = \"${dependency.version.requiredVersion}\" -> \"${latestVersion}\""
}
countDownLatch.countDown()
}
}
countDownLatch.await()
println 'Finish check libraries update'
pool.shutdown()
}
Map<String, DependencyModel> defInLibs() {
def versionCatalogsExtension = project.extensions.getByType(VersionCatalogsExtension)
for (final def versionCatalog in versionCatalogsExtension) {
return versionCatalog.config.libraries as Map<String, DependencyModel>
}
return [:]
}
DependencyModel buildModel(String group, String name, String versionRef, String version) {
return new DependencyModel(
group, name, versionRef, new DefaultImmutableVersionConstraint(version), null
)
}
String getLatestVersion(String groupId, String artifactId) {
def baseUrl = "https://repo1.maven.org/maven2"
def groupPath = groupId.replace('.', '/')
def url = "${baseUrl}/${groupPath}/${artifactId}/maven-metadata.xml"
def response = uri(url).toURL().openStream().withCloseable { stream -> return stream.bytes }
def xmlContent = new XmlParser().parseText(new String(response, 'UTF-8'))
def latestVersion = xmlContent?.versioning?.latest?.text()
return latestVersion
}