Skip to content

Commit 8fa67bf

Browse files
authored
Merge pull request #156 from petebankhead/building
Update building instructions
2 parents 8767431 + 2e4393a commit 8fa67bf

File tree

7 files changed

+128
-22
lines changed

7 files changed

+128
-22
lines changed

conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
html_favicon = 'docs/images/QuPath.ico'
102102

103103
# Variables for current QuPath version
104-
release = '0.6.0-rc4'
104+
release = '0.6.0-rc5'
105105
version = '0.6'
106106
java_version = '21'
107107

docs/reference/building.md

Lines changed: 127 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Building software can be tricky, but hopefully this won't be - thanks to [Gradle].
66

7-
:::{note}
7+
:::{admonition} You might not need this
88
Most people using QuPath won't need to build QuPath from source!
99
Just download an existing installer from [qupath.github.io](https://qupath.github.io) and use that instead.
1010

@@ -45,8 +45,12 @@ cd qupath
4545
:::
4646
::::
4747

48-
:::{warning}
49-
You'll need to type `gradlew` if you're using a standard command prompt on Windows, but `./gradlew` if you're using macOS, Linux, or Windows with some other shell prompt.
48+
:::{admonition} Dot or not?
49+
:class: warning
50+
51+
You'll need to type `gradlew` if you're using a standard command prompt on Windows.
52+
53+
You'll need `./gradlew` if you're using macOS, Linux, or Windows with some other shell prompt.
5054
:::
5155

5256
It will take a few minutes to download everything required and build the software.
@@ -61,6 +65,8 @@ Example of command line build success
6165
**That's it!**
6266
You can find QuPath inside the `./build/dist/` subdirectory.
6367

68+
If it *didn't* go so well, check out [](#Troubleshooting).
69+
6470
:::{admonition} Which Java version do I need?
6571
:class: tip
6672

@@ -73,9 +79,33 @@ Switching to an OpenJDK distribution based on HotSpot may help -- see [here](htt
7379
:::
7480

7581

76-
### Customizing the build
82+
## Running with Gradle
83+
84+
You can also run QuPath from the command line via Gradle, without needing to create the package.
85+
86+
To do this, replace `jpackage` above with `run` (and `clean` is optional).
87+
The command would then be simply
88+
89+
::::{tab-set}
90+
91+
:::{tab-item} Windows
92+
:sync: win
93+
94+
``` bash
95+
gradlew run
96+
```
97+
:::
98+
99+
:::{tab-item} macOS/Linux
100+
:sync: nix
101+
102+
``` bash
103+
./gradlew run
104+
```
105+
:::
106+
::::
77107

78-
#### Creating installers
108+
## Creating installers
79109

80110
If you need to create an installer for QuPath, you can use
81111

@@ -124,23 +154,73 @@ Then I only need to call
124154
rather than some elaborate command that includes all these options.
125155
:::
126156

127-
#### Building a specific version
157+
## Building a specific version
158+
159+
You can circumvent the need to use git entirely by downloading the QuPath code associated with a specific release from <http://github.com/qupath/qupath/releases>
160+
161+
Simply choose the *Source code (zip)* or *Source code (tar.gz)* option.
162+
You can then build it from a command prompt as described above.
128163

129-
QuPath releases are associated with different git tags.
130-
You can get the code associated with QuPath {{ env.config.release }} by using the command
164+
Alternatively, you can get the code associated with a specific QuPath release using git tags.
165+
For example, to get the code for QuPath {{ env.config.release }} use the command
131166

132167
```{eval-rst}
133168
.. parsed-literal::
134169
git checkout tags/v\ |release|\ -b\ v\ |release|
135170
```
136171

137-
You can then try building it as above, however *note that some different versions may require different build commands* (e.g. the steps for v0.2.3 are slightly different from v0.3.0).
172+
You can then try building it as above.
173+
174+
:::{admonition} Build commands might be different!
175+
:class: warning
176+
177+
Some older QuPath versions might require different build commands (e.g. the steps for v0.2.3 are slightly different from v0.3.0).
138178
Check out the docs associated with the specific version if this is the case.
179+
:::
180+
181+
182+
## Building with Fiji
183+
By default, QuPath embeds a version of [ImageJ](https://imagej.net/software/imagej/).
184+
This allows you to [send image regions to ImageJ, and even use custom ImageJ plugins](ImageJ).
185+
186+
[Fiji](https://fiji.sc) is a special distribution of ImageJ that contains a *lot* of custom plugins, and many extra features and other changes.
187+
188+
Thanks to [help from Curtis Rueden](https://forum.image.sc/t/embedding-fiji-inside-qupath/105065), since QuPath v0.6.0 it's possible to build QuPath with Fiji using
189+
190+
::::{tab-set}
191+
192+
:::{tab-item} Windows
193+
:sync: win
194+
195+
``` bash
196+
./gradlew jpackage -Pfiji
197+
```
198+
:::
199+
200+
:::{tab-item} macOS/Linux
201+
:sync: nix
202+
203+
``` bash
204+
./gradlew jpackage -Pfiji
205+
```
206+
:::
207+
::::
208+
209+
Note that this will take some time to download everything it needs, and the package will be a *lot* bigger.
210+
We also can't guarantee *everything* will work perfectly -- but most things we've tried seem to.
211+
212+
:::{figure} images/qupath-fiji.jpg
213+
:class: shadow-image mid-image
214+
215+
QuPath built with Fiji
216+
:::
139217

140218
## Other options
141219

142220
A few other ways to obtain and/or build QuPath's code are described below.
143-
These might be better if you a) don't like the command line much, or b) want to make changes to the software.
221+
These might be better if you
222+
1. don't like the command line much, or
223+
2. want to make changes to the software.
144224

145225
### GitHub Desktop
146226

@@ -193,7 +273,7 @@ gradlew clean jpackage
193273
Once you've built QuPath once, updating it to use the latest source code in *GitHub Desktop* should be easier.
194274
The right-most button on the main toolbar serves two purposes: to {guilabel}`Fetch` information about the latest changes (from GitHub) and to {guilabel}`Pull` the changes down to your computer.
195275

196-
:::{figure} images/building-branches.png
276+
:::{figure} images/building-fetch.png
197277
:class: shadow-image full-image
198278

199279
The GitHub Desktop interface
@@ -204,32 +284,27 @@ If the option is {guilabel}`Fetch origin`, when you press the button the text wi
204284
You can press it again to pull those changes, and then rebuild QuPath using `gradlew`.
205285

206286
:::{figure} images/building-pull.png
207-
:class: shadow-image mid-image
287+
:class: shadow-image full-image
208288

209289
Pulling changes from GitHub
210290
:::
211291
::::
212292

213-
### Download release
214-
215-
You can circumvent the need to use git entirely by downloading the QuPath code associated with a specific release from <http://github.com/qupath/qupath/releases>
216-
217-
Simply choose the *Source code (zip)* or *Source code (tar.gz)* option.
218-
You can then build it from a command prompt as described above.
219293

220294
### Running from an IDE
221295

222296
You should be able to import QuPath into any IDE (e.g. *IntelliJ*, *Eclipse*) that supports Gradle.
223297

224298
#### IntelliJ IDEA
225299

226-
I personally use [IntelliJ IDEA] for QuPath development, which allows me to run
227-
the software in debug mode -- and even change the code while it is running.
300+
The QuPath devs mostly use [IntelliJ IDEA] for QuPath development.
301+
This allows us to run the software in debug mode -- and even change the code while it is running.
228302

229303
To do this, you can either:
230304

231305
* download and build QuPath once as described above, then use {menuselection}`Open` from within IntelliJ, and navigate to the directory containing the QuPath code, or
232-
* use {menuselection}`Get from VCS` in IntelliJ to download the code directly from GitHub using git. To do this, you should use the URL `https://github.com/qupath/qupath.git` (or the URL to your own git repository housing the QuPath code).
306+
* use {menuselection}`Get from VCS` in IntelliJ to download the code directly from GitHub using git.
307+
To do this, you should use the URL `https://github.com/qupath/qupath.git` (or the URL to your own git repository housing the QuPath code).
233308

234309
If you download the code using this approach, you should make sure you have installed a Java JDK before proceeding any further (see instructions above).
235310

@@ -260,6 +335,37 @@ to reload the changes *while QuPath is running*.
260335
Provided they aren't *too* extreme, the changes will be incorporated into the software without needing to relaunch it.
261336
However, any major changes that alter method signatures (e.g. adding or removing arguments, or changing return types) will require QuPath to be relaunched.
262337

338+
## Troubleshooting
339+
340+
Two fairly common things can go wrong when attempting to build QuPath:
341+
1. The version of Java used to run Gradle is too old - *even if the right version is installed*
342+
* Fix this by telling Gradle more insistently which Java version to use, via `-Dorg.gradle.java.home`
343+
2. Javadocs are unavailable -- or a firewall is blocking access to them
344+
* Fix this by adding `-x javadoc` to the Gradle command used to build QuPath, to skip the javadocs
345+
346+
Both are described [in this post on image.sc](https://forum.image.sc/t/building-qupath-0-6-0-rc5-from-source/113232).
347+
An example using both these fixes is shown below:
348+
349+
::::{tab-set}
350+
351+
:::{tab-item} Windows
352+
:sync: win
353+
354+
``` bash
355+
gradlew clean jpackage -x javadoc -Dorg.gradle.java.home="C:/Program Files/Microsoft/jdk-21.0.7.6-hotspot"
356+
```
357+
:::
358+
359+
:::{tab-item} macOS/Linux
360+
:sync: nix
361+
362+
``` bash
363+
./gradlew clean jpackage -x javadoc -Dorg.gradle.java.home="C:/Program Files/Microsoft/jdk-21.0.7.6-hotspot"
364+
```
365+
:::
366+
::::
367+
368+
263369
[Visual Studio Code]: https://code.visualstudio.com
264370
[IntelliJ IDEA]: https://www.jetbrains.com/idea/
265371
[github desktop]: https://desktop.github.com/
-11.3 KB
Binary file not shown.
26.3 KB
Loading
19.5 KB
Loading
26.2 KB
Loading
166 KB
Loading

0 commit comments

Comments
 (0)