|
2 | 2 |
|
3 | 3 | This repo contains a template and instructions to help create a new extension for [QuPath](https://qupath.github.io). |
4 | 4 |
|
5 | | -It already contains two minimal extensions, so the first task is to make sure that they work. |
| 5 | +It already contains two minimal extensions - one using Java, one using Groovy - so the first task is to make sure that they work. |
6 | 6 | Then, it's a matter of customizing the code to make it more useful. |
7 | 7 |
|
8 | | -> There are two extensions to show that you can use either Java or Groovy. |
| 8 | +> **Update!** |
| 9 | +> For QuPath v0.6.0 this repo switched to use Kotlin DSL for Gradle build files - |
| 10 | +> and also to use the [QuPath Gradle Plugin](https://github.com/qupath/qupath-gradle-plugin). |
| 11 | +> |
| 12 | +> The outcome is that the build files are _much_ simpler. |
| 13 | +
|
9 | 14 |
|
10 | 15 | ## Build the extension |
11 | 16 |
|
@@ -33,39 +38,88 @@ QuPath. |
33 | 38 | > If you don't do that, you'll need to drag *all* the extra dependences onto QuPath to install them as well. |
34 | 39 |
|
35 | 40 |
|
36 | | -## Set up in an IDE (optional) |
| 41 | +## Configure the extension |
37 | 42 |
|
38 | | -During development, things are likely to be much easier if you work within an IDE. |
| 43 | +Edit `settings.gradle.kts` to specify which version of QuPath your extension should be compatible with, e.g. |
39 | 44 |
|
40 | | -QuPath itself is developed using IntelliJ, and you can import the extension template there. |
| 45 | +```kotlin |
| 46 | +qupath { |
| 47 | + version = "0.6.0-SNAPSHOT" |
| 48 | +} |
| 49 | +``` |
| 50 | +
|
| 51 | +Edit `build.gradle.kts` to specify the details of your extension |
41 | 52 |
|
42 | | -However, for development and testing, it can help to import QuPath *and* the extension and have them in your IDE side-by-side. |
| 53 | +```kotlin |
| 54 | +qupathExtension { |
| 55 | + name = "qupath-extension-template" |
| 56 | + group = "io.github.qupath" |
| 57 | + version = "0.1.0-SNAPSHOT" |
| 58 | + description = "A simple QuPath extension" |
| 59 | + automaticModule = "io.github.qupath.extension.template" |
| 60 | +} |
| 61 | +``` |
43 | 62 |
|
44 | | -In IntelliJ, you can do this in a few steps: |
45 | | -* Get QuPath's source code, as described at https://qupath.readthedocs.io/en/stable/docs/reference/building.html |
46 | | -* Store your extension code in a directory *beside* QuPath's code. So it should be located next to the `qupath` code directory. |
47 | | -* Import QuPath into IntelliJ as a Gradle project (you don't need to import the extension yet!) |
48 | | - * See https://www.jetbrains.com/help/idea/work-with-gradle-projects.html |
49 | | -* Within `qupath/settings.gradle` add the line `includeFlat 'your-extension-code-directory'` (updating the code directory as needed) |
50 | | -* Refresh the Gradle project in IntelliJ, and your extension code should appear |
51 | | -* Create a [Run configuration](https://www.jetbrains.com/help/idea/run-debug-configuration.html) in IntelliJ to launch QuPath. An example of how that looks is shown below: |
52 | 63 |
|
53 | | -<img src="qupath-intellij.png" alt="QuPath run configuration in IntelliJ" width="428" /> |
| 64 | +## Run QuPath + the extension |
54 | 65 |
|
55 | | -Now when you run QuPath from IntelliJ, your extension should (hopefully) be found - there's no need to add it by drag & drop. |
| 66 | +During development, your probably want to run QuPath easily with your extension installed for debugging. |
56 | 67 |
|
57 | | -## Customize the extension |
| 68 | +### 0. Make sure you have Java installed |
| 69 | +You'll need to install Java first. |
58 | 70 |
|
59 | | -There are a few fixed steps to customizing the extension, and then the main creative part where you add your own code. |
| 71 | +At the time of writing, we use a Java 21 JDK downloaded from https://adoptium.net/ |
60 | 72 |
|
61 | | -### Update `settings.gradle` |
| 73 | +> Java 21 is a 'Long Term Support' release - which is why we use it instead of the very latest version. |
| 74 | +
|
| 75 | +### 1. Get QuPath's source code |
| 76 | +You can find instructions at https://qupath.readthedocs.io/en/stable/docs/reference/building.html |
| 77 | + |
| 78 | +### 2. Create an `include-extra` file |
| 79 | +Create a file called `include-extra` in the root directory of the QuPath source code (*not* the extension code!). |
| 80 | + |
| 81 | +Set the contents of this file to: |
| 82 | +``` |
| 83 | +[includeBuild] |
| 84 | +/path/to/your/extension |
| 85 | +
|
| 86 | +[dependencies] |
| 87 | +extension-group:extension-name |
| 88 | +``` |
| 89 | +replacing the default lines where needed. |
| 90 | + |
| 91 | +For example, to build the extension with the names given above you'd use |
| 92 | +``` |
| 93 | +[includeBuild] |
| 94 | +../qupath-extension-template |
62 | 95 |
|
63 | | -Open `settings.gradle` and check the comment lines flagged with `\\TODO`. |
64 | | -These point you towards parts you may well need to change. |
| 96 | +[dependencies] |
| 97 | +io.github.qupath:qupath-extension-template |
| 98 | +``` |
| 99 | + |
| 100 | +### 3. Run QuPath |
| 101 | +Run QuPath from the command line using |
| 102 | +``` |
| 103 | +gradlew run |
| 104 | +``` |
| 105 | +If all goes well, QuPath should launch and you can check the *Extensions* mention to confirm the extension is installed. |
| 106 | + |
| 107 | + |
| 108 | +## Set up in an IDE (optional) |
| 109 | + |
| 110 | +During development, things are likely to be much easier if you work within an IDE. |
| 111 | + |
| 112 | +QuPath itself is developed using IntelliJ, and you can import the extension template there. |
| 113 | + |
| 114 | +The setup process is as above, and you'll need a a [Run configuration](https://www.jetbrains.com/help/idea/run-debug-configuration.html) |
| 115 | +to call `gradlew run`. |
| 116 | + |
| 117 | + |
| 118 | +## Customize the extension |
65 | 119 |
|
66 | | -### Update `build.gradle` |
| 120 | +Now you're ready for the creative part. |
67 | 121 |
|
68 | | -Open `build.gradle` and follow a similar process to with `settings.gradle`, to update the bits flagged with `\\TODO`. |
| 122 | +You can develop the extension using either Java or Groovy - the template includes examples of both. |
69 | 123 |
|
70 | 124 | ### Create the extension Java or Groovy file(s) |
71 | 125 |
|
|
0 commit comments