-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
149 lines (131 loc) · 4.52 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
import org.javamodularity.moduleplugin.extensions.CompileTestModuleOptions
plugins {
id("org.openjfx.javafxplugin") version "0.0.13"
`java-library`
jacoco
checkstyle
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.hildan.github.changelog") version "1.12.1"
}
group = "org.hildan.fxgson"
description = "A set of type adapters for Google Gson to make JavaFX properties serialization more natural."
java {
withJavadocJar()
withSourcesJar()
}
modularity {
// Compiles the library to bytecode level 8, so it is usable with JRE 8,
// but also compiles module-info.java separately for Java 9+.
// This doesn't build a multi-release jar, because it places module-info.class at the root of the jar.
// See https://github.com/java9-modularity/gradle-modules-plugin#compilation-to-a-specific-java-release
mixedJavaRelease(8)
}
// When mixedJavaRelease is set, the module-info.class is packaged into the sources and javadoc jars (by mistake?)
// se we have to exclude the file explicitly.
// See https://github.com/java9-modularity/gradle-modules-plugin/issues/220
tasks.getByName<Jar>("sourcesJar") {
exclude("module-info.class")
}
tasks.getByName<Jar>("javadocJar") {
exclude("module-info.class")
}
javafx {
version = "11"
modules = listOf("javafx.base", "javafx.graphics")
// This removes any JavaFX dependency from the generated pom.xml, because consumers should define their own
// dependencies on JavaFX to match the correct target platform.
configuration = "compileOnly"
}
repositories {
mavenCentral()
}
val checkstyleConfig: Configuration by configurations.creating {}
configurations {
// provides JavaFX dependencies to tests (because they are added as compileOnly via the javafx plugin)
testImplementation.get().extendsFrom(compileOnly.get())
}
dependencies {
api("com.google.code.gson:gson:2.10")
compileOnlyApi("org.jetbrains:annotations:23.0.0")
testImplementation("junit:junit:4.13.2")
checkstyleConfig("org.hildan.checkstyle:checkstyle-config:2.5.0")
}
checkstyle {
maxWarnings = 0
toolVersion = "8.29"
config = resources.text.fromArchiveEntry(checkstyleConfig, "checkstyle.xml")
}
tasks {
compileTestJava {
extensions.configure<CompileTestModuleOptions> {
// Fallback to classpath mode because with mixedJavaRelease using the module path seems to be broken.
// Despite using classpath, the tests still seem to pick up missing declarations in module-info.java,
// which may be good enough for now.
isCompileOnClasspath = true
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 1.0.toBigDecimal()
}
}
}
}
}
tasks.check {
dependsOn(tasks.jacocoTestCoverageVerification)
}
changelog {
futureVersionTag = project.version.toString()
sinceTag = "1.2.0"
customTagByIssueNumber = mapOf(12 to "3.1.0")
}
nexusPublishing {
packageGroup.set("org.hildan")
repositories {
sonatype()
}
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
val githubUser = findProperty("githubUser") as String? ?: System.getenv("GITHUB_USER")
val githubSlug = "$githubUser/${rootProject.name}"
val githubRepoUrl = "https://github.com/$githubSlug"
pom {
name.set(project.name)
description.set(project.description)
url.set(githubRepoUrl)
licenses {
license {
name.set("The MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("joffrey-bion")
name.set("Joffrey Bion")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:$githubRepoUrl.git")
developerConnection.set("scm:git:[email protected]:$githubSlug.git")
url.set(githubRepoUrl)
}
}
}
}
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["maven"])
}