-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
163 lines (141 loc) · 4.62 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
plugins {
base
id("com.diffplug.spotless") version "5.7.0"
id("de.marcphilipp.nexus-publish") version "0.4.0" apply false
id("io.codearte.nexus-staging") version "0.22.0"
id("net.researchgate.release") version "2.8.1"
}
val encoding: String by project
val isReleaseVersion = !version.toString().endsWith("SNAPSHOT")
allprojects {
apply(plugin = "com.diffplug.spotless")
tasks {
named("build") {
dependsOn(spotlessApply)
}
}
repositories {
mavenCentral()
}
}
subprojects {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "de.marcphilipp.nexus-publish")
tasks {
named<Test>("test") {
maxHeapSize = "1g"
useJUnitPlatform()
}
named("build") {
dependsOn("publishToMavenLocal")
}
withType<JavaCompile>().configureEach {
options.encoding = encoding
}
withType<Sign>().configureEach {
onlyIf { isReleaseVersion }
}
}
dependencies {
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.7.0")
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.7.0")
}
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
configure<de.marcphilipp.gradle.nexus.NexusPublishExtension> {
repositories {
sonatype()
}
}
configure<PublishingExtension> {
publications {
create<MavenPublication>("maven") {
from(components["java"])
pom {
val projectUrl: String by project
name.set(project.name)
description.set("Sandbox")
url.set(projectUrl)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("nakamura-to")
name.set("Toshihiro Nakamura")
email.set("[email protected]")
}
}
scm {
val githubUrl: String by project
connection.set("scm:git:${githubUrl}")
developerConnection.set("scm:git:${githubUrl}")
url.set(projectUrl)
}
}
}
}
}
configure<SigningExtension> {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
val publishing = convention.findByType(PublishingExtension::class)!!
sign(publishing.publications)
isRequired = isReleaseVersion
}
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
java {
googleJavaFormat("1.7")
}
kotlin {
ktlint("0.38.1")
trimTrailingWhitespace()
endWithNewline()
}
}
}
rootProject.apply {
tasks {
named("closeRepository") {
onlyIf { isReleaseVersion }
}
named("releaseRepository") {
onlyIf { isReleaseVersion }
}
}
configure<net.researchgate.release.ReleaseExtension> {
fun net.researchgate.release.ReleaseExtension.git(configureFn : net.researchgate.release.GitAdapter.GitConfig.() -> Unit) {
(propertyMissing("git") as net.researchgate.release.GitAdapter.GitConfig).configureFn()
}
newVersionCommitMessage = "[Gradle Release Plugin] - [skip ci] new version commit: "
git {
requireBranch = "main"
}
}
configure<io.codearte.gradle.nexus.NexusStagingExtension> {
val sonatypeUsername: String by project
val sonatypePassword: String by project
username = sonatypeUsername
password = sonatypePassword
packageGroup = "org.seasar"
}
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
format("misc") {
target("**/*.gradle.kts", "**/*.gitignore")
targetExclude("**/bin/**", "**/build/**")
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
}
}
}