This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
270 lines (228 loc) Β· 8.33 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/*
* πͺ ai: Simple CLI parser for Kotlin that won't make your head spin. γ.:β*:ο½₯'(*βββ*)))
* Copyright (c) 2022 Noelware
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import dev.floofy.utils.gradle.Version
import dev.floofy.utils.gradle.by
import dev.floofy.utils.gradle.noel
import org.gradle.api.tasks.wrapper.Wrapper.DistributionType.ALL
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.Properties
import java.io.StringReader
buildscript {
repositories {
maven("https://maven.floofy.dev/repo/releases")
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
dependencies {
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.6.1")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.6.21")
classpath(kotlin("gradle-plugin", version = "1.6.21"))
classpath(kotlin("serialization", version = "1.6.21"))
classpath("dev.floofy.commons:gradle:2.1.0.1")
}
}
plugins {
`maven-publish`
`java-library`
id("com.diffplug.spotless") version "6.6.1"
id("org.jetbrains.dokka") version "1.6.21"
kotlin("jvm") version "1.6.21"
}
val VERSION = Version(1, 1, 0, 0, dev.floofy.utils.gradle.ReleaseType.Beta)
val DOKKA_OUTPUT = "${rootProject.projectDir}/docs"
val JAVA_VERSION = JavaVersion.VERSION_17
group = "org.noelware.ai"
version = "$VERSION"
repositories {
mavenCentral()
mavenLocal()
noel()
}
dependencies {
// Kotlin libraries
implementation(kotlin("stdlib"))
// Parser (Apache Commons CLI)
implementation("commons-cli:commons-cli:1.5.0")
// Testing library :D
testImplementation(kotlin("test"))
}
spotless {
kotlin {
trimTrailingWhitespace()
licenseHeaderFile("${rootProject.projectDir}/assets/HEADING")
endWithNewline()
// We can't use the .editorconfig file, so we'll have to specify it here
// issue: https://github.com/diffplug/spotless/issues/142
// ktlint 0.35.0 (default for Spotless) doesn't support trailing commas
ktlint("0.43.0")
.userData(
mapOf(
"no-consecutive-blank-lines" to "true",
"no-unit-return" to "true",
"disabled_rules" to "no-wildcard-imports,colon-spacing",
"indent_size" to "4"
)
)
}
}
java {
targetCompatibility = JAVA_VERSION
sourceCompatibility = JAVA_VERSION
}
tasks {
wrapper {
version = "7.4.2"
distributionType = ALL
}
clean {
delete(DOKKA_OUTPUT)
}
test {
useJUnitPlatform()
}
dokkaHtml {
dependsOn(clean)
dokkaSourceSets {
named("main") {
outputDirectory by file(DOKKA_OUTPUT)
jdkVersion by 17
platform by org.jetbrains.dokka.Platform.jvm
sourceLink {
remoteLineSuffix by "#L"
localDirectory by file("src/main/kotlin")
remoteUrl by uri("https://github.com/Noelware/ai/tree/master/src/main/kotlin").toURL()
}
}
}
}
jar {
manifest {
attributes(
mapOf(
"Implementation-Version" to "$VERSION",
"Implementation-Vendor" to "Noelware, Inc. <[email protected]>"
)
)
}
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = JAVA_VERSION.toString()
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
kotlinOptions.javaParameters = true
}
}
// Get the `publishing.properties` file from the `gradle/` directory
// in the root project.
val publishingPropsFile = file("${rootProject.projectDir}/gradle/publishing.properties")
val publishingProps = Properties()
// If the file exists, let's get the input stream
// and load it.
if (publishingPropsFile.exists()) {
publishingProps.load(publishingPropsFile.inputStream())
} else {
// Check if we do in environment variables
val accessKey = System.getenv("NOELWARE_PUBLISHING_ACCESS_KEY") ?: ""
val secretKey = System.getenv("NOELWARE_PUBLISHING_SECRET_KEY") ?: ""
if (accessKey.isNotEmpty() && secretKey.isNotEmpty()) {
val data = """
|s3.accessKey=$accessKey
|s3.secretKey=$secretKey
""".trimMargin()
publishingProps.load(StringReader(data))
}
}
// Check if we have the `NOELWARE_PUBLISHING_ACCESS_KEY` and `NOELWARE_PUBLISHING_SECRET_KEY` environment
// variables, and if we do, set it in the publishing.properties loader.
val snapshotRelease: Boolean = run {
val env = System.getenv("NOELWARE_PUBLISHING_IS_SNAPSHOT") ?: "false"
env == "true"
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val dokkaJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assemble Kotlin documentation with Dokka"
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
dependsOn(tasks.dokkaHtml)
}
publishing {
publications {
create<MavenPublication>("ai") {
from(components["kotlin"])
artifactId = "ai"
groupId = "org.noelware.ai"
version = "$VERSION"
artifact(sourcesJar.get())
artifact(dokkaJar.get())
pom {
description by "Simple CLI parser for Kotlin that won't make your head spin. γ.:β*:ο½₯'(*βββ*)))"
name by "ai"
url by "https://docs.noelware.org/libs/ai"
organization {
name by "Noelware"
url by "https://noelware.org"
}
developers {
developer {
name by "Noel"
email by "[email protected]"
url by "https://floofy.dev"
}
developer {
name by "Noelware Team"
email by "[email protected]"
url by "https://noelware.org"
}
}
issueManagement {
system by "GitHub"
url by "https://github.com/Noelware/ai/issues"
}
licenses {
license {
name by "Apache-2.0"
url by "http://www.apache.org/licenses/LICENSE-2.0"
}
}
scm {
connection by "scm:git:ssh://github.com/Noelware/remi.git"
developerConnection by "scm:git:ssh://[email protected]:Noelware/remi.git"
url by "https://github.com/Noelware/ai"
}
}
}
}
repositories {
val url = if (snapshotRelease) "s3://maven.noelware.org/snapshots" else "s3://maven.noelware.org"
maven(url) {
credentials(AwsCredentials::class.java) {
accessKey = publishingProps.getProperty("s3.accessKey") ?: System.getenv("NOELWARE_PUBLISHING_ACCESS_KEY") ?: ""
secretKey = publishingProps.getProperty("s3.secretKey") ?: System.getenv("NOELWARE_PUBLISHING_SECRET_KEY") ?: ""
}
}
}
}