-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
191 lines (171 loc) · 6.61 KB
/
build.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import com.github.vlsi.gradle.publishing.dsl.simplifyXml
import com.github.vlsi.gradle.publishing.dsl.versionFromResolution
plugins {
`java-library`
`maven-publish`
id("com.github.vlsi.gradle-extensions")
id("com.github.vlsi.stage-vote-release")
}
repositories {
ivy {
url = uri("https://github.com/angular/clang-format/raw/")
content {
includeModule("com.github.angular", "clang-format")
}
patternLayout {
artifact("[revision]/bin/[classifier]/[module](.[ext])")
}
metadataSources { // skip downloading ivy.xml
artifact()
}
}
}
group = "com.github.autostyle"
releaseParams {
tlp.set("autostyle-clang-format")
organizationName.set("autostyle")
componentName.set("autostyle-clang-format")
prefixForProperties.set("gh")
svnDistEnabled.set(false)
sitePreviewEnabled.set(false)
nexus {
mavenCentral()
}
voteText.set {
"""
${it.componentName} v${it.version}-rc${it.rc} is ready for preview.
Git SHA: ${it.gitSha}
Staging repository: ${it.nexusRepositoryUri}
""".trimIndent()
}
}
val String.v: String get() = rootProject.extra["$this.version"] as String
val buildVersion = "autostyle-clang-format".v + releaseParams.snapshotSuffix
version = buildVersion
println("Building autostyle-clang-format $version")
class TargetPlatform(val os: OperatingSystemFamily, val architecture: MachineArchitecture) {
val id: String get() = "${os.name}_${architecture.name}"
}
fun targetPlatform(os: String, architecture: String): TargetPlatform =
TargetPlatform(objects.named(os), objects.named(architecture))
val platforms = mapOf(
targetPlatform(OperatingSystemFamily.WINDOWS, MachineArchitecture.X86) to "win32",
targetPlatform(OperatingSystemFamily.MACOS, MachineArchitecture.X86_64) to "darwin_x64",
targetPlatform(OperatingSystemFamily.LINUX, MachineArchitecture.X86_64) to "linux_x64"
)
dependencies {
for ((platform, classifier) in platforms) {
val ext = if (platform.os.isWindows) "exe" else ""
val conf = configurations.create("clangFormatBinary_${platform.id}")
conf("com.github.angular:clang-format:${"clang-format".v}:$classifier@$ext")
}
}
val binaries by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.NATIVE_RUNTIME))
}
outgoing {
variants {
for (platform in platforms.keys) {
create(platform.id) {
attributes {
attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, platform.os)
attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, platform.architecture)
}
}
}
}
}
}
(components["java"] as AdhocComponentWithVariants).addVariantsFromConfiguration(binaries) {
}
for (platform in platforms.keys) {
val jarTask = tasks.register<Jar>("package_${platform.id}") {
group = LifecycleBasePlugin.BUILD_GROUP
description = "Package clang-format ${platform.id}"
archiveClassifier.set(platform.id)
from(configurations.named("clangFormatBinary_${platform.id}").map { it.singleFile }) {
rename { "${project.name}-${platform.id}" }
}
}
binaries.outgoing.variants {
named(platform.id) {
artifact(jarTask)
}
}
}
tasks {
withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
withType<Jar>().configureEach {
manifest {
attributes["Bundle-License"] = "Apache-2.0"
attributes["Implementation-Title"] = "Autostyle clang-format"
attributes["Implementation-Version"] = project.version
attributes["Specification-Vendor"] = "Autostyle clang-format"
attributes["Specification-Version"] = project.version
attributes["Specification-Title"] = "Autostyle clang-format"
attributes["Implementation-Vendor"] = "Autostyle clang-format"
attributes["Implementation-Vendor-Id"] = "com.github.autostyle"
}
}
publishing {
publications {
create<MavenPublication>(project.name) {
artifactId = project.name
version = rootProject.version.toString()
description = project.description
from(project.components.get("java"))
versionFromResolution()
pom {
simplifyXml()
name.set(
(project.findProperty("artifact.name") as? String)
?: "Autostyle clang-format ${project.name.capitalize()}"
)
description.set(
project.description
?: "Autostyle clang-format ${project.name.capitalize()}"
)
developers {
developer {
id.set("vlsi")
name.set("Vladimir Sitnikov")
email.set("sitnikov.vladimir@gmail.com")
}
}
inceptionYear.set("2019")
url.set("https://github.com/autostyle/clang-format")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
comments.set("A business-friendly OSS license")
distribution.set("repo")
}
}
issueManagement {
system.set("GitHub")
url.set("https://github.com/autostyle/clang-format/issues")
}
scm {
connection.set("scm:git:https://github.com/autostyle/clang-format.git")
developerConnection.set("scm:git:https://github.com/autostyle/clang-format.git")
url.set("https://github.com/autostyle/clang-format")
tag.set("HEAD")
}
}
}
}
}
}