This repository was archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
126 lines (98 loc) · 3.17 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.Properties
group = "me.darefox"
version = "0.3.3"
plugins {
id("java-library")
id("maven-publish")
kotlin("jvm") version "1.6.20"
kotlin("plugin.serialization") version "1.6.20"
id("org.jetbrains.dokka") version "1.6.10"
}
buildscript {
dependencies {
classpath("org.jetbrains.dokka:versioning-plugin:1.6.10")
}
}
repositories {
mavenCentral()
}
val ktorVersion = "1.6.8"
dependencies {
testImplementation(kotlin("test"))
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
implementation("io.github.resilience4j:resilience4j-ratelimiter:1.7.1")
implementation("io.github.resilience4j:resilience4j-kotlin:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
dokkaPlugin("org.jetbrains.dokka:versioning-plugin:1.6.10")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = rootProject.group.toString()
artifactId = rootProject.name
version = rootProject.version.toString()
from(components["java"])
}
}
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.test {
doFirst {
val localEnv = rootProject.file("local.properties")
val prop = Properties()
if (localEnv.exists()) {
prop.load(localEnv.inputStream())
}
val token = prop["test.dtf.token"]
token?.let {
environment("TEST_DTF_TOKEN", it)
}
}
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
// Create fat .jar file
tasks.create("fatJar", Jar::class) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
val dependencies = configurations
.runtimeClasspath
.get()
.map(::zipTree)
from(dependencies)
with(tasks.jar.get())
}
// Generate documentation by Dokka
tasks.dokkaHtml.configure {
val docs = projectDir.resolve("docs")
// DO NOT INCLUDE THIS FOLDER IN 'docs' FOLDER!!!
// COPYING FILES CODE WILL FALL IN ENDLESS RECURSION!!!
val otherVersionDir = projectDir.resolve("otherVersions")
outputDirectory.set(docs)
// Enable versioning plugin
pluginConfiguration<org.jetbrains.dokka.versioning.VersioningPlugin, org.jetbrains.dokka.versioning.VersioningConfiguration> {
version = rootProject.version.toString()
olderVersionsDir = otherVersionDir
}
// Archive documentation versions
doLast {
println("Generated documentation copy stage")
otherVersionDir.mkdir()
require(otherVersionDir.isDirectory && otherVersionDir.exists()) {
"Can't create otherVersions folder"
}
require(docs.isDirectory && docs.exists()) {
"docs folder doesn't exist"
}
println("Copying docs to ${otherVersionDir.name}")
docs.copyRecursively(otherVersionDir.resolve(rootProject.version.toString()), true)
}
}