-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
103 lines (84 loc) · 3.63 KB
/
build.gradle.kts
File metadata and controls
103 lines (84 loc) · 3.63 KB
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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
val kotlinVersion = "2.3.0"
kotlin("jvm") version kotlinVersion
kotlin("kapt") version kotlinVersion
application
id("org.asciidoctor.jvm.convert") version "4.0.5"
}
group = "io.foldright"
version = "0.3.0-SNAPSHOT"
repositories.mavenCentral()
dependencies {
implementation("com.github.javaparser:javaparser-core:3.28.0")
val picocliVersion = "4.7.7"
implementation("info.picocli:picocli:$picocliVersion")
kapt("info.picocli:picocli-codegen:$picocliVersion")
testImplementation(platform("org.junit:junit-bom:5.14.2"))
// In order to run JUnit 5 test cases in IntelliJ IDEA, need include this dependency. more info see:
// https://junit.org/junit5/docs/current/user-guide/#running-tests-ide-intellij-idea
// https://github.com/junit-team/junit5-samples/blob/main/junit5-jupiter-starter-maven/pom.xml#L29
testImplementation("org.junit.jupiter:junit-jupiter")
val kotestVersion = "5.9.1"
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
testImplementation("io.kotest:kotest-property:$kotestVersion")
compileOnly("org.jetbrains:annotations:26.0.2-1")
}
configurations.runtimeClasspath {
exclude("org.jetbrains", "annotations")
}
java.sourceCompatibility = JavaVersion.VERSION_1_8
// https://kotlinlang.org/docs/gradle-compiler-options.html#centralize-compiler-options-and-use-types
kotlin.compilerOptions.jvmTarget = JvmTarget.JVM_1_8
tasks.jar { exclude("META-INF/native-image") }
tasks.test {
useJUnitPlatform()
testLogging.exceptionFormat = TestExceptionFormat.FULL
}
val mainClassName = "io.foldright.dslf.DuplicateStringLiteralFinder"
val buildDir: File = layout.buildDirectory.get().asFile
// https://picocli.info/autocomplete.html#_generating_completion_scripts_during_the_build
val genCliAutoComplete by tasks.registering(JavaExec::class) {
classpath = sourceSets.main.get().runtimeClasspath
workingDir = buildDir
mainClass = "picocli.AutoComplete"
args(mainClassName, "--force")
}
val generatedPicocliDocsDir = "${buildDir}/generated-picocli-docs"
// https://github.com/remkop/picocli/tree/v4.7.7/picocli-examples
// https://picocli.info/man/gen-manpage.html
val genManpageAsciiDoc by tasks.registering(JavaExec::class) {
dependsOn(tasks.classes)
group = "Documentation"
description = "Generate AsciiDoc manpage"
classpath(sourceSets.main.get().runtimeClasspath, configurations.kapt)
mainClass = "picocli.codegen.docgen.manpage.ManPageGenerator"
args(mainClassName, "--outdir=$generatedPicocliDocsDir", "-v", "--force")
// "--template-dir=src/docs/mantemplates"
}
tasks.asciidoctor {
dependsOn(genManpageAsciiDoc)
setSourceDir(generatedPicocliDocsDir)
setOutputDir("${buildDir}/docs")
logDocuments = true
outputOptions { backends("manpage", "html5") }
jvm {
if (!JavaVersion.current().isJava9Compatible) return@jvm
jvmArgs("--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED")
}
}
arrayOf(tasks.assemble, tasks.distZip, tasks.distTar).forEach {
it { dependsOn(genCliAutoComplete, tasks.asciidoctor) }
}
distributions.main {
val completionFile: File = buildDir.resolve("${project.name}_completion")
contents {
into("etc/bash_completion.d") { from(completionFile) }
into("share/zsh/site-functions") { from(completionFile).rename { "_${project.name}" } }
into("share/man/man1") { from("$buildDir/docs/manpage") }
into("share/doc/${project.name}/html") { from("$buildDir/docs/html5") }
}
}
application.mainClass = mainClassName