-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
142 lines (122 loc) · 4.77 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
142 lines (122 loc) · 4.77 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
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
140
141
142
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.org.jetbrains.kotlin.jvm)
`java-library`
`maven-publish`
signing
alias(libs.plugins.io.github.gradle.nexus.publish.plugin)
}
allprojects {
group = "io.github.dehuckakpyt.telegrambot"
version = "1.4.2"
}
allprojects {
repositories {
mavenCentral()
}
tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
}
}
kotlin {
jvmToolchain(17)
}
nexusPublishing {
packageGroup.set(project.group as String)
repositories {
sonatype { //only for users registered in Sonatype after 24 Feb 2021
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
username.set(project.properties["sonatypeUsername"].toString())
password.set(project.properties["sonatypePassword"].toString())
}
}
}
configure(subprojects.filter { it.path.startsWith(":example").not() && it.path.startsWith(":kscripts").not() }) {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "org.jetbrains.kotlin.jvm")
publishing {
publications {
create<MavenPublication>(project.name) {
groupId = project.group as String
artifactId = project.name
version = project.version as String
from(components["java"])
pom {
packaging = "jar"
name.set(project.name)
description.set("Kotlin Telegram Bot library")
url.set("https://github.com/DEHuckaKpyT/telegram-bot")
scm {
connection.set("scm:https://github.com/DEHuckaKpyT/telegram-bot.git")
developerConnection.set("scm:git@github.com:DEHuckaKpyT/telegram-bot.git")
url.set("https://github.com/DEHuckaKpyT/telegram-bot")
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("DEHuckaKpyT")
name.set("Denis Matytsin")
email.set("den-matytsin@mail.com")
}
}
}
repositories {
maven {
val releasesUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsUrl else releasesUrl
credentials {
username = project.properties["sonatypeUsername"].toString()
password = project.properties["sonatypePassword"].toString()
}
}
}
}
}
}
signing {
sign(publishing.publications[project.name])
}
kotlin {
// explicitApi()
}
java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
tasks.test {
useJUnitPlatform()
}
sourceSets.main {
java.srcDirs("build/generated/ksp/main/kotlin")
}
}
// Experimental
tasks.register("updateProjectVersionInWriterside") {
doFirst {
// write project version to Writerside variables
val writersideVariablesFile = file("Writerside/v.list")
val writersideVariables = writersideVariablesFile.readText()
.replace(Regex("<var name=\"current_version\" value=\".*\"/>"), "<var name=\"current_version\" value=\"${project.version}\"/>")
writersideVariablesFile.writeText(writersideVariables)
// write project version to Writerside config
val writersideConfigFile = file("Writerside/writerside.cfg")
val writersideConfig = writersideConfigFile.readText()
.replace(Regex("<instance src=\"ktb.tree\" web-path=\"/ktb/\" version=\".*\"/>"), "<instance src=\"ktb.tree\" web-path=\"/ktb/\" version=\"${project.version}\"/>")
writersideConfigFile.writeText(writersideConfig)
}
}
tasks.build {
dependsOn("updateProjectVersionInWriterside")
}