forked from ExpediaGroup/graphql-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
215 lines (196 loc) · 7.75 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import io.gitlab.arturbosch.detekt.detekt
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Duration
import java.time.Instant
description = "Libraries for running a GraphQL server in Kotlin"
extra["isReleaseVersion"] = !version.toString().endsWith("SNAPSHOT")
plugins {
kotlin("jvm")
id("org.jetbrains.dokka") apply false
id("org.jlleitschuh.gradle.ktlint")
id("io.gitlab.arturbosch.detekt")
jacoco
signing
`maven-publish`
id("io.github.gradle-nexus.publish-plugin")
}
allprojects {
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
}
repositories {
mavenCentral()
google()
mavenLocal {
content {
includeGroup("com.expediagroup")
}
}
}
}
subprojects {
val kotlinCoroutinesVersion: String by project
val kotlinJvmVersion: String by project
val kotlinVersion: String by project
val junitVersion: String by project
val mockkVersion: String by project
val detektVersion: String by project
val ktlintVersion: String by project
val jacocoVersion: String by project
val currentProject = this
apply(plugin = "kotlin")
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "jacoco")
apply(plugin = "java-library")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "maven-publish")
apply(plugin = "signing")
tasks {
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = kotlinJvmVersion
freeCompilerArgs = listOf("-Xjsr305=strict")
}
}
check {
dependsOn(jacocoTestCoverageVerification)
}
detekt {
toolVersion = detektVersion
config = files("${rootProject.projectDir}/detekt.yml")
}
ktlint {
version.set(ktlintVersion)
}
jacoco {
toolVersion = jacocoVersion
}
jar {
manifest {
attributes["Built-By"] = "Expedia Group"
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
}
// NOTE: in order to run gradle and maven plugin integration tests we need to have our build artifacts available in local repo
finalizedBy("publishToMavenLocal")
}
java {
// even though we don't have any Java code, since we are building using Java LTS version,
// this is required for Gradle to set the correct JVM versions in the module metadata
targetCompatibility = JavaVersion.VERSION_1_8
}
// 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 {
publications {
withType<MavenPublication> {
pom {
name.set("${currentProject.group}:${currentProject.name}")
url.set("https://github.com/ExpediaGroup/graphql-kotlin")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
organization {
name.set("Expedia Group")
name.set("https://www.expediagroup.com/")
}
developers {
developer {
name.set("Expedia Group Committers")
email.set("[email protected]")
organization.set("Expedia Group")
organizationUrl.set("https://www.expediagroup.com/")
}
}
scm {
connection.set("scm:git:git://github.com/ExpediaGroup/graphql-kotlin.git")
developerConnection.set("scm:git:git://github.com/ExpediaGroup/graphql-kotlin.git")
url.set("https://github.com/ExpediaGroup/graphql-kotlin")
}
// child projects need to be evaluated before their description can be read
val mavenPom = this
afterEvaluate {
mavenPom.description.set(currentProject.description)
}
}
}
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)
}
test {
useJUnitPlatform()
finalizedBy(jacocoTestReport)
}
}
dependencies {
implementation(kotlin("stdlib", kotlinVersion))
implementation(kotlin("reflect", kotlinVersion))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinCoroutinesVersion")
testImplementation(kotlin("test", kotlinVersion))
testImplementation(kotlin("test-junit5", kotlinVersion))
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
testImplementation("io.mockk:mockk:$mockkVersion")
}
}
tasks {
jar {
enabled = false
}
nexusPublishing {
repositories {
sonatype {
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
transitionCheckOptions {
maxRetries.set(60)
delayBetween.set(Duration.ofMillis(5000))
}
}
register("resolveIntegrationTestDependencies") {
// our Gradle and Maven integration tests run in separate VMs that will need access to the generated artifacts
// we will need to run them after artifacts are published to local m2 repo
for (graphQLKotlinProject in project.childProjects) {
dependsOn(":${graphQLKotlinProject.key}:publishToMavenLocal")
}
}
}