-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
118 lines (101 loc) · 4.04 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
118 lines (101 loc) · 4.04 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
import java.text.SimpleDateFormat
import java.util.*
plugins {
id("maven-publish")
id("java")
}
val versionFromProperty = "${project.property("version")}"
val versionFromEnv: String? = System.getenv("VERSION")
version = versionFromEnv ?: versionFromProperty
group = "${project.property("group")}"
val targetJavaVersion = (project.property("jdk_version") as String).toInt()
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
java {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
repositories {
mavenCentral()
maven(url = "https://nexus.sibmaks.ru/repository/maven-snapshots/")
maven(url = "https://nexus.sibmaks.ru/repository/maven-releases/")
}
dependencies {
compileOnly("org.projectlombok:lombok:${project.property("lib_lombok_version")}")
annotationProcessor("org.projectlombok:lombok:${project.property("lib_lombok_version")}")
implementation("jakarta.annotation:jakarta.annotation-api:${project.property("lib_annotation_api_version")}")
implementation("com.github.sibdevtools:api-common:${project.property("lib_api_common_version")}")
}
tasks.withType<JavaCompile>().configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
java {
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
withJavadocJar()
withSourcesJar()
}
tasks.jar {
from("LICENSE") {
rename { "${it}_${project.property("project_name")}" }
}
manifest {
attributes(
mapOf(
"Specification-Title" to project.name,
"Specification-Vendor" to project.property("author"),
"Specification-Version" to project.version,
"Specification-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()),
"Timestamp" to System.currentTimeMillis(),
"Built-On-Java" to "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})"
)
)
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
packaging = "jar"
url = "https://github.com/sibdevtools/api-error"
licenses {
license {
name.set("The MIT License (MIT)")
url.set("https://www.mit.edu/~amini/LICENSE.md")
}
}
scm {
connection.set("scm:https://github.com/sibdevtools/api-error.git")
developerConnection.set("scm:git:ssh://github.com/sibdevtools")
url.set("https://github.com/sibdevtools/api-error")
}
developers {
developer {
id.set("sibmaks")
name.set("Maksim Drobyshev")
email.set("sibmaks@vk.com")
}
}
}
}
}
repositories {
maven {
val releasesUrl = uri("https://nexus.sibmaks.ru/repository/maven-releases/")
val snapshotsUrl = uri("https://nexus.sibmaks.ru/repository/maven-snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsUrl else releasesUrl
credentials {
username = project.findProperty("nexus_username")?.toString() ?: System.getenv("NEXUS_USERNAME")
password = project.findProperty("nexus_password")?.toString() ?: System.getenv("NEXUS_PASSWORD")
}
}
}
}