-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
138 lines (123 loc) · 4.07 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
plugins {
java
`maven-publish`
signing
id("pl.allegro.tech.build.axion-release") version "1.18.13"
checkstyle
jacoco
}
group = "pl.tfij"
project.version = scmVersion.version
repositories {
mavenCentral()
}
dependencies {
implementation("com.puppycrawl.tools:checkstyle:10.18.2")
compileOnly("org.projectlombok:lombok:1.18.34")
annotationProcessor("org.projectlombok:lombok:1.18.34")
// https://github.com/google/guava/issues/6825
modules {
// replace old dependency `google-collections` with `guava`
module("com.google.collections:google-collections") {
replacedBy("com.google.guava:guava", "google-collections is part of guava")
}
}
// -------------------------------------------
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}
tasks.jacocoTestReport {
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(true)
}
}
tasks.getByName<Jar>("jar") {
manifest {
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
}
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
create<MavenPublication>("sonatype") {
artifactId = "check-tfij-style"
from(components.getByName("java"))
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult();
}
}
pom {
name.set("check-tfij-style")
description.set("A set of additional check to use with checkstyle.")
url.set("https://github.com/tfij/check-tfij-style")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("tfij")
name.set("Tomasz Fijakowski")
email.set("tomasz@chi.pl")
}
}
scm {
connection.set("scm:git:https://github.com/tfij/check-tfij-style.git")
developerConnection.set("scm:git:https://github.com/tfij/check-tfij-style.git")
url.set("https://github.com/tfij/check-tfij-style.git")
}
}
}
}
repositories {
maven {
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
if (System.getenv().containsKey("SIGNING_GPG_KEY_ID")) {
signing {
useInMemoryPgpKeys(
System.getenv("SIGNING_GPG_KEY_ID"),
System.getenv("SIGNING_GPG_PRIVATE_KEY"),
System.getenv("SIGNING_GPG_PRIVATE_KEY_PASSWORD")
)
sign(publishing.publications.getByName("sonatype"))
}
}
tasks.getByName<Javadoc>("javadoc") {
if(JavaVersion.current().isJava9Compatible) {
(options as? StandardJavadocDocletOptions)?.addBooleanOption("html5", true)
}
}
checkstyle {
toolVersion = "10.3.4"
sourceSets = listOf(project.sourceSets.main.orNull)
}