forked from micronaut-projects/micronaut-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
125 lines (106 loc) · 3.12 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
plugins {
id 'java-platform'
}
group projectGroupId
version projectVersion
apply plugin: 'maven-publish'
boolean micronautSnapshot = rootProject.version.toString().endsWith("-SNAPSHOT")
def excludedProjects = [
"benchmarks",
"test-suite",
"test-suite-groovy",
"test-suite-helper",
"test-suite-kotlin",
"test-utils"
]
publishing {
afterEvaluate {
publications {
maven(MavenPublication) {
artifactId("micronaut-bom")
from components.javaPlatform
pom.withXml {
def xml = asNode()
xml.children().find {
it.name().localPart == 'packaging'
} + pomInfo
for(dep in dependencyVersions) {
setBomVersion(dep, xml)
}
for(dep in bomVersions) {
setBomVersion(dep, xml)
}
}
}
}
}
}
private void setBomVersion(Map.Entry<Object, Object> dep, xml) {
String property = "\${${dep.key}.version}"
def info = dep.value
def version = info.version
def group = info.group
if (group && version) {
def modules = []
if (info.name) {
modules << info.name
}
if (info.modules) {
modules.addAll(info.modules)
}
for (module in modules) {
def pomDep = xml.dependencyManagement.dependencies.dependency.find {
it.artifactId.text() == module &&
it.groupId.text() == group
}
if (pomDep != null) {
pomDep.version.first().setValue(property)
}
}
}
}
ext.extraPomInfo = {
delegate.properties {
for(dep in dependencyVersions) {
"${dep.key}.version"(dep.value.version)
}
for(dep in bomVersions) {
"${dep.key}.version"(dep.value.version)
}
}
}
javaPlatform {
allowDependencies()
}
dependencies {
for (dep in bomVersions) {
def info = dep.value
def versionExpr = info.version
api platform("$info.group:$info.name:$versionExpr")
}
constraints {
for (Project p : rootProject.subprojects) {
if (!p.subprojects.empty) continue
if (p.name.contains("bom")) continue
if (excludedProjects.contains(p.name)) continue
api "$p.group:micronaut-$p.name:$p.version"
}
for (dep in dependencyVersions) {
def info = dep.value
// don't include snapshots
if (info.version.toString().endsWith("-SNAPSHOT") && !micronautSnapshot) {
continue
}
def versionExpr = dep.value.version
if (info.name) {
api "$info.group:$info.name:$versionExpr"
}
if (info.modules) {
for (m in info.modules) {
api "$info.group:$m:$versionExpr"
}
}
}
}
}
apply plugin: "io.micronaut.build.publishing"