-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
172 lines (147 loc) · 5.03 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
plugins {
// Main gradle plugin for building a Java library
id 'java-library'
// Support writing the extension in Groovy (remove this if you don't want to)
id 'groovy'
// 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'
id 'maven-publish'
}
ext.moduleName = 'qupath.extension.basic-stitching'
group = 'qupath.ext.basicstitching'
base {
archivesName = rootProject.name
version = '0.2.0'
description = 'Provides basic tiling, no overlap resolution yet.'
}
// The default 'gradle.ext.qupathVersion' reads this from settings.gradle.
ext.qupathVersion = gradle.ext.qupathVersion
// Should be Java 17 for QuPath v0.5.0
ext.qupathJavaVersion = 17
/**
* Define dependencies.
* - Using 'shadow' indicates that they are already part of QuPath, so you don't need
* to include them in your extension. If creating a single 'shadow jar' containing your
* extension and all dependencies, these won't be added.
* - Using 'implementation' indicates that you need the dependency for the extension to work,
* and it isn't part of QuPath already. If you are creating a single 'shadow jar', the
* dependency should be bundled up in the extension.
* - Using 'testImplementation' indicates that the dependency is only needed for testing,
* but shouldn't be bundled up for use in the extension.
*/
dependencies {
// Main QuPath user interface jar.
// Automatically includes other QuPath jars as subdependencies.
shadow "io.github.qupath:qupath-gui-fx:${qupathVersion}"
// For logging - the version comes from QuPath's version catalog at
// https://github.com/qupath/qupath/blob/main/gradle/libs.versions.toml
// See https://docs.gradle.org/current/userguide/platforms.html
shadow libs.slf4j
// If you aren't using Groovy, this can be removed
shadow libs.bundles.groovy
implementation libs.qupath.fxtras
testImplementation "io.github.qupath:qupath-gui-fx:${qupathVersion}"
testImplementation libs.junit
implementation "io.github.qupath:qupath-extension-bioformats:${qupathVersion}"
}
/*
* Manifest info
*/
jar {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": archiveVersion,
"Automatic-Module-Name": moduleName)
}
}
/**
* Copy necessary attributes, see
* - https://github.com/qupath/qupath-extension-template/issues/9
* - https://github.com/openjfx/javafx-gradle-plugin#variants
*/
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... if we have one (we should!)
*/
processResources {
from ("${projectDir}/LICENSE") {
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 17 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) {
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) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
/*
* Support tests with JUnit.
*/
tasks.named('test') {
useJUnitPlatform()
}
// 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/groups/public"
}
}
publishing {
publications {
myLibrary(MavenPublication) {
from components.java
}
}
}