-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.gradle
80 lines (65 loc) · 2.54 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
plugins {
id 'maven-publish'
}
group 'cz.orany'
version getTagOrDefault('1.0.0-SNAPSHOT')
publishing {
repositories {
maven {
name = 'GitHub'
url = uri('https://maven.pkg.github.com/' + System.getenv('GITHUB_REPOSITORY'))
credentials {
username = ''
password = System.getenv('GITHUB_TOKEN')
}
}
}
publications {
maven(MavenPublication) {
pom.withXml {
def xml = asNode()
xml.children().last() + {
def mkp = delegate
File versionPropertiesFile = new File("$projectDir/src/main/versions/_versions.properties")
def versionProperties = new Properties()
versionProperties.load(new StringReader(versionPropertiesFile.text))
mkp.properties {
for (dep in versionProperties.entrySet()) {
mkp."${dep.key}"(dep.value)
}
}
mkp.dependencyManagement {
mkp.dependencies {
for (File propertyFile in new File("$projectDir/src/main/versions").listFiles()) {
if (propertyFile.name == '_versions.properties') {
continue
}
String groupIdFromFile = propertyFile.name - '.properties'
def versions = new Properties()
versions.load(new StringReader(propertyFile.text))
for (pair in versions.entrySet()) {
mkp.dependency {
String finalVersion = pair.value ==~ /\d.*/ ? pair.value : "\${$pair.value}"
mkp.groupId groupIdFromFile
mkp.artifactId pair.key
mkp.version finalVersion
}
}
}
}
}
}
}
}
}
}
private static String getTagOrDefault(String defaultValue) {
String ref = System.getenv('GITHUB_REF')
if (!ref) {
return defaultValue
}
if (ref.startsWith('refs/tags/')) {
return ref.substring('refs/tags/'.length())
}
return defaultValue
}