forked from smclab/caldav-sync
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-bom.gradle
102 lines (82 loc) · 2.29 KB
/
build-bom.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
/*
* Define logic to create and publish a bill of materials with all
* modules in this repository (all packaged as jar).
*
* To enable this logic you have to start gradle-wrapper with
* "-Penable.bom.tasks=true".
* Common tasks are "publish" and "publishToMavenLocal"
*
*/
apply plugin: "maven-publish"
ext.pomInfo = {
delegate.licenses {
delegate.license {
delegate.name 'Unpublished Copyright SMC TREVISO SRL.'
//delegate.url 'https://www.smc.it/licenses/XXXX.txt'
delegate.distribution 'repo'
}
}
delegate.developers {
delegate.developer {
delegate.name "maumar"
delegate.organization "SMC Treviso srl"
}
}
}
publishing {
afterEvaluate {
repositories {
maven {
credentials {
username project.properties['registryUsername']
password project.properties['registryPassword']
}
if (registrySuffix == "-SNAPSHOT") {
url project.properties['nexus.snapshots.url']
}
else {
url project.properties['nexus.releases.url']
}
}
}
publications {
maven(MavenPublication) {
version "${productVersion}${registrySuffix}"
artifactId "${productName}.bom"
from components.javaPlatform
pom.withXml {
def xml = asNode()
xml.children().find {
it.name().localPart == 'packaging'
} + pomInfo
// println "withXml"
// Replace project name with Bundle-SymbolicName
rootProject.subprojects.each { prj ->
if (!prj.subprojects.empty) return
if (prj.path.startsWith(":bom") || prj.path.startsWith(":plugins-sdk")) return
String artifactName = prj.property('archivesBaseName')
// println "${prj.name} ${artifactName} ${prj.version}"
def pomDep = xml.dependencyManagement.dependencies.dependency.find {
it.artifactId.text() == prj.name && it.groupId.text() == group
}
if (pomDep != null && artifactName != null) {
pomDep.artifactId.first().setValue(artifactName)
}
}
// println "done"
}
}
}
}
}
dependencies {
constraints {
println "Inject dependencies"
rootProject.subprojects.each { prj ->
if (!prj.subprojects.empty) return
if (prj.path.startsWith(":bom") || prj.path.startsWith(":plugins-sdk")) return
//runtime project("${prj.path}")
api project("${prj.path}")
}
}
}