-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
186 lines (165 loc) · 5.37 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
jacoco
kotlin("jvm") version Dependencies.kotlinVersion
`maven-publish`
id("org.jetbrains.dokka") version Dependencies.dokkaVersion
id("org.jlleitschuh.gradle.ktlint") version Dependencies.ktlintVersion
id("org.jlleitschuh.gradle.ktlint-idea") version Dependencies.ktlintVersion
signing
}
group = "io.github.sapientpants"
version = Version.FULL
extra["isReleaseVersion"] = !version.toString().endsWith("SNAPSHOT")
kotlin {
explicitApi()
}
// val dokka by tasks.getting(DokkaTask::class) {
// outputFormat = "javadoc"
// outputDirectory = "$buildDir/javadoc"
//
// jdkVersion = 8
//
// includes = listOf("src/main/kotlin/packages.md")
//
// externalDocumentationLink(
// delegateClosureOf<DokkaConfiguration.ExternalDocumentationLink.Builder> {
// url = URL("https://docs.spring.io/spring-framework/docs/4.2.9.RELEASE/javadoc-api/")
// }
// )
// }
tasks.register<Jar>("dokkaJar") {
archiveClassifier.set("javadoc")
dependsOn("dokkaJavadoc")
from("$buildDir/dokka/javadoc/")
}
ktlint {
verbose.set(true)
outputToConsole.set(true)
}
val sourcesJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles sources JAR"
classifier = "sources"
from(sourceSets.getByName("main").allSource)
}
artifacts.add("archives", sourcesJar)
val jar by tasks.getting(Jar::class) {
manifest.attributes.apply {
put("Implementation-Title", "Structurizr Macros")
put("Implementation-Version", project.version)
put("Built-By", System.getProperty("user.name"))
put("Built-JDK", System.getProperty("java.version"))
put("Built-Gradle", project.gradle.gradleVersion)
}
}
repositories {
jcenter()
// Up to date Structurizr jars
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
api(Dependencies.dotEnv)
api(Dependencies.plantUml)
api(Dependencies.slf4jLog4j)
api(Dependencies.structurizrAdrTools)
api(Dependencies.structurizrAnnotations)
api(Dependencies.structurizrClient)
api(Dependencies.structurizrCore)
api(Dependencies.structurizrPlantUml)
api(Dependencies.structurizrSpring)
testImplementation(Dependencies.junitApi)
testImplementation(Dependencies.junitEngine)
}
tasks.test {
useJUnitPlatform()
}
jacoco {
toolVersion = "0.8.5"
}
tasks.jacocoTestReport {
reports {
xml.isEnabled = true
xml.destination = file("$buildDir/reports/jacoco/report.xml")
}
}
tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = "0.5".toBigDecimal()
}
}
rule {
element = "CLASS"
includes = listOf("io.github.sapientpants.*")
limit {
counter = "LINE"
value = "TOTALCOUNT"
maximum = "100".toBigDecimal()
}
}
}
}
publishing {
publications {
create<MavenPublication>("mavenKotlin") {
from(components["kotlin"])
artifact(tasks["dokkaJar"])
artifact(tasks["sourcesJar"])
pom {
name.set("Structurizr Macros")
description.set("A collection of macros for Structurizr")
url.set("https://github.com/sapientpants/structurizr-macros")
licenses {
license {
name.set("The MIT License")
url.set("http://www.opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("sapientpants")
name.set("Marc Tremblay")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:[email protected]:sapientpants/architecture-documentation-macros.git")
developerConnection.set("scm:git:[email protected]:sapientpants/architecture-documentation-macros.git")
url.set("https://github.com/sapientpants/structurizr-macros")
}
}
}
repositories {
maven {
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
credentials {
username = project.findProperty("maven.publish.username") as String?
password = project.findProperty("maven.publish.password") as String?
}
}
}
}
}
if (project.hasProperty("signing.gnupg.keyName") &&
project.hasProperty("signing.gnupg.passphrase")
) {
signing {
useGpgCmd()
setRequired({
(project.properties["isReleaseVersion"] as Boolean) && gradle.taskGraph.hasTask("uploadArchives")
})
sign(publishing.publications["mavenKotlin"])
sign(configurations.archives.get())
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}