-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild.gradle.kts
165 lines (144 loc) · 4.82 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
import com.google.protobuf.gradle.protobuf
import com.google.protobuf.gradle.protoc
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath("com.google.protobuf:protobuf-gradle-plugin:0.8.19")
classpath("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
}
}
repositories {
mavenCentral()
}
apply(from = "gradle/gradle-mvn-push.gradle")
plugins {
kotlin("jvm") version "1.9.0"
`maven-publish`
`java-library`
id("org.jetbrains.dokka") version "1.9.20"
id("io.codearte.nexus-staging") version "0.30.0"
id("com.google.protobuf") version "0.8.19"
id("com.diffplug.spotless") version "6.21.0"
}
java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
spotless {
// optional: limit format enforcement to just the files changed by this feature branch
ratchetFrom("origin/main")
format("misc") {
// define the files to apply `misc` to
target("*.gradle", "*.md", ".gitignore")
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
// apply a specific flavor of google-java-format
googleJavaFormat("1.17.0").aosp().reflowLongStrings()
// fix formatting of type annotations
formatAnnotations()
// make sure every file has the following copyright header.
// optionally, Spotless can set copyright years by digging
// through git history (see "license" section below)
licenseHeaderFile(rootProject.file("LicenseHeaderFile.txt"))
removeUnusedImports()
toggleOffOn()
}
kotlin {
target("src/*/java/**/*.kt", "src/*/kotlin/**/*.kt")
ktlint("0.50.0")
.setEditorConfigPath("$rootDir/.editorconfig")
licenseHeaderFile(rootProject.file("LicenseHeaderFile.txt"))
.named("license")
endWithNewline()
toggleOffOn()
}
}
val protoc_platform: String? by project
val protoSrc = File("$projectDir/protocol/protobufs/").listFiles { f -> f.isFile }
val protobufVersion = "3.21.7"
val protobufDep = "com.google.protobuf:protobuf-java:$protobufVersion"
protobuf {
protoc {
// for apple m1, please add protoc_platform=osx-x86_64 in $HOME/.gradle/gradle.properties
artifact = if (protoc_platform != null) {
"com.google.protobuf:protoc:$protobufVersion:$protoc_platform"
} else {
"com.google.protobuf:protoc:$protobufVersion"
}
}
}
fun org.jetbrains.dokka.gradle.DokkaTask.configureDokkaTask() {
moduleName.set("livekit-server-sdk")
dokkaSourceSets {
configureEach {
skipEmptyPackages.set(true)
includeNonPublic.set(false)
includes.from("module.md")
displayName.set("SDK")
sourceLink {
localDirectory.set(file("src/main/kotlin"))
// URL showing where the source code can be accessed through the web browser
remoteUrl.set(
URL(
"https://github.com/livekit/server-sdk-kotlin/tree/main/src/main/kotlin"
)
)
// Suffix which is used to append the line number to the URL. Use #L for GitHub
remoteLineSuffix.set("#L")
}
}
}
}
tasks.dokkaHtml.configure {
configureDokkaTask()
}
tasks.dokkaJavadoc.configure {
configureDokkaTask()
}
val javadocJar = tasks.named<Jar>("javadocJar") {
from(tasks.named("dokkaJavadoc"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
dependencies {
protobuf(files(*protoSrc))
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
api("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-protobuf:2.9.0")
implementation("com.auth0:java-jwt:4.2.1")
api(protobufDep)
api("com.google.protobuf:protobuf-java-util:$protobufVersion")
implementation("javax.annotation:javax.annotation-api:1.3.2")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
nexusStaging {
serverUrl = "https://s01.oss.sonatype.org/service/local/"
packageGroup = properties["GROUP"] as String
stagingProfileId = "16b57cbf143daa"
}
publishing {
publications {
create<MavenPublication>("maven") {
artifactId = properties["POM_ARTIFACT_ID"] as String
version = properties["VERSION_NAME"] as String
from(components["java"])
}
}
}