-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
142 lines (122 loc) · 3.91 KB
/
build.gradle.kts
File metadata and controls
142 lines (122 loc) · 3.91 KB
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
fun resolveProjectVersion(): String {
val gitDescribe = runCatching {
ProcessBuilder(*"git describe --exact-match HEAD".split(" ").toTypedArray())
.directory(rootDir)
.start()
.inputStream
.bufferedReader()
.readText()
.trim()
}.getOrElse { "" }
val version = file("version.txt").readText().trim()
val branchName = runCatching {
ProcessBuilder(*"git rev-parse --abbrev-ref HEAD".split(" ").toTypedArray())
.directory(rootDir)
.start()
.inputStream
.bufferedReader()
.readText()
.trim()
}.getOrElse { "unknown" }
return if (gitDescribe.isNotEmpty()) version else "$branchName-SNAPSHOT"
}
var currentVersion = resolveProjectVersion()
plugins {
java
`maven-publish`
kotlin("jvm") version "2.1.0"
kotlin("plugin.serialization") version "1.9.10"
id("com.apollographql.apollo3") version "3.8.2"
id("com.diffplug.spotless") version "7.0.2"
}
group = "com.ziro.engineering"
version = currentVersion
sourceSets.main {
java.srcDirs("src/main/kotlin")
}
repositories {
mavenCentral()
}
val sonatypeUsername = System.getenv("SONATYPE_USERNAME") ?: ""
val sonatypePassword = System.getenv("SONATYPE_PASSWORD") ?: ""
if (sonatypeUsername.isEmpty() || sonatypePassword.isEmpty()) {
println("WARNING: SONATYPE_USERNAME and/or SONATYPE_PASSWORD environment variables are not set! Publishing will fail if attempted.")
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
groupId = "com.ziro.engineering"
artifactId = "github-zenhub-sdk"
version = currentVersion
from(components["java"])
}
}
repositories {
maven {
url = uri("https://repository.goziro.com/repository/engineering/")
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
}
dependencies {
implementation("com.apollographql.apollo3:apollo-runtime")
implementation("com.apollographql.apollo3:apollo-api")
testImplementation(kotlin("test"))
}
kotlin {
jvmToolchain(17)
}
apollo {
service("zenhub") {
packageName.set("com.ziro.engineering.zenhub.graphql.sdk")
sourceFolder.set("./zenhub")
introspection {
headers.put("Authorization", "Bearer ${System.getenv("ZENHUB_GRAPHQL_TOKEN")}")
endpointUrl.set("https://api.zenhub.com/public/graphql")
schemaFile.set(file("src/main/graphql/zenhub/schema.json"))
}
mapScalar("JSON", "kotlin.String", "adapters.JsonAdapter")
}
service("github") {
packageName.set("com.ziro.engineering.github.graphql.sdk")
sourceFolder.set("./github")
introspection {
headers.put("Authorization", "Bearer ${System.getenv("GITHUB_API_TOKEN")}")
endpointUrl.set("https://api.github.com/graphql")
schemaFile.set(file("src/main/graphql/github/schema.json"))
}
mapScalar("URI", "java.net.URI", "adapters.UriAdapter")
}
}
spotless {
kotlin {
ktfmt().configure {
it.setBlockIndent(4)
it.setContinuationIndent(4)
it.setRemoveUnusedImports(true)
}
targetExclude("build/**")
}
}
tasks.test {
useJUnitPlatform()
}
tasks.register("updateSchemas") {
group = "GraphQL Schema Tasks"
description = "Updates GraphQL Schemas"
dependsOn(
"downloadGithubApolloSchemaFromIntrospection",
"downloadZenhubApolloSchemaFromIntrospection"
)
}
tasks.withType<PublishToMavenRepository>().configureEach {
val predicate = provider {
version.toString().contains("SNAPSHOT") || System.getenv().getOrDefault("CI_MODE", "false") == "true"
}
onlyIf("Artifact is a snapshot or running in CI") {
predicate.get()
}
}