forked from Ninja-Squad/springmockk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
168 lines (144 loc) · 4.89 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Duration
plugins {
// if it's changed, it must also be channged in the bomProperty below
val kotlinVersion = "1.7.21"
`java-library`
kotlin("jvm") version kotlinVersion
`maven-publish`
signing
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("org.jetbrains.kotlin.plugin.noarg") version kotlinVersion
id("org.springframework.boot") version "3.0.0" apply false
id("io.spring.dependency-management") version "1.1.0"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}
group = "com.ninja-squad"
version = "4.0.2"
description = "MockBean and SpyBean, but for MockK instead of Mockito"
val sonatypeUsername = project.findProperty("sonatypeUsername")?.toString() ?: ""
val sonatypePassword = project.findProperty("sonatypePassword")?.toString() ?: ""
java {
sourceCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
}
repositories {
mavenCentral()
}
val sharedManifest = Action<Manifest> {
attributes(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "ninja-squad.com"
)
}
tasks {
withType(KotlinCompile::class.java) {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xjvm-default=all")
jvmTarget = "17"
}
}
test {
useJUnitPlatform()
jvmArgs(
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED"
)
}
withType<Jar> {
manifest(sharedManifest)
}
register("publishToSonatypeAndClose") {
group = "Maven Central Release"
description = "Publishes to the Sonatype OSSRH repository and closes, but does not do the final release to Maven Central"
dependsOn("publishToSonatype")
dependsOn("closeSonatypeStagingRepository")
}
register("publishToSonatypeAndCloseAndReleaseToMavenCentral") {
group = "Maven Central Release"
description = "Publishes to the Sonatype OSSRH repository and closes, then does the final release to Maven Central"
dependsOn("publishToSonatype")
dependsOn("closeAndReleaseSonatypeStagingRepository")
}
}
afterEvaluate {
tasks.named("closeSonatypeStagingRepository") {
mustRunAfter("publishToSonatype")
}
tasks.named("closeAndReleaseSonatypeStagingRepository") {
mustRunAfter("publishToSonatype")
}
}
dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES) {
bomProperty("kotlin.version", "1.7.21")
}
}
}
dependencies {
api("io.mockk:mockk-jvm:1.13.3")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.springframework.boot:spring-boot-test")
implementation("org.springframework:spring-test")
implementation("org.springframework:spring-context")
testImplementation("org.assertj:assertj-core")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
pom {
name.set(project.name)
description.set(project.description)
url.set("https://github.com/Ninja-Squad/springmockk")
organization {
name.set("Ninja Squad")
url.set("http://ninja-squad.com")
}
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0")
distribution.set("repo")
}
}
developers {
developer {
id.set("jnizet")
name.set("Jean-Baptiste Nizet")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/Ninja-Squad/springmockk")
developerConnection.set("scm:git:git://github.com/Ninja-Squad/springmockk")
url.set("https://github.com/Ninja-Squad/springmockk")
}
}
}
}
repositories {
maven {
name = "build"
url = uri("$buildDir/repo")
}
}
}
signing {
sign(publishing.publications["maven"])
}
nexusPublishing {
repositories {
sonatype {
username.set(sonatypeUsername)
password.set(sonatypePassword)
}
}
connectTimeout.set(Duration.ofMinutes(3))
clientTimeout.set(Duration.ofMinutes(3))
}