-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle.kts
173 lines (154 loc) · 5.86 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.jetbrains.dokka.gradle.DokkaTask
import java.time.Duration
import java.time.Instant
description = "Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema"
extra["isReleaseVersion"] = !version.toString().endsWith("SNAPSHOT")
plugins {
kotlin("jvm")
id("org.jetbrains.dokka") apply false
`java-library`
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin")
}
allprojects {
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
}
repositories {
mavenLocal()
mavenCentral()
}
}
subprojects {
val kotlinJdkVersion: String by project
val junitVersion: String by project
val currentProject = this
apply(plugin = "kotlin")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
kotlin {
jvmToolchain(kotlinJdkVersion.toInt())
}
println("${currentProject.group}:${currentProject.name}")
tasks {
jar {
manifest {
attributes["Built-By"] = "https://github.com/ermadmi78"
attributes["Build-Jdk"] =
"${System.getProperty("java.version")} (${System.getProperty("java.vendor")} ${System.getProperty("java.vm.version")})"
attributes["Build-Timestamp"] = Instant.now().toString()
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
attributes["Implementation-Title"] = currentProject.name
attributes["Implementation-Version"] = project.version
}
}
test {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = FULL
useJUnitPlatform()
}
// published artifacts
val jarComponent = currentProject.components.getByName("java")
val sourcesJar by registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val dokka = named("dokkaJavadoc", DokkaTask::class)
val javadocJar by registering(Jar::class) {
archiveClassifier.set("javadoc")
from("$buildDir/dokka/javadoc")
dependsOn(dokka)
}
publishing {
repositories {
if (!(rootProject.extra["isReleaseVersion"] as Boolean)) {
mavenLocal()
}
}
publications {
withType<MavenPublication> {
pom {
name.set("${currentProject.group}:${currentProject.name}")
url.set("https://github.com/ermadmi78/kobby")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Dmitry Ermakov")
email.set("ermadmi78@gmail.com")
url.set("https://www.linkedin.com/in/ermadmi78")
}
}
scm {
connection.set("scm:git:git@github.com:ermadmi78/kobby.git")
developerConnection.set("scm:git:git@github.com:ermadmi78/kobby.git")
url.set("https://github.com/ermadmi78/kobby")
}
// child projects need to be evaluated before their description can be read
val mavenPom = this
afterEvaluate {
mavenPom.description.set(currentProject.description)
}
}
}
if (currentProject.name != "kobby-gradle-plugin") {
create<MavenPublication>("mavenJava") {
from(jarComponent)
// no need to publish sources or javadocs for SNAPSHOT builds
if (rootProject.extra["isReleaseVersion"] as Boolean) {
artifact(sourcesJar.get())
artifact(javadocJar.get())
}
}
}
}
}
signing {
setRequired {
rootProject.extra["isReleaseVersion"] as Boolean &&
(gradle.taskGraph.hasTask("publish") || gradle.taskGraph.hasTask("publishPlugins"))
}
val signingKey: String? = System.getenv("GPG_SECRET")
val signingPassword: String? = System.getenv("GPG_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
testImplementation(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
}
}
tasks {
jar {
enabled = false
}
if (rootProject.extra["isReleaseVersion"] as Boolean) {
nexusPublishing {
repositories {
sonatype {
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
transitionCheckOptions {
maxRetries.set(60)
delayBetween.set(Duration.ofMillis(5000))
}
}
}
}