Skip to content

Commit 9b6c686

Browse files
authored
Improve build scripts (#256)
1 parent 8e2f484 commit 9b6c686

File tree

28 files changed

+540
-403
lines changed

28 files changed

+540
-403
lines changed

BotCommands-core/build.gradle.kts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
2+
import dev.freya02.botcommands.tasks.GenerateBCInfoTask
3+
import dev.freya02.botcommands.utils.registerBucket4JDocs
4+
import dev.freya02.botcommands.utils.registerJetbrainsAnnotationsDocs
5+
import dev.freya02.botcommands.utils.registerSourceSet
36

47
plugins {
5-
id("BotCommands-conventions")
6-
id("BotCommands-publish-conventions")
8+
id("repositories-conventions")
9+
id("kotlin-conventions")
10+
id("publish-conventions")
11+
id("dokka-conventions")
12+
713
alias(libs.plugins.ksp)
814
}
915

@@ -134,16 +140,6 @@ dependencies {
134140
testImplementation(libs.kotlin.metadata)
135141
}
136142

137-
tasks.named<JavaCompile>("compileTestJava") {
138-
options.release = 24
139-
}
140-
141-
tasks.named<KotlinCompile>("compileTestKotlin") {
142-
compilerOptions {
143-
jvmTarget = JvmTarget.JVM_24
144-
}
145-
}
146-
147143
tasks.withType<Test> {
148144
useJUnitPlatform()
149145

@@ -166,6 +162,9 @@ sourceSets {
166162
dokka {
167163
dokkaSourceSets.configureEach {
168164
suppressGeneratedFiles = false
165+
166+
registerBucket4JDocs()
167+
registerJetbrainsAnnotationsDocs()
169168
}
170169
}
171170

@@ -181,8 +180,10 @@ kotlin {
181180
}
182181
}
183182

184-
configurePublishedJarArtifact(
185-
artifactId = "BotCommands-core",
186-
description = "Includes a core set of features bots typically need.",
187-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-core",
188-
)
183+
publishedProjectEnvironment {
184+
configureJarArtifact(
185+
artifactId = "BotCommands-core",
186+
description = "Includes a core set of features bots typically need.",
187+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-core",
188+
)
189+
}

BotCommands-jda-ktx/build.gradle.kts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
2+
13
plugins {
2-
id("BotCommands-conventions")
3-
id("BotCommands-publish-conventions")
4+
id("repositories-conventions")
5+
id("kotlin-conventions")
6+
id("publish-conventions")
7+
id("dokka-conventions")
8+
49
alias(libs.plugins.ksp)
510
}
611

@@ -26,8 +31,10 @@ tasks.named<Test>("test") {
2631
environment("KSP_OUTPUT", layout.buildDirectory.dir("generated/ksp").get().asFile.path)
2732
}
2833

29-
configurePublishedJarArtifact(
30-
artifactId = "BotCommands-jda-ktx",
31-
description = "Kotlin extensions for JDA. This is recommended when using Kotlin for a more idiomatic usage.",
32-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-jda-ktx",
33-
)
34+
publishedProjectEnvironment {
35+
configureJarArtifact(
36+
artifactId = "BotCommands-jda-ktx",
37+
description = "Kotlin extensions for JDA. This is recommended when using Kotlin for a more idiomatic usage.",
38+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-jda-ktx",
39+
)
40+
}
Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2-
31
plugins {
4-
id("BotCommands-conventions")
2+
id("repositories-conventions")
3+
id("kotlin-conventions")
54

65
alias(libs.plugins.jmh)
76
}
87

98
dependencies {
10-
implementation(projects.botCommandsMethodAccessors.classfile)
11-
implementation(projects.botCommandsMethodAccessors.kotlinReflect)
12-
139
testImplementation(libs.bundles.test)
10+
11+
testImplementation(projects.botCommandsMethodAccessors.classfile)
12+
testImplementation(projects.botCommandsMethodAccessors.kotlinReflect)
13+
14+
jmh(projects.botCommandsMethodAccessors.classfile)
1415
}
1516

1617
tasks.withType<Test> {
@@ -23,13 +24,3 @@ jmh {
2324
humanOutputFile = project.file("reports/jmh/human.txt") // human-readable output file
2425
resultsFile = project.file("reports/jmh/results.txt") // results file
2526
}
26-
27-
tasks.withType<JavaCompile> {
28-
options.release = 24
29-
}
30-
31-
kotlin {
32-
compilerOptions {
33-
jvmTarget = JvmTarget.JVM_24
34-
}
35-
}
Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
1-
import org.jetbrains.dokka.gradle.tasks.DokkaBaseTask
2-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
2+
import dev.freya02.botcommands.utils.setMainJvmTarget
33

44
plugins {
5-
id("BotCommands-conventions")
6-
id("BotCommands-publish-conventions")
5+
id("repositories-conventions")
6+
id("kotlin-conventions")
7+
id("publish-conventions")
78
}
89

910
dependencies {
1011
api(projects.botCommandsMethodAccessors.core)
1112
}
1213

13-
tasks.withType<JavaCompile> {
14-
options.release = 24
15-
}
16-
17-
kotlin {
18-
compilerOptions {
19-
jvmTarget = JvmTarget.JVM_24
20-
}
21-
}
14+
setMainJvmTarget(target = 24)
2215

23-
tasks.withType<DokkaBaseTask> {
24-
enabled = false
16+
publishedProjectEnvironment {
17+
configureJarArtifact(
18+
artifactId = "BotCommands-method-accessors-classfile",
19+
description = "Provides support to call methods reflectively, using generated accessors.",
20+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-method-accessors/classfile",
21+
)
2522
}
26-
27-
configurePublishedJarArtifact(
28-
artifactId = "BotCommands-method-accessors-classfile",
29-
description = "Provides support to call methods reflectively, using generated accessors.",
30-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-method-accessors/classfile",
31-
)
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
2+
13
plugins {
2-
id("BotCommands-conventions")
3-
id("BotCommands-publish-conventions")
4+
id("repositories-conventions")
5+
id("kotlin-conventions")
6+
id("publish-conventions")
7+
id("dokka-conventions")
48
}
59

610
dependencies {
@@ -10,8 +14,11 @@ dependencies {
1014
api(libs.jspecify)
1115
}
1216

13-
configurePublishedJarArtifact(
14-
artifactId = "BotCommands-method-accessors-core",
15-
description = "Provides an API to call methods reflectively.",
16-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-method-accessors/core",
17-
)
17+
18+
publishedProjectEnvironment {
19+
configureJarArtifact(
20+
artifactId = "BotCommands-method-accessors-core",
21+
description = "Provides an API to call methods reflectively.",
22+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-method-accessors/core",
23+
)
24+
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import org.jetbrains.dokka.gradle.tasks.DokkaBaseTask
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
22

33
plugins {
4-
id("BotCommands-conventions")
5-
id("BotCommands-publish-conventions")
4+
id("repositories-conventions")
5+
id("kotlin-conventions")
6+
id("publish-conventions")
67
}
78

89
dependencies {
910
api(projects.botCommandsMethodAccessors.core)
1011
}
1112

12-
tasks.withType<DokkaBaseTask> {
13-
enabled = false
14-
}
1513

16-
configurePublishedJarArtifact(
17-
artifactId = "BotCommands-method-accessors-kotlin-reflect",
18-
description = "Provides support to call methods reflectively, using kotlin-reflect.",
19-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-method-accessors/kotlin-reflect",
20-
)
14+
publishedProjectEnvironment {
15+
configureJarArtifact(
16+
artifactId = "BotCommands-method-accessors-kotlin-reflect",
17+
description = "Provides support to call methods reflectively, using kotlin-reflect.",
18+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-method-accessors/kotlin-reflect",
19+
)
20+
}

BotCommands-spring/build.gradle.kts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
2+
import dev.freya02.botcommands.utils.registerSpringFrameworkDocs
3+
14
plugins {
2-
id("BotCommands-conventions")
3-
id("BotCommands-publish-conventions")
5+
id("repositories-conventions")
6+
id("kotlin-conventions")
7+
id("publish-conventions")
8+
id("dokka-conventions")
9+
410
alias(libs.plugins.ksp)
511
}
612

@@ -21,8 +27,16 @@ dependencies {
2127
ksp(projects.springPropertiesProcessor)
2228
}
2329

24-
configurePublishedJarArtifact(
25-
artifactId = "BotCommands-spring",
26-
description = "Provides support for Spring Boot 3 and 4.",
27-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-spring",
28-
)
30+
dokka {
31+
dokkaSourceSets.configureEach {
32+
registerSpringFrameworkDocs()
33+
}
34+
}
35+
36+
publishedProjectEnvironment {
37+
configureJarArtifact(
38+
artifactId = "BotCommands-spring",
39+
description = "Provides support for Spring Boot 3 and 4.",
40+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-spring",
41+
)
42+
}

BotCommands-typesafe-messages/bc/build.gradle.kts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
2+
import dev.freya02.botcommands.utils.setMainJvmTarget
23

34
plugins {
4-
id("BotCommands-conventions")
5-
id("BotCommands-publish-conventions")
5+
id("repositories-conventions")
6+
id("kotlin-conventions")
7+
id("publish-conventions")
68
}
79

810
dependencies {
@@ -22,13 +24,10 @@ dependencies {
2224
testImplementation(libs.logback.classic)
2325
}
2426

25-
tasks.withType<JavaCompile> {
26-
options.release = 24
27-
}
27+
setMainJvmTarget(target = 24)
2828

2929
kotlin {
3030
compilerOptions {
31-
jvmTarget = JvmTarget.JVM_24
3231
optIn.add("dev.freya02.botcommands.typesafe.messages.api.annotations.ExperimentalTypesafeMessagesApi")
3332
}
3433
}
@@ -37,8 +36,10 @@ tasks.withType<Test> {
3736
useJUnitPlatform()
3837
}
3938

40-
configurePublishedJarArtifact(
41-
artifactId = "BotCommands-typesafe-messages-bc",
42-
description = "Easily define functions to retrieve (localized) messages, improving safety and convenience. Default version.",
43-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-typesafe-messages/bc",
44-
)
39+
publishedProjectEnvironment {
40+
configureJarArtifact(
41+
artifactId = "BotCommands-typesafe-messages-bc",
42+
description = "Easily define functions to retrieve (localized) messages, improving safety and convenience. Default version.",
43+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-typesafe-messages/bc",
44+
)
45+
}

BotCommands-typesafe-messages/core/build.gradle.kts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1+
import dev.freya02.botcommands.plugins.configureJarArtifact
2+
import dev.freya02.botcommands.utils.setMainJvmTarget
23

34
plugins {
4-
id("BotCommands-conventions")
5-
id("BotCommands-publish-conventions")
5+
id("repositories-conventions")
6+
id("kotlin-conventions")
7+
id("publish-conventions")
8+
id("dokka-conventions")
69
}
710

811
dependencies {
@@ -24,13 +27,10 @@ dependencies {
2427
testImplementation(libs.logback.classic)
2528
}
2629

27-
tasks.withType<JavaCompile> {
28-
options.release = 24
29-
}
30+
setMainJvmTarget(target = 24)
3031

3132
kotlin {
3233
compilerOptions {
33-
jvmTarget = JvmTarget.JVM_24
3434
optIn.add("dev.freya02.botcommands.typesafe.messages.api.annotations.ExperimentalTypesafeMessagesApi")
3535
freeCompilerArgs.addAll(
3636
"-Xcontext-parameters",
@@ -42,8 +42,10 @@ tasks.withType<Test> {
4242
useJUnitPlatform()
4343
}
4444

45-
configurePublishedJarArtifact(
46-
artifactId = "BotCommands-typesafe-messages-core",
47-
description = "Easily define functions to retrieve (localized) messages, improving safety and convenience.",
48-
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-typesafe-messages/core",
49-
)
45+
publishedProjectEnvironment {
46+
configureJarArtifact(
47+
artifactId = "BotCommands-typesafe-messages-core",
48+
description = "Easily define functions to retrieve (localized) messages, improving safety and convenience.",
49+
url = "https://github.com/freya022/BotCommands/tree/3.X/BotCommands-typesafe-messages/core",
50+
)
51+
}

0 commit comments

Comments
 (0)