-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
122 lines (111 loc) · 4.06 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
plugins {
id("java-library")
id("jacoco")
id("signing")
id("maven-publish")
// cannot read variable in plugins
id("org.gradlex.extra-java-module-info") version "1.4.1"
}
jacoco {
toolVersion = project.property("jcoco.version") as String
}
tasks {
wrapper {
gradleVersion = project.property("gradle.wrapper.version") as String
distributionType = Wrapper.DistributionType.ALL
}
}
allprojects {
repositories {
mavenCentral()
}
}
subprojects {
apply(plugin = "java-library")
apply(plugin = "jacoco")
apply(plugin = "signing")
apply(plugin = "maven-publish")
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
dependencies {
implementation("org.slf4j:slf4j-api:${project.property("slf4j.version")}")
implementation("org.slf4j:slf4j-simple:${project.property("slf4j.version")}")
testImplementation(platform("org.junit:junit-bom:${project.property("junit-bom.version")}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks {
test {
useJUnitPlatform()
}
jacocoTestReport {
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(false)
xml.outputLocation.set(File("$projectDir/build/reports/coverage/jacoco-${project.name}.xml"))
}
dependsOn(test)
}
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
register<MavenPublication>(project.property("artifact.id") as String) {
groupId = project.property("group.id") as String
artifactId = project.property("artifact.id") as String + "-" + project.name
version = project.property("project.version") as String
from(components["java"])
signing {
sign(this@register)
}
pom {
name.set(artifactId)
description.set("bm's $artifactId tool kit.")
url.set(project.property("project.url") as String)
licenses {
license {
name.set("The MIT License")
url.set("https://opensource.org/license/mit/")
}
}
developers {
developer {
id.set("arjenzhou")
name.set("Zhou Yang")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:[email protected]:arjenzhou/bm-kit.git")
developerConnection.set("scm:git:[email protected]:arjenzhou/bm-kit.git")
url.set(project.property("project.url") as String)
}
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/arjenzhou/bm-kit")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "OSSRH"
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val isSnapshots = project.property("project.version").toString().endsWith("SNAPSHOT")
url = if (isSnapshots) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
}