Skip to content

Commit 381673e

Browse files
authored
1 parent bac491d commit 381673e

File tree

38 files changed

+366
-303
lines changed

38 files changed

+366
-303
lines changed

build.gradle.kts

Lines changed: 7 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
import org.jetbrains.dokka.gradle.DokkaTask
2-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
31
import java.time.Duration
4-
import java.time.Instant
52

63
description = "Libraries for running a GraphQL server in Kotlin"
74
extra["isReleaseVersion"] = !version.toString().endsWith("SNAPSHOT")
85

6+
@Suppress("DSL_SCOPE_VIOLATION") // TODO: remove once KTIJ-19369 / Gradle#22797 is fixed
97
plugins {
10-
kotlin("jvm")
11-
id("org.jetbrains.dokka") apply false
12-
id("org.jlleitschuh.gradle.ktlint")
13-
id("io.gitlab.arturbosch.detekt")
14-
jacoco
15-
signing
16-
`maven-publish`
17-
id("io.github.gradle-nexus.publish-plugin")
8+
alias(libs.plugins.nexus.publish)
189
}
1910

2011
allprojects {
2112
buildscript {
2213
repositories {
2314
mavenCentral()
24-
mavenLocal()
15+
mavenLocal {
16+
content {
17+
includeGroup("com.expediagroup")
18+
}
19+
}
2520
}
2621
}
2722

@@ -36,157 +31,7 @@ allprojects {
3631
}
3732
}
3833

39-
subprojects {
40-
val kotlinJvmVersion: String by project
41-
42-
val currentProject = this
43-
44-
apply(plugin = "kotlin")
45-
apply(plugin = "io.gitlab.arturbosch.detekt")
46-
apply(plugin = "org.jlleitschuh.gradle.ktlint")
47-
apply(plugin = "jacoco")
48-
apply(plugin = "java-library")
49-
apply(plugin = "org.jetbrains.dokka")
50-
apply(plugin = "maven-publish")
51-
apply(plugin = "signing")
52-
53-
tasks {
54-
withType<KotlinCompile> {
55-
kotlinOptions {
56-
jvmTarget = kotlinJvmVersion
57-
freeCompilerArgs = listOf("-Xjsr305=strict")
58-
}
59-
}
60-
61-
check {
62-
dependsOn(jacocoTestCoverageVerification)
63-
}
64-
detekt {
65-
toolVersion = rootProject.project.libs.versions.detekt.get()
66-
config = files("${rootProject.projectDir}/detekt.yml")
67-
}
68-
ktlint {
69-
version.set(rootProject.project.libs.versions.ktlint.core.get())
70-
}
71-
jacoco {
72-
toolVersion = rootProject.project.libs.versions.jacoco.get()
73-
}
74-
jar {
75-
manifest {
76-
attributes["Built-By"] = "Expedia Group"
77-
attributes["Build-Jdk"] = "${System.getProperty("java.version")} (${System.getProperty("java.vendor")} ${System.getProperty("java.vm.version")})"
78-
attributes["Build-Timestamp"] = Instant.now().toString()
79-
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
80-
attributes["Implementation-Title"] = currentProject.name
81-
attributes["Implementation-Version"] = project.version
82-
}
83-
84-
// NOTE: in order to run gradle and maven plugin integration tests we need to have our build artifacts available in local repo
85-
finalizedBy("publishToMavenLocal")
86-
}
87-
java {
88-
// even though we don't have any Java code, since we are building using Java LTS version,
89-
// this is required for Gradle to set the correct JVM versions in the module metadata
90-
targetCompatibility = JavaVersion.VERSION_1_8
91-
sourceCompatibility = JavaVersion.VERSION_1_8
92-
}
93-
94-
// published sources and javadoc artifacts
95-
val jarComponent = currentProject.components.getByName("java")
96-
val sourcesJar by registering(Jar::class) {
97-
archiveClassifier.set("sources")
98-
from(sourceSets.main.get().allSource)
99-
}
100-
101-
val dokka = named("dokkaJavadoc", DokkaTask::class)
102-
val javadocJar by registering(Jar::class) {
103-
archiveClassifier.set("javadoc")
104-
from("$buildDir/dokka/javadoc")
105-
dependsOn(dokka)
106-
}
107-
publishing {
108-
publications {
109-
withType<MavenPublication> {
110-
pom {
111-
name.set("${currentProject.group}:${currentProject.name}")
112-
url.set("https://github.com/ExpediaGroup/graphql-kotlin")
113-
licenses {
114-
license {
115-
name.set("The Apache Software License, Version 2.0")
116-
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
117-
}
118-
}
119-
organization {
120-
name.set("Expedia Group")
121-
name.set("https://www.expediagroup.com/")
122-
}
123-
developers {
124-
developer {
125-
name.set("Expedia Group Committers")
126-
email.set("[email protected]")
127-
organization.set("Expedia Group")
128-
organizationUrl.set("https://www.expediagroup.com/")
129-
}
130-
}
131-
scm {
132-
connection.set("scm:git:git://github.com/ExpediaGroup/graphql-kotlin.git")
133-
developerConnection.set("scm:git:git://github.com/ExpediaGroup/graphql-kotlin.git")
134-
url.set("https://github.com/ExpediaGroup/graphql-kotlin")
135-
}
136-
137-
// child projects need to be evaluated before their description can be read
138-
val mavenPom = this
139-
afterEvaluate {
140-
mavenPom.description.set(currentProject.description)
141-
}
142-
}
143-
}
144-
// com.gradle.plugin-publish creates publication automatically
145-
if (currentProject.name != "graphql-kotlin-gradle-plugin") {
146-
create<MavenPublication>("mavenJava") {
147-
from(jarComponent)
148-
artifact(sourcesJar.get())
149-
// no need to publish javadocs for SNAPSHOT builds
150-
if (rootProject.extra["isReleaseVersion"] as Boolean) {
151-
artifact(javadocJar.get())
152-
}
153-
}
154-
}
155-
}
156-
}
157-
signing {
158-
setRequired {
159-
(rootProject.extra["isReleaseVersion"] as Boolean) && (gradle.taskGraph.hasTask("publish") || gradle.taskGraph.hasTask("publishPlugins"))
160-
}
161-
val signingKey: String? = System.getenv("GPG_SECRET")
162-
val signingPassword: String? = System.getenv("GPG_PASSPHRASE")
163-
useInMemoryPgpKeys(signingKey, signingPassword)
164-
sign(publishing.publications)
165-
}
166-
167-
test {
168-
useJUnitPlatform()
169-
finalizedBy(jacocoTestReport)
170-
}
171-
}
172-
173-
// typesafe accessors to version catalog do not work in the subprojects/allprojects block, need to use rootProject.project
174-
dependencies {
175-
implementation(rootProject.project.libs.kotlin.stdlib)
176-
implementation(rootProject.project.libs.kotlin.reflect)
177-
implementation(rootProject.project.libs.kotlinx.coroutines.jdk8)
178-
testImplementation(rootProject.project.libs.kotlin.test)
179-
testImplementation(rootProject.project.libs.kotlin.junit.test)
180-
testImplementation(rootProject.project.libs.junit.api)
181-
testImplementation(rootProject.project.libs.junit.engine)
182-
testImplementation(rootProject.project.libs.mockk)
183-
}
184-
}
185-
18634
tasks {
187-
jar {
188-
enabled = false
189-
}
19035
nexusPublishing {
19136
repositories {
19237
sonatype {

buildSrc/build.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
3+
`kotlin-dsl`
4+
}
5+
6+
repositories {
7+
// Use the plugin portal to apply community plugins in convention plugins.
8+
gradlePluginPortal()
9+
}
10+
11+
dependencies {
12+
// add plugin artifacts so we can reference them in plugins block in the precompiled script
13+
// in the future maybe we could update below to <plugin id>:<plugin id>.gradle.plugin:<plugin version> coordinates
14+
implementation(libs.kotlin.gradle.plugin)
15+
implementation(libs.detekt.plugin)
16+
implementation(libs.dokka.plugin)
17+
implementation(libs.ktlint.plugin)
18+
19+
// this is a workaround to enable version catalog usage in the convention plugin
20+
// see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
21+
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
22+
}

buildSrc/settings.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import org.gradle.accessors.dm.LibrariesForLibs
2+
import org.jetbrains.dokka.gradle.DokkaTask
3+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4+
import java.time.Duration
5+
import java.time.Instant
6+
7+
plugins {
8+
kotlin("jvm")
9+
id("org.jetbrains.dokka")
10+
id("org.jlleitschuh.gradle.ktlint")
11+
id("io.gitlab.arturbosch.detekt")
12+
jacoco
13+
`java-library`
14+
signing
15+
`maven-publish`
16+
}
17+
18+
// this is a workaround to enable version catalog usage in the convention plugin
19+
// see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
20+
val libs = the<LibrariesForLibs>()
21+
tasks {
22+
val kotlinJvmVersion: String by project
23+
withType<KotlinCompile> {
24+
kotlinOptions {
25+
jvmTarget = kotlinJvmVersion
26+
freeCompilerArgs = listOf("-Xjsr305=strict")
27+
}
28+
}
29+
30+
check {
31+
dependsOn(jacocoTestCoverageVerification)
32+
}
33+
detekt {
34+
toolVersion = libs.versions.detekt.get()
35+
config = files("${rootProject.projectDir}/detekt.yml")
36+
}
37+
ktlint {
38+
version.set(libs.versions.ktlint.core.get())
39+
}
40+
jacoco {
41+
toolVersion = libs.versions.jacoco.get()
42+
}
43+
jar {
44+
manifest {
45+
attributes["Built-By"] = "Expedia Group"
46+
attributes["Build-Jdk"] = "${System.getProperty("java.version")} (${System.getProperty("java.vendor")} ${System.getProperty("java.vm.version")})"
47+
attributes["Build-Timestamp"] = Instant.now().toString()
48+
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
49+
attributes["Implementation-Title"] = project.name
50+
attributes["Implementation-Version"] = project.version
51+
}
52+
53+
// NOTE: in order to run gradle and maven plugin integration tests we need to have our build artifacts available in local repo
54+
finalizedBy("publishToMavenLocal")
55+
}
56+
java {
57+
// even though we don't have any Java code, since we are building using Java LTS version,
58+
// this is required for Gradle to set the correct JVM versions in the module metadata
59+
targetCompatibility = JavaVersion.VERSION_1_8
60+
sourceCompatibility = JavaVersion.VERSION_1_8
61+
}
62+
63+
// published sources and javadoc artifacts
64+
val jarComponent = project.components.getByName("java")
65+
val sourcesJar by registering(Jar::class) {
66+
archiveClassifier.set("sources")
67+
from(sourceSets.main.get().allSource)
68+
}
69+
70+
val dokka = named("dokkaJavadoc", DokkaTask::class)
71+
val javadocJar by registering(Jar::class) {
72+
archiveClassifier.set("javadoc")
73+
from("$buildDir/dokka/javadoc")
74+
dependsOn(dokka)
75+
}
76+
publishing {
77+
publications {
78+
withType<MavenPublication> {
79+
pom {
80+
name.set("${project.group}:${project.name}")
81+
url.set("https://github.com/ExpediaGroup/graphql-kotlin")
82+
licenses {
83+
license {
84+
name.set("The Apache Software License, Version 2.0")
85+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
86+
}
87+
}
88+
organization {
89+
name.set("Expedia Group")
90+
name.set("https://www.expediagroup.com/")
91+
}
92+
developers {
93+
developer {
94+
name.set("Expedia Group Committers")
95+
email.set("[email protected]")
96+
organization.set("Expedia Group")
97+
organizationUrl.set("https://www.expediagroup.com/")
98+
}
99+
}
100+
scm {
101+
connection.set("scm:git:git://github.com/ExpediaGroup/graphql-kotlin.git")
102+
developerConnection.set("scm:git:git://github.com/ExpediaGroup/graphql-kotlin.git")
103+
url.set("https://github.com/ExpediaGroup/graphql-kotlin")
104+
}
105+
106+
// child projects need to be evaluated before their description can be read
107+
val mavenPom = this
108+
afterEvaluate {
109+
mavenPom.description.set(project.description)
110+
}
111+
}
112+
}
113+
// com.gradle.plugin-publish creates publication automatically
114+
if (project.name != "graphql-kotlin-gradle-plugin") {
115+
create<MavenPublication>("mavenJava") {
116+
from(jarComponent)
117+
artifact(sourcesJar.get())
118+
// no need to publish javadocs for SNAPSHOT builds
119+
if (rootProject.extra["isReleaseVersion"] as Boolean) {
120+
artifact(javadocJar.get())
121+
}
122+
}
123+
}
124+
}
125+
}
126+
signing {
127+
setRequired {
128+
(rootProject.extra["isReleaseVersion"] as Boolean) && (gradle.taskGraph.hasTask("publish") || gradle.taskGraph.hasTask("publishPlugins"))
129+
}
130+
val signingKey: String? = System.getenv("GPG_SECRET")
131+
val signingPassword: String? = System.getenv("GPG_PASSPHRASE")
132+
useInMemoryPgpKeys(signingKey, signingPassword)
133+
sign(publishing.publications)
134+
}
135+
136+
test {
137+
useJUnitPlatform()
138+
finalizedBy(jacocoTestReport)
139+
}
140+
}
141+
142+
dependencies {
143+
implementation(libs.kotlin.stdlib)
144+
implementation(libs.kotlin.reflect)
145+
implementation(libs.kotlinx.coroutines.jdk8)
146+
testImplementation(libs.kotlin.test)
147+
testImplementation(libs.kotlin.junit.test)
148+
testImplementation(libs.junit.api)
149+
testImplementation(libs.junit.engine)
150+
testImplementation(libs.mockk)
151+
}

clients/graphql-kotlin-client-jackson/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
description = "GraphQL client serializer based on Jackson"
22

3+
plugins {
4+
id("com.expediagroup.graphql.conventions")
5+
}
6+
37
dependencies {
48
api(project(path = ":graphql-kotlin-client"))
59
api(libs.jackson)

clients/graphql-kotlin-client-serialization/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
description = "GraphQL client serializer based on kotlinx.serialization"
22

3+
@Suppress("DSL_SCOPE_VIOLATION") // TODO: remove once KTIJ-19369 / Gradle#22797 is fixed
34
plugins {
4-
kotlin("plugin.serialization")
5+
id("com.expediagroup.graphql.conventions")
6+
alias(libs.plugins.kotlin.serialization)
57
}
68

79
dependencies {

0 commit comments

Comments
 (0)