Skip to content

Commit d177cc4

Browse files
author
r8vnhill
committed
✨ Add Gradle convention plugins and utility classes
- 🛠️ Integrated Gradle convention plugins: `compile.conventions`, `dokka.conventions`, and `jvm.conventions`. - 📦 Added utility classes and extensions including `FatJarExtension` and `GreetExtension` for enhanced build and documentation setup. - ⚙️ Implemented core functionalities like fat JAR creation, project management tasks, and versioning plugin.
1 parent 9500f36 commit d177cc4

20 files changed

Lines changed: 347 additions & 17 deletions

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/lib/echo-app.lib.main.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
plugins {
2-
id("jvm.conventions")
32
application
43
}
54

65
dependencies {
7-
implementation(libs.kotlinx.datetime)
6+
implementation(
7+
fileTree("libs") {
8+
include("lib-1.0.0-all.jar")
9+
}
10+
)
811
}
912

1013
application {
1114
mainClass.set("cl.ravenhill.echo.EchoAppKt")
1215
}
16+
17+
tasks.named("compileKotlin") {
18+
dependsOn(":lib:copyLib")
19+
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package cl.ravenhill.echo
22

3-
import kotlinx.datetime.Clock
4-
5-
fun echo(message: String) = "${Clock.System.now()} - $message"
6-
73
fun main(args: Array<String>) {
84
for (arg in args) {
95
println(echo(arg))
106
}
11-
}
7+
}

build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id("jvm.conventions")
33
id("playground")
4+
alias(libs.plugins.detekt)
5+
alias(libs.plugins.dokka)
46
}
57

68
val projectGroup = extra["echo.group"] ?: error("La propiedad 'echo.group' no está definida.")
@@ -10,3 +12,20 @@ allprojects {
1012
group = projectGroup
1113
version = projectVersion
1214
}
15+
16+
val detektId = libs.plugins.detekt.get().pluginId
17+
val detektFormattingModule = libs.detekt.formatting.get().module.toString()
18+
val detektFormattingVersion = libs.detekt.formatting.get().version
19+
20+
subprojects {
21+
apply(plugin = "jvm.conventions")
22+
apply(plugin = detektId)
23+
24+
dependencies {
25+
detektPlugins("$detektFormattingModule:$detektFormattingVersion")
26+
}
27+
}
28+
29+
greeting {
30+
module = name
31+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
plugins {
2-
`kotlin-dsl` // (1)
2+
`kotlin-dsl`
33
}
44

55
dependencies {
66
implementation(libs.kotlin.gradle.plugin)
7+
implementation(libs.kotlinx.datetime)
8+
implementation(libs.dokka)
79
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import extensions.FatJarExtension
2+
import java.time.LocalDateTime
3+
4+
plugins {
5+
id("jvm.conventions")
6+
id("dokka.conventions")
7+
}
8+
9+
tasks.register<Jar>("fatJar") {
10+
group = "build"
11+
description = "Creates a fat JAR with all dependencies"
12+
13+
val fatJarConfig = project.extensions.getByType<FatJarExtension>()
14+
15+
archiveClassifier = "all" // (3)
16+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // (4)
17+
manifest { // (5)
18+
attributes["Implementation-Title"] = fatJarConfig.implementationTitle
19+
attributes["Implementation-Version"] = fatJarConfig.implementationVersion
20+
attributes["Build-Date"] = LocalDateTime.now().toString()
21+
}
22+
from(sourceSets.main.get().output) // (6)
23+
dependsOn(configurations.runtimeClasspath) // (7)
24+
from({ // (8)
25+
configurations.runtimeClasspath.get()
26+
.filter { file -> file.name.endsWith("jar") } // (9)
27+
.map { file -> zipTree(file) } // (10)
28+
})
29+
}
30+
31+
tasks.named("fatJar") {
32+
dependsOn("dokkaJar")
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import org.jetbrains.dokka.gradle.DokkaTask
2+
3+
tasks.withType<DokkaTask>().configureEach { // (1)
4+
dokkaSourceSets {
5+
configureEach { // (2)
6+
reportUndocumented = true // (3)
7+
sourceRoots.from(file("src/main/kotlin")) // (4)
8+
platform = org.jetbrains.dokka.Platform.jvm // (5)
9+
}
10+
}
11+
outputDirectory = layout.buildDirectory.dir("dokka/html").get().asFile // (6)
12+
}
13+
14+
tasks.register<Jar>("dokkaJar") {
15+
group = "documentation"
16+
description = "Creates a JAR with the Dokka documentation"
17+
archiveClassifier = "docs"
18+
from(tasks.named<DokkaTask>("dokkaHtml").get().outputDirectory)
19+
}

0 commit comments

Comments
 (0)