Skip to content

Commit

Permalink
Merge pull request #114 from petebankhead/kotlin
Browse files Browse the repository at this point in the history
Use kotlin for build scripts
  • Loading branch information
petebankhead authored Nov 26, 2024
2 parents 76e3402 + cb6fdd9 commit d9eb155
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 101 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Forum](https://img.shields.io/badge/forum-image.sc-green)](https://forum.image.sc/tag/qupath)

<img style="float: right" width="25%" alt="InstanSeg logo" src="https://github.com/instanseg/instanseg/raw/main/images/instanseg_logo.png" />
<img style="float: right" width="25%" alt="InstanSeg logo" src="https://github.com/instanseg/instanseg/raw/main/assets/instanseg_logo.png" />

## 🚧 Work-in-progress! 🚧

Expand Down
116 changes: 65 additions & 51 deletions build.gradle → build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
plugins {
id 'java-library'
id 'maven-publish'
`java-library`
`maven-publish`
// 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("org.bytedeco.gradle-javacpp-platform")
id("org.openjfx.javafxplugin")
}

ext.moduleName = 'io.github.qupath.extension.instanseg'
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'
group = 'io.github.qupath'
version = "0.0.1-SNAPSHOT"
description = "A QuPath extension for running inference with the InstanSeg deep learning model"
group = "io.github.qupath"
}

ext.qupathVersion = gradle.ext.qupathVersion
javafx {
version = libs.versions.jdk.get()
modules = listOf(
"javafx.controls",
"javafx.fxml",
"javafx.web"
)
}

val qupathVersion = gradle.extra["qupath.app.version"]

/**
* Define dependencies.
Expand All @@ -30,57 +39,59 @@ ext.qupathVersion = gradle.ext.qupathVersion
*/
dependencies {
// Main QuPath user interface jar.
// Automatically includes other QuPath jars as subdependencies.
implementation "io.github.qupath:qupath-gui-fx:${qupathVersion}"
// 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.slf4j)

implementation libs.qupath.fxtras
implementation libs.bioimageio.spec
implementation libs.deepJavaLibrary
implementation libs.commonmark
implementation(libs.qupath.fxtras)
implementation(libs.bioimageio.spec)
implementation(libs.deepJavaLibrary)
implementation(libs.commonmark)

implementation 'io.github.qupath:qupath-extension-djl:0.4.0-SNAPSHOT'
implementation("io.github.qupath:qupath-extension-djl:0.4.0-SNAPSHOT")

testImplementation "io.github.qupath:qupath-gui-fx:${qupathVersion}"
testImplementation libs.junit
testImplementation("io.github.qupath:qupath-gui-fx:${qupathVersion}")
testImplementation(libs.junit)
}

/*
* Manifest info
*/
jar {
tasks.withType<Jar> {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": archiveVersion,
"Automatic-Module-Name": moduleName)
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!)
*/
processResources {
tasks.processResources {
from ("${projectDir}/LICENSE") {
into '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"
tasks.register<Copy>("copyDependencies") {
description = "Copy dependencies into the build directory for use elsewhere"
group = "QuPath"

from configurations.default
into 'build/libs'
from(configurations.default)
into("build/libs")
}

/*
* Ensure Java 17 compatibility, and include sources and javadocs when building.
* Ensure Java compatibility, and include sources and javadocs when building
*/
java {
toolchain {
Expand All @@ -94,42 +105,45 @@ java {
* 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')
tasks.withType<Javadoc> {
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.named('compileJava') {
options.encoding = 'UTF-8'
tasks.withType<JavaCompile> {
// 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.withType(org.gradle.jvm.tasks.Jar) {
tasks.jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

/*
* Support tests with JUnit.
*/
tasks.named('test') {
tasks.test {
useJUnitPlatform()
}

// Looks redundant to include this here and in settings.gradle,
// 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 (findProperty("use-maven-local")) {
if ("true" == providers.gradleProperty("use-maven-local").getOrElse("false")) {
logger.warn("Using Maven local")
mavenLocal()
}
Expand All @@ -138,11 +152,11 @@ repositories {

// Add scijava - which is where QuPath's jars are hosted
maven {
url "https://maven.scijava.org/content/repositories/releases"
url = uri("https://maven.scijava.org/content/repositories/releases")
}

maven {
url "https://maven.scijava.org/content/repositories/snapshots"
url = uri("https://maven.scijava.org/content/repositories/snapshots")
}

}
Expand All @@ -152,10 +166,10 @@ publishing {
repositories {
maven {
name = "SciJava"
def releasesRepoUrl = uri("https://maven.scijava.org/content/repositories/releases")
def snapshotsRepoUrl = uri("https://maven.scijava.org/content/repositories/snapshots")
val releasesRepoUrl = uri("https://maven.scijava.org/content/repositories/releases")
val snapshotsRepoUrl = uri("https://maven.scijava.org/content/repositories/snapshots")
// Use gradle -Prelease publish
url = project.hasProperty('release') ? releasesRepoUrl : snapshotsRepoUrl
url = if (project.hasProperty("release")) releasesRepoUrl else snapshotsRepoUrl
credentials {
username = System.getenv("MAVEN_USER")
password = System.getenv("MAVEN_PASS")
Expand All @@ -164,14 +178,14 @@ publishing {
}

publications {
mavenJava(MavenPublication) {
from components.java
create<MavenPublication>("mavenJava") {
from(components["java"])

pom {
licenses {
license {
name = 'Apache License v2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
name = "Apache License v2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0"
}
}
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
36 changes: 0 additions & 36 deletions settings.gradle

This file was deleted.

34 changes: 34 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pluginManagement {
plugins {
id("org.bytedeco.gradle-javacpp-platform") version "1.5.10"
id("org.openjfx.javafxplugin") version "0.1.0"
}
}

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")
}

}
}

0 comments on commit d9eb155

Please sign in to comment.