forked from impossibl/pgjdbc-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
104 lines (81 loc) · 2.96 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
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseTask
import de.undercouch.gradle.tasks.download.Download
plugins {
base
id("de.undercouch.download") version "3.4.3"
id("com.github.breadmoirai.github-release") version Versions.githubReleasePlugin
}
allprojects {
apply {
plugin("idea")
}
group = "com.impossibl.pgjdbc-ng"
version = "0.9-SNAPSHOT"
extra["isSnapshot"] = version.toString().endsWith("SNAPSHOT")
val organization by extra(mapOf(
"name" to "impossibl.com",
"url" to "https://github.com"
))
val url by extra("${organization["url"]}/pgjdbc-ng")
extra["issuesUrl"] = "$url/issues"
extra["scmUrl"] = "scm:$url.git"
extra["scmGitUrl"] = "scm:[email protected]:impossibl/pgjdbc-ng.git"
}
subprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
val isSnapshot: Boolean by project
tasks {
val downloadTasks = listOf(
centralDownload("com.impossibl.pgjdbc-ng", "pgjdbc-ng-all"),
centralDownload("com.impossibl.pgjdbc-ng", "pgjdbc-ng", "javadoc"),
centralDownload("com.impossibl.pgjdbc-ng", "pgjdbc-ng", "sources"),
centralDownload("com.impossibl.pgjdbc-ng", "spy"),
centralDownload("com.impossibl.pgjdbc-ng", "spy", "javadoc"),
centralDownload("com.impossibl.pgjdbc-ng", "spy", "sources"),
centralDownload("com.impossibl.pgjdbc-ng.tools", "udt-gen-all"),
centralDownload("com.impossibl.pgjdbc-ng.tools", "udt-gen", "javadoc"),
centralDownload("com.impossibl.pgjdbc-ng.tools", "udt-gen", "sources")
)
val downloadArtifacts = register<Task>("downloadArtifacts") {
outputs.files(downloadTasks.flatMap { it.get().outputFiles })
dependsOn(downloadTasks)
}
named<GithubReleaseTask>("githubRelease") {
dependsOn(downloadArtifacts)
setAuthorization("token ${project.properties["github.token"]?.toString() ?: ""}")
setOwner("impossibl")
setRepo("pgjdbc-ng")
setTagName("v$version")
setTargetCommitish("develop")
setDraft(true)
setPrerelease(isSnapshot)
setOverwrite(true)
setBody(
"""
## [Release Notes](https://impossibl.github.io/pgjdbc-ng/docs/$version/release-notes)
## [User Guide](https://impossibl.github.io/pgjdbc-ng/docs/$version/user-guide)
""".trimIndent().trim()
)
releaseAssets.from(downloadArtifacts)
}
}
fun centralDownload(group: String, artifact: String, classifier: String? = null): TaskProvider<Download> {
val base = "http://oss.sonatype.org/service/local/artifact/maven/redirect"
val repo = if(isSnapshot) "snapshots" else "releases"
val queryClassifier = classifier?.let { "&c=$it" } ?: ""
val dest = "$buildDir/artifacts/$artifact-$version${classifier?.let { "-$it" } ?: ""}.jar"
tasks.named("clean") {
doFirst {
file(dest).delete()
}
}
return tasks.register<Download>("downloadCentral" + "$group-$artifact-${classifier ?: ""}") {
outputFiles.add(file(dest))
src("$base?r=$repo&g=$group&a=$artifact$queryClassifier&v=$version")
dest(dest)
}
}