-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathbuild.gradle.kts
224 lines (202 loc) · 6.29 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jreleaser.model.Active
val semVer: String? by project
group = "ru.odnoklassniki"
version = semVer ?: "2.1-SNAPSHOT"
plugins {
id("org.cadixdev.licenser") version "0.6.1"
`java-library`
id("org.jreleaser") version "1.14.0"
`maven-publish`
}
repositories {
mavenCentral()
maven("https://plugins.gradle.org/m2")
}
dependencies {
implementation(group = "org.ow2.asm", name = "asm", version = "9.2")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.36")
testImplementation(group = "junit", name = "junit", version = "4.13.1")
testImplementation(group = "org.apache.logging.log4j", name = "log4j-slf4j-impl", version = "2.24.3")
}
java {
withJavadocJar()
withSourcesJar()
}
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.encoding = "UTF-8"
options.compilerArgs = options.compilerArgs + "-Xlint:all"
}
tasks.withType<Test> {
useJUnit()
testLogging {
debug {
events("started", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
}
testLogging.showStandardStreams = true
events("passed", "skipped", "failed")
}
}
tasks.register<Test>("testCI") {
jvmArgs("-Dci=true")
}
val nativeBuildDir = layout.buildDirectory.dir("classes/java/main").get()
tasks.register<Exec>("compileNative") {
val javaHome = System.getProperty("java.home")
doFirst {
logger.info("Compiling native library...")
logger.info("Using java from $javaHome")
nativeBuildDir.asFile.mkdirs()
}
val sourceFiles = fileTree("src") {
include("**/*.c")
}.map { it.path }.toList()
val args = arrayListOf(
"gcc",
"-D_GNU_SOURCE", "-fPIC", "-shared", "-Wl,-soname,libonenio.so", "-O3", "-fno-omit-frame-pointer", "-momit-leaf-frame-pointer", "--verbose",
"-o", "$nativeBuildDir/libonenio.so",
"-I", "$javaHome/include", "-I", "$javaHome/include/linux",
"-I", "$javaHome/../include", "-I", "$javaHome/../include/linux")
args += sourceFiles
args += listOf("-ldl", "-lrt")
commandLine(args)
}
tasks.compileJava {
if (DefaultNativePlatform.getCurrentOperatingSystem().isLinux) {
finalizedBy("compileNative")
}
}
license {
include("**/*.java")
exclude("**/lz4/*.java")
header(rootProject.file("COPYRIGHT_HEADER.txt"))
}
val repoUrl: String = project.properties["repoUrl"] as? String ?: "https://maven.pkg.github.com/odnoklassniki/one-nio"
jreleaser {
signing {
active = Active.ALWAYS
armored = true
verify = true
}
release {
github {
tagName = semVer
releaseName = "Release $semVer"
draft = true
sign = true
branch = "master"
branchPush = "master"
overwrite = true
}
}
deploy {
maven {
nexus2 {
create("maven-central") {
active = Active.ALWAYS
url = "https://oss.sonatype.org/service/local"
stagingRepository(layout.buildDirectory.dir("staging-deploy").get().toString())
setAuthorization("Basic")
sign = true
checksums = true
sourceJar = true
javadocJar = true
closeRepository = true
releaseRepository = false
}
}
}
}
}
publishing {
publications {
register<MavenPublication>("release") {
from(components["java"])
groupId = "ru.odnoklassniki"
artifactId = project.name
addPom()
}
}
repositories {
maven {
setUrl(layout.buildDirectory.dir("staging-deploy"))
}
}
}
fun MavenPublication.addPom() {
pom {
packaging = "jar"
name.set("ru.odnoklassniki")
description.set("Unconventional Java I/O library")
url.set("https://github.com/odnoklassniki/one-nio")
issueManagement {
url.set("https://github.com/odnoklassniki/one-nio/issues")
}
scm {
connection.set("scm:git:[email protected]:odnoklassniki/one-nio.git")
developerConnection.set("scm:git:[email protected]:odnoklassniki/one-nio.git")
url.set("https://github.com/odnoklassniki/one-nio")
}
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("lehvolk")
name.set("Alexey Volkov")
email.set("[email protected]")
}
developer {
id.set("apangin")
name.set("Andrei Pangin")
email.set("[email protected]")
}
developer {
id.set("incubos")
name.set("Vadim Tsesko")
email.set("[email protected]")
}
}
contributors {
contributor {
name.set("Alen Vrečko")
email.set("[email protected]")
}
contributor {
name.set("Leonid Talalaev")
email.set("[email protected]")
}
contributor {
name.set("Maksim Ponomarev")
email.set("[email protected]")
}
contributor {
name.set("Oleg Anastasyev")
email.set("[email protected]")
}
contributor {
name.set("Sergey Novikov")
email.set("[email protected]")
}
contributor {
name.set("Oleg Larionov")
email.set("[email protected]")
}
contributor {
name.set("Vadim Eliseev")
email.set("[email protected]")
}
}
}
}
tasks.wrapper {
gradleVersion = "8.3"
distributionType = Wrapper.DistributionType.ALL
}