-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
139 lines (126 loc) · 4.64 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
plugins {
`java-library`
kotlin("jvm") version "1.9.0"
kotlin("plugin.serialization") version "1.9.0"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2"
id("org.jetbrains.dokka") version "1.8.20"
id("org.jetbrains.kotlinx.kover") version "0.7.2"
signing
`maven-publish`
}
allprojects {
group = "space.iseki.cmdpipe"
version = "0.6.1-SNAPSHOT"
repositories {
mavenCentral()
}
}
java {
withSourcesJar()
}
dependencies {
implementation(kotlin("stdlib"))
testImplementation(kotlin("test"))
compileOnly(libs.jetbrains.annotations)
compileOnly(libs.slf4j.api)
compileOnly(libs.checker.qual)
testImplementation(libs.slf4j.api)
testImplementation(libs.logback.classic)
testImplementation(libs.kotlinx.coroutine.core)
}
fun JavaToolchainSpec.configure() {
languageVersion.set(JavaLanguageVersion.of(17))
}
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
javaCompiler.set(javaToolchains.compilerFor { configure() })
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs += "-Xcontext-receivers"
kotlinOptions.freeCompilerArgs += "-Xassertions=jvm"
kotlinOptions.freeCompilerArgs += "-Xlambdas=indy"
kotlinOptions.freeCompilerArgs += "-Xjvm-default=all-compatibility"
kotlinOptions.jvmTarget = "17"
kotlinJavaToolchain.toolchain.use(javaToolchains.launcherFor { configure() })
}
tasks.test {
useJUnitPlatform()
}
publishing {
repositories {
maven {
name = "Central"
url = if (version.toString().endsWith("SNAPSHOT")) {
// uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
uri("https://oss.sonatype.org/content/repositories/snapshots")
} else {
// uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
}
credentials {
username = properties["ossrhUsername"]?.toString() ?: System.getenv("OSSRH_USERNAME")
password = properties["ossrhPassword"]?.toString() ?: System.getenv("OSSRH_PASSWORD")
}
}
}
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
val publication = this
val javadocJar = tasks.register("${publication.name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.dokkaJavadoc)
archiveBaseName.set("${archiveBaseName.get()}-${publication.name}")
}
artifact(javadocJar)
pom {
name.set("cmdpipe")
description.set("Utils for commandline call")
url.set("https://github.com/iseki0/cmdpipe")
licenses {
license {
name.set("Apache-2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("iseki0")
name.set("iseki zero")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:https://github.com/iseki0/cmdpipe.git")
developerConnection.set("scm:git:https://github.com/iseki0/cmdpipe.git")
url.set("https://github.com/iseki0/cmdpipe")
}
}
}
}
}
afterEvaluate {
signing {
// To use local gpg command, configure gpg options in ~/.gradle/gradle.properties
// reference: https://docs.gradle.org/current/userguide/signing_plugin.html#example_configure_the_gnupgsignatory
useGpgCmd()
publishing.publications.forEach { sign(it) }
}
}
project.tasks.named("compileJava", JavaCompile::class.java) {
options.compilerArgumentProviders.add(CommandLineArgumentProvider {
// Provide compiled Kotlin classes to javac – needed for Java/Kotlin mixed sources to work
listOf("--patch-module", "space.iseki.cmdpipe=${sourceSets["main"].output.asPath}")
})
}
//project.tasks.named("javadoc", Javadoc::class.java) {
// options {
// this as CoreJavadocOptions
// addStringOption("-patch-module", "$module=${sourceSets["main"].output.asPath}")
// }
//}