-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.gradle.kts
114 lines (102 loc) · 3.39 KB
/
release.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
import org.gradle.api.tasks.bundling.Jar
plugins.apply("maven-publish")
fun Project.publishing(configure: PublishingExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("publishing", configure)
val Project.publishing: PublishingExtension get() =
(this as ExtensionAware).extensions.getByName("publishing") as PublishingExtension
val Project.sourceSets: SourceSetContainer get() =
(this as ExtensionAware).extensions.getByName("sourceSets") as SourceSetContainer
val SourceSetContainer.main: NamedDomainObjectProvider<SourceSet>
get() = named<SourceSet>("main")
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val dokkaTask by tasks.named("dokka")
val dokkaJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(dokkaTask)
}
publishing {
repositories {
if (project.hasProperty("sonatypeUrl")) {
maven {
name = "sonatype"
val sonatypeUrl: String by project
url = uri(sonatypeUrl)
val sonatypeUsername: String? by project
val sonatypePassword: String? by project
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
if (project.hasProperty("githubPackageUrl")) {
maven {
name = "githubPackages"
val githubPackageUrl: String by project
url = uri(githubPackageUrl)
val githubUsername: String? by project
val githubToken: String? by project
credentials {
username = githubUsername
password = githubToken
}
}
}
}
publications {
create<MavenPublication>("library") {
from(components["kotlin"])
artifact(sourcesJar.get())
artifact(dokkaJar.get())
pom {
name.set(project.name)
packaging = "jar"
description.set("Testing framework on JUnit Platform with Give-When-Then style.")
url.set("https://github.com/mike-neck/ktcheck")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/mit-license.php")
}
}
developers {
developer {
id.set("mike-neck")
name.set("Shinya Mochida")
email.set("jkrt3333[at]gmail.com")
}
}
scm {
connection.set("scm:git:https://github.com/mike-neck/ktcheck.git")
developerConnection.set("scm:git:https://github.com/mike-neck/ktcheck.git")
url.set("https://github.com/mike-neck/ktcheck")
}
}
}
}
}
val privateKey: String? by project
val pgpPassword: String? by project
if (privateKey != null && pgpPassword != null) {
plugins.apply("signing")
fun Project.signing(configure: SigningExtension.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("signing", configure)
signing {
useInMemoryPgpKeys(privateKey, pgpPassword)
sign(publishing.publications["library"])
}
}
task("showType") {
doLast {
val publishToMavenLocal = tasks.getByPath("publish")
println(publishToMavenLocal.javaClass.canonicalName)
println(publishToMavenLocal.group)
println(publishToMavenLocal.dependsOn.map { it.toString() })
}
}
if (!project.hasProperty("KT_CHECK_VERSION")) {
tasks.find { it.name == "publishLibraryPublicationToSonatypeRepository" }?.enabled = false
}