diff --git a/build.gradle.kts b/build.gradle.kts index 6f1da22..0bb322d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,167 +1,32 @@ plugins { - `java-library` + id("qupath-conventions") `maven-publish` - // Include this plugin to avoid downloading JavaCPP dependencies for all platforms - id("org.bytedeco.gradle-javacpp-platform") - id("org.openjfx.javafxplugin") } -val moduleName = "io.github.qupath.extension.instanseg" - -base { - archivesName = rootProject.name - version = "0.0.1-SNAPSHOT" - description = "A QuPath extension for running inference with the InstanSeg deep learning model" +qupathExtension { + name = "qupath-extension-instanseg" + version = "0.1.0-SNAPSHOT" group = "io.github.qupath" + description = "A QuPath extension for running inference with the InstanSeg deep learning model" + automaticModule = "qupath.extension.instanseg" } -javafx { - version = libs.versions.jdk.get() - modules = listOf( - "javafx.controls", - "javafx.fxml", - "javafx.web" - ) -} - -val qupathVersion = gradle.extra["qupath.app.version"] - -/** - * 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 - implementation("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 - implementation(libs.slf4j) + implementation(libs.bundles.qupath) + implementation(libs.bundles.logging) implementation(libs.qupath.fxtras) + implementation(libs.bundles.markdown) + implementation(libs.bioimageio.spec) implementation(libs.deepJavaLibrary) - implementation(libs.commonmark) - implementation("io.github.qupath:qupath-extension-djl:0.4.0-SNAPSHOT") - testImplementation("io.github.qupath:qupath-gui-fx:${qupathVersion}") + // For testing testImplementation(libs.junit) -} - -/* - * Manifest info - */ -tasks.withType { - manifest { - attributes( - mapOf("Implementation-Title" to project.name, - "Implementation-Version" to project.version, - "Automatic-Module-Name" to moduleName) - ) - } -} - -/* - * Copy the LICENSE file into the jar... if we have one (we should!) - */ -tasks.processResources { - from ("${projectDir}/LICENSE") { - into("licenses/") - } -} - -/* - * Define extra 'copyDependencies' task to copy dependencies into the build directory. - */ -tasks.register("copyDependencies") { - 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(libs.versions.jdk.get()) - } - 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 { - options.encoding = "UTF-8" - val strictJavadoc = providers.gradleProperty("strictJavadoc").getOrElse("false") - if (!"true".equals(strictJavadoc, true)) { - (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") - } } -/* - * Specify that the encoding should be UTF-8 for source files - */ -tasks.withType { - // Include parameter names, so they are available in the script editor via reflection - options.compilerArgs = listOf("-parameters") - // Specify source should be UTF8 - options.encoding = "UTF-8" -} - -/* - * Avoid 'Entry .gitkeep is a duplicate but no duplicate handling strategy has been set.' - * when using withSourcesJar() - */ -tasks.jar { - duplicatesStrategy = DuplicatesStrategy.INCLUDE -} - -/* - * Support tests with JUnit. - */ -tasks.test { - useJUnitPlatform() -} - -// Looks redundant to include this here and in settings.gradle.kts, -// but helps overcome some gradle trouble when including this as a subproject -// within QuPath itself (which is useful during development). -repositories { - - if ("true" == providers.gradleProperty("use-maven-local").getOrElse("false")) { - logger.warn("Using Maven local") - mavenLocal() - } - - mavenCentral() - - // Add scijava - which is where QuPath's jars are hosted - maven { - url = uri("https://maven.scijava.org/content/repositories/releases") - } - - maven { - url = uri("https://maven.scijava.org/content/repositories/snapshots") - } - -} - - publishing { repositories { maven { @@ -180,7 +45,6 @@ publishing { publications { create("mavenJava") { from(components["java"]) - pom { licenses { license { @@ -191,4 +55,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/settings.gradle.kts b/settings.gradle.kts index bad136b..12d007b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,34 +1,17 @@ pluginManagement { - plugins { - id("org.bytedeco.gradle-javacpp-platform") version "1.5.10" - id("org.openjfx.javafxplugin") version "0.1.0" - } + repositories { + gradlePluginPortal() + maven { + url = uri("https://maven.scijava.org/content/repositories/releases") + } + } } -rootProject.name = "qupath-extension-instanseg" -var qupathVersion = "0.6.0-SNAPSHOT" -gradle.extra["qupath.app.version"] = qupathVersion - -dependencyResolutionManagement { - - // Access QuPath's version catalog for dependency versions - versionCatalogs { - create("libs") { - from("io.github.qupath:qupath-catalog:$qupathVersion") - } - } - - repositories { - mavenCentral() - - // Add scijava - which is where QuPath's jars are hosted - maven { - url = uri("https://maven.scijava.org/content/repositories/releases") - } - - maven { - url = uri("https://maven.scijava.org/content/repositories/snapshots") - } +qupath { + version = "0.6.0-SNAPSHOT" +} - } +// Apply QuPath Gradle settings plugin to handle configuration +plugins { + id("io.github.qupath.qupath-extension-settings") version "0.2.1" }