-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
130 lines (116 loc) · 4.33 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
130 lines (116 loc) · 4.33 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
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import org.jetbrains.kotlin.konan.properties.hasProperty
plugins {
id("org.springframework.boot") version "2.6.7" apply false
id("io.spring.dependency-management") version "1.0.11.RELEASE" apply false
kotlin("jvm") version "1.6.21" apply false
kotlin("plugin.spring") version "1.6.21" apply false
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}
val globalProperties = java.util.Properties()
if (System.getenv("RELEASE") != null) {
globalProperties["release"] = true
globalProperties["development"] = false
} else {
globalProperties["release"] = false
globalProperties["development"] = true
}
val globalLocalFile = project.file("local.properties")
if (globalLocalFile.isFile)
globalProperties.load(globalLocalFile.inputStream())
globalProperties.forEach { key, value ->
ext.set(key as String, value)
}
allprojects {
//属性文件
val localProperties = globalProperties.clone() as java.util.Properties
val localFile = this.file("local.properties")
if (localFile.isFile)
localProperties.load(localFile.inputStream())
localProperties.forEach { key, value ->
ext.set(key as String, value)
}
group = "me.danwi.kato"
version = "0.0.5"
if (ext["development"] == true)
version = "$version-SNAPSHOT"
repositories {
mavenCentral()
}
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.encoding = "UTF-8"
}
tasks.withType(Javadoc::class) {
options.encoding = "UTF-8"
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<Test> {
useJUnitPlatform()
}
pluginManager.withPlugin("java") {
extensions.configure(JavaPluginExtension::class) {
withJavadocJar()
withSourcesJar()
}
}
pluginManager.withPlugin("maven-publish") {
extensions.configure(PublishingExtension::class) {
publications {
create<MavenPublication>("Java") {
from(components["java"])
pom {
name.set(project.name)
description.set("kato ${project.name} component")
url.set("https://github.com/kato/kato-java")
scm {
connection.set("scm:git:https://github.com/kato/kato-java.git")
developerConnection.set("scm:git:https://github.com/kato/kato-java.git")
url.set("https://github.com/kato/kato-java")
}
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("danwi")
name.set("danwi")
email.set("demon@danwi.me")
}
}
}
}
}
}
if (localProperties.hasProperty("signing.key"))
pluginManager.withPlugin("signing") {
extensions.configure(SigningExtension::class) {
useInMemoryPgpKeys(
localProperties["signing.key"].toString(),
localProperties["signing.password"].toString()
)
extensions.configure(PublishingExtension::class) {
publications.forEach { sign(it) }
}
}
}
}
}
if (globalProperties.hasProperty("ossrh.username")) {
pluginManager.withPlugin("io.github.gradle-nexus.publish-plugin") {
extensions.configure(NexusPublishExtension::class) {
repositories {
sonatype {
username.set(globalProperties["ossrh.username"].toString())
password.set(globalProperties["ossrh.password"].toString())
}
}
}
}
}