-
Notifications
You must be signed in to change notification settings - Fork 66
/
build.gradle.kts
172 lines (154 loc) · 3.99 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
plugins {
`java-library`
application
`maven-publish`
signing
id("org.gradle.test-retry") version "1.6.0"
id("com.github.ben-manes.versions") version "0.51.0"
eclipse
}
repositories {
mavenLocal()
mavenCentral()
maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
val junitJupiterVersion = "5.11.3"
val desc = "Calimero, a free KNX network library"
group = "io.calimero"
version = "3.0-SNAPSHOT"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
withSourcesJar()
withJavadocJar()
}
tasks.withType<Jar>().configureEach {
from(projectDir) {
include("LICENSE.txt")
into("META-INF")
}
if (name == "sourcesJar") {
from(projectDir) {
include("README.md")
}
}
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs.addAll(listOf(
"-Xlint:all,-serial",
"--limit-modules", "java.base,java.xml"
))
}
tasks.named<JavaCompile>("compileJava") {
options.javaModuleVersion = project.version.toString()
}
application {
mainModule.set("io.calimero.core")
mainClass.set("io.calimero.Settings")
}
sourceSets {
main {
java.srcDirs("src")
resources.srcDirs("resources")
}
test {
java {
srcDirs("test")
exclude("resources/", "**/.gradle")
}
resources.srcDirs("test/resources")
}
}
tasks.withType<Javadoc>().configureEach {
(options as CoreJavadocOptions).addStringOption("Xdoclint:-missing", "-quiet")
}
tasks.named<Jar>("jar") {
manifest {
val gitHash = providers.exec {
commandLine("git", "-C", "$projectDir", "rev-parse", "--verify", "--short", "HEAD")
}.standardOutput.asText.map { it.trim() }
val buildDate = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z")
.withZone(ZoneId.of("UTC"))
.format(Instant.now())
attributes(
"Main-Class" to application.mainClass.get(),
"Implementation-Version" to project.version,
"Revision" to gitHash.get(),
"Build-Date" to buildDate
)
}
}
tasks.named<Test>("test") {
useJUnitPlatform {
excludeTags("ft12", "slow")
testLogging {
// exceptionFormat = TestExceptionFormat.FULL
// showStandardStreams = true
}
}
retry {
maxRetries = 2
maxFailures = 20
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = rootProject.name
from(components["java"])
pom {
name.set("Calimero core library")
description.set("Calimero, a free KNX network library")
url.set("https://github.com/calimero-project/calimero-core")
inceptionYear.set("2006")
licenses {
license {
name.set("GNU General Public License, version 2, with the Classpath Exception")
url.set("LICENSE")
}
}
developers {
developer {
name.set("Boris Malinowsky")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/calimero-project/calimero-core.git")
url.set("https://github.com/calimero-project/calimero-core.git")
}
}
}
}
repositories {
maven {
name = "maven"
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials(PasswordCredentials::class)
}
}
}
signing {
if (project.hasProperty("signing.keyId")) {
sign(publishing.publications["mavenJava"])
}
}
plugins.withType<JavaPlugin>().configureEach {
eclipse {
// Eclipse's view of projects treats circular dependencies as errors by default
jdt.file.withProperties { set("org.eclipse.jdt.core.circularClasspath", "warning") }
}
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")
// Eclipse treats circular dependencies as errors by default, see eclipseJdt task above
// testRuntimeOnly("io.calimero:calimero-rxtx:$version")
}