-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
123 lines (104 loc) · 3.48 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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlin.jvm)
`maven-publish`
`java-library`
jacoco
}
group = "io.github.manamiproject"
version = project.findProperty("release.version") as String? ?: ""
val projectName = "kommand"
val githubUsername = "manami-project"
repositories {
mavenCentral()
}
dependencies {
api(libs.kotlin.stdlib)
testImplementation(libs.junit.jupiter.engine)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.junit.platform.launcher)
testImplementation(libs.assertj.core)
}
kotlin {
explicitApi()
jvmToolchain(JavaVersion.VERSION_21.toString().toInt())
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
}
}
tasks.withType<Test> {
useJUnitPlatform()
reports.html.required.set(false)
reports.junitXml.required.set(true)
maxParallelForks = Runtime.getRuntime().availableProcessors()
}
tasks.jacocoTestReport {
reports {
html.required.set(false)
xml.required.set(true)
xml.outputLocation.set(file("${layout.buildDirectory.get()}/reports/jacoco/test/jacocoFullReport.xml"))
}
dependsOn(allprojects.map { it.tasks.named<Test>("test") })
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javaDoc by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(sourceSets.main.get().allSource)
}
publishing {
repositories {
maven {
name = projectName
url = uri("https://maven.pkg.github.com/$githubUsername/$projectName")
credentials {
username = parameter("GH_USERNAME", githubUsername)
password = parameter("GH_PACKAGES_RELEASE_TOKEN")
}
}
}
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = projectName
version = project.version.toString()
from(components["java"])
artifact(sourcesJar.get())
artifact(javaDoc.get())
pom {
packaging = "jar"
name.set(projectName)
description.set("This library allows you to easily create kotlin-style wrappers for command line functions.")
url.set("https://github.com/$githubUsername/$projectName")
licenses {
license {
name.set("AGPL-V3")
url.set("https://www.gnu.org/licenses/agpl-3.0.txt")
}
}
scm {
connection.set("scm:git@github.com:$githubUsername/$projectName.git")
developerConnection.set("scm:git:ssh://github.com:$githubUsername/$projectName.git")
url.set("https://github.com/$githubUsername/$projectName")
}
}
}
}
}
fun parameter(name: String, default: String = ""): String {
val env = System.getenv(name) ?: ""
if (env.isNotBlank()) {
return env
}
val property = project.findProperty(name) as String? ?: ""
if (property.isNotEmpty()) {
return property
}
return default
}