-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
176 lines (153 loc) · 4.79 KB
/
build.gradle
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
// SPDX-FileCopyrightText: 2024 Carlo Castoldi <[email protected]>
//
// SPDX-License-Identifier: CC0-1.0
plugins {
id "jacoco"
id "java-library"
// To create a shadow/fat jar that bundle up all dependencies
id "com.github.johnrengelman.shadow" version "8.1.1"
// Include this plugin to avoid downloading JavaCPP dependencies for all platforms
id "org.bytedeco.gradle-javacpp-platform"
id "org.openjfx.javafxplugin" version "0.1.0"
}
ext.moduleName = "qupath.extension.braian"
base {
archivesName = rootProject.name
version = "1.0.3-SNAPSHOT"
description = "QuPath extension for whole-brain data extraction"
}
ext.qupathVersion = gradle.ext.qupathVersion
ext.qupathJavaVersion = 17
dependencies {
// Main QuPath user interface jar.
// Automatically includes other QuPath jars as subdependencies.
shadow "io.github.qupath:qupath-gui-fx:$qupathVersion"
shadow libs.slf4j
// For JavaFX
shadow libs.qupath.fxtras
shadow libs.snakeyaml
testImplementation "io.github.qupath:qupath-gui-fx:$qupathVersion" // repeat dependency, since it was shadowed
testImplementation libs.junit
testImplementation "org.mockito:mockito-core:5.+"
testRuntimeOnly libs.junit.platform
}
jar {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": archiveVersion,
"Automatic-Module-Name": moduleName)
}
}
tasks.test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
csv.required = true
}
doLast {
print "INSTRUCTIONS: " + printJacocoCoverage("3")
println " BRANCHES: " + printJacocoCoverage("5")
}
}
tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.8
}
}
}
}
def printJacocoCoverage(String xpath) {
def jacocoCoverage = new ByteArrayOutputStream()
exec {
commandLine "xmllint","-html","-xpath", "//tfoot//td["+xpath+"]/text()", "build/reports/jacoco/test/html/index.html"
standardOutput = jacocoCoverage
ignoreExitValue true
}
return jacocoCoverage.toString()
}
/**
* Copy necessary attributes, see
* <li>https://github.com/qupath/qupath-extension-template/issues/9</li>
* <li>https://github.com/openjfx/javafx-gradle-plugin#variants</li>
*
*/
configurations.shadow {
def runtimeAttributes = configurations.runtimeClasspath.attributes
runtimeAttributes.keySet().each { key ->
if (key in [Usage.USAGE_ATTRIBUTE, OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, MachineArchitecture.ARCHITECTURE_ATTRIBUTE])
attributes.attribute(key, runtimeAttributes.getAttribute(key))
}
}
/**
* Copy the LICENSE file into the jar
**/
processResources {
from ("${projectDir}/LICENSES/*") {
into "licenses/"
}
}
/**
* Define extra "copyDependencies" task to copy dependencies into the build directory.
**/
tasks.register("copyDependencies", Copy) {
description "Copy dependencies into the build directory for use elsewhere"
group "QuPath"
from configurations.default
into "build/libs"
}
/**
* Ensure Java compatibility, and include sources and javadocs when building.
**/
java {
toolchain {
languageVersion = JavaLanguageVersion.of(qupathJavaVersion)
}
withSourcesJar()
withJavadocJar()
}
/**
* Create javadocs for all modules/packages in one place.
* Use -PstrictJavadoc=true to fail on error with doclint (which is rather strict).
**/
tasks.withType(Javadoc).configureEach {
options.encoding = "UTF-8"
def strictJavadoc = findProperty("strictJavadoc")
if (!strictJavadoc) {
options.addStringOption("Xdoclint:none", "-quiet")
}
}
/**
* Specify that the encoding should be UTF-8 for source files
**/
tasks.named("compileJava") {
options.encoding = "UTF-8"
}
/**
* Avoid "Entry .gitkeep is a duplicate but no duplicate handling strategy has been set."
* when using withSourcesJar()
**/
tasks.withType(org.gradle.jvm.tasks.Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
/**
* Looks redundant to include this here and in settings.gradle,
* but helps overcome some gradle trouble when including this as a subproject
* within QuPath itself (which is useful during development).
**/
repositories {
// Add this if you need access to dependencies only installed locally
// mavenLocal()
mavenCentral()
// Add scijava - which is where QuPath"s jars are hosted
maven {
url "https://maven.scijava.org/content/repositories/releases"
}
maven {
url "https://maven.scijava.org/content/repositories/snapshots"
}
}