|
| 1 | +import org.gradle.kotlin.dsl.implementation |
| 2 | +import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.* |
| 3 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 4 | +import sciJava.* |
| 5 | +import java.net.URL |
| 6 | + |
| 7 | +plugins { |
| 8 | + val ktVersion = "1.4.20" |
| 9 | + java |
| 10 | + kotlin("jvm") version ktVersion |
| 11 | + kotlin("kapt") version ktVersion |
| 12 | + sciview.publish |
| 13 | + sciview.sign |
| 14 | + id("com.github.elect86.sciJava") version "0.0.4" |
| 15 | + id("org.jetbrains.dokka") version ktVersion |
| 16 | + jacoco |
| 17 | + idea |
| 18 | +} |
| 19 | + |
| 20 | +repositories { |
| 21 | + mavenCentral() |
| 22 | + jcenter() |
| 23 | + maven("https://jitpack.io") |
| 24 | + maven("https://maven.scijava.org/content/groups/public") |
| 25 | +} |
| 26 | + |
| 27 | +val sceneryVersion = "4a0c1f7" |
| 28 | +// here we set some versions |
| 29 | +//"scijava-common"("2.84.0") |
| 30 | +"ui-behaviour"("2.0.3") |
| 31 | +"imagej-mesh"("0.8.1") |
| 32 | +"bigdataviewer-vistools"("1.0.0-beta-21") |
| 33 | +"bigvolumeviewer"("0.1.8") // added from Gradle conversion |
| 34 | + |
| 35 | +"kotlin"("1.4.20") |
| 36 | +"kotlinx-coroutines-core"("1.3.9") |
| 37 | + |
| 38 | +dependencies { |
| 39 | + |
| 40 | + // Graphics dependencies |
| 41 | + |
| 42 | + val sciJavaCommon = "org.scijava:scijava-common:${versions["scijava-common"]}" |
| 43 | + annotationProcessor(sciJavaCommon) |
| 44 | + kapt(sciJavaCommon) |
| 45 | + |
| 46 | +// api("graphics.scenery:scenery:$sceneryVersion") |
| 47 | + api("com.github.scenerygraphics:scenery:$sceneryVersion") |
| 48 | + |
| 49 | + sciJava("net.clearvolume:cleargl") |
| 50 | + sciJava("net.clearcontrol:coremem") |
| 51 | + sciJava("org.jogamp.jogl:jogl-all", native = joglNative) |
| 52 | + |
| 53 | + implementation("com.formdev:flatlaf:0.38") |
| 54 | + |
| 55 | + // SciJava dependencies |
| 56 | + |
| 57 | + sciJava("org.scijava"["scijava-common", "ui-behaviour", "script-editor", "scijava-ui-swing", |
| 58 | + "scijava-ui-awt", "scijava-search", "scripting-jython"]) |
| 59 | + implementation("org.scijava:scijava-common:2.83.0") { |
| 60 | + version { strictly("2.83.3") } |
| 61 | + } |
| 62 | + sciJava("com.miglayout:miglayout-swing") |
| 63 | + |
| 64 | + // ImageJ dependencies |
| 65 | + |
| 66 | + sciJava("net.imagej") { |
| 67 | + exclude("org.scijava", "scripting-renjin") |
| 68 | + exclude("org.scijava", "scripting-jruby") |
| 69 | + } |
| 70 | + |
| 71 | + sciJava("net.imagej:imagej-"["common", "mesh", "mesh-io", "ops", "launcher", "ui-swing", "legacy"]) |
| 72 | + sciJava("io.scif:scifio"["", "-bf-compat"]) |
| 73 | + |
| 74 | + // ImgLib2 dependencies |
| 75 | + |
| 76 | + sciJava("net.imglib2:imglib2"["-roi", ""]) |
| 77 | + |
| 78 | + // Math dependencies |
| 79 | + |
| 80 | + sciJava("org.apache.commons:commons-math3") |
| 81 | + sciJava("org.joml") |
| 82 | + |
| 83 | + // Kotlin dependencies |
| 84 | + |
| 85 | + sciJava("org.jetbrains.kotlinx:kotlinx-coroutines-core") |
| 86 | + |
| 87 | + // Optional dependencies - for sc.iview.Main only! --> |
| 88 | + // <dependency> |
| 89 | + // <groupId>org.scijava</groupId> |
| 90 | + // <artifactId>scijava-plugins-commands</artifactId> |
| 91 | + // <scope>runtime</scope> |
| 92 | + // <optional>true</optional> |
| 93 | + // </dependency> |
| 94 | + // <dependency> |
| 95 | + // <groupId>net.imagej</groupId> |
| 96 | + // <artifactId>imagej-plugins-commands</artifactId> |
| 97 | + // <scope>runtime</scope> |
| 98 | + // <optional>true</optional> |
| 99 | + // </dependency> |
| 100 | + // <dependency> |
| 101 | + // <groupId>ch.qos.logback</groupId> |
| 102 | + // <artifactId>logback-classic</artifactId> |
| 103 | + // </dependency> |
| 104 | + |
| 105 | + // Test scope |
| 106 | + |
| 107 | + testSciJava("junit") |
| 108 | + sciJava("net.imagej:ij", test = false) |
| 109 | + sciJava("net.imglib2:imglib2-ij", test = false) |
| 110 | + |
| 111 | + |
| 112 | + sciJava("org.janelia.saalfeldlab:n5"["", "-hdf5", "-imglib2"]) |
| 113 | + sciJava("sc.fiji:spim_data") |
| 114 | + |
| 115 | + implementation(platform(kotlin("bom"))) |
| 116 | + implementation(kotlin("stdlib-jdk8")) |
| 117 | + testImplementation(kotlin("test-junit")) |
| 118 | + |
| 119 | + sciJava("sc.fiji"["bigdataviewer-core", "bigdataviewer-vistools", "bigvolumeviewer"]) |
| 120 | + |
| 121 | + // this apparently is still necessary |
| 122 | + implementation(platform("org.lwjgl:lwjgl-bom:3.2.3")) |
| 123 | + val os = getCurrentOperatingSystem() |
| 124 | + val lwjglNatives = "natives-" + when { |
| 125 | + os.isWindows -> "windows" |
| 126 | + os.isLinux -> "linux" |
| 127 | + os.isMacOsX -> "macos" |
| 128 | + else -> error("invalid") |
| 129 | + } |
| 130 | + listOf("", "-glfw", "-jemalloc", "-vulkan", "-opengl", "-openvr", "-xxhash", "-remotery").forEach { |
| 131 | + implementation("org.lwjgl:lwjgl$it") |
| 132 | + if (it != "-vulkan") |
| 133 | + runtimeOnly("org.lwjgl", "lwjgl$it", classifier = lwjglNatives) |
| 134 | + } |
| 135 | + |
| 136 | + sciJava("graphics.scenery:spirvcrossj:0.7.0-1.1.106.0") |
| 137 | + runtimeOnly("graphics.scenery", "spirvcrossj", "0.7.0-1.1.106.0", classifier = lwjglNatives) |
| 138 | + |
| 139 | + sciJava("net.java.jinput:jinput:2.0.9", native = "natives-all") |
| 140 | +} |
| 141 | + |
| 142 | +kapt { |
| 143 | + useBuildCache = false // safe |
| 144 | + arguments { |
| 145 | + arg("-Werror") |
| 146 | + arg("-Xopt-in", "kotlin.RequiresOptIn") |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +tasks { |
| 151 | + withType<KotlinCompile>().all { |
| 152 | + val version = System.getProperty("java.version").substringBefore('.').toInt() |
| 153 | + val default = if (version == 1) "1.8" else "$version" |
| 154 | + kotlinOptions { |
| 155 | + jvmTarget = project.properties["jvmTarget"]?.toString() ?: default |
| 156 | + freeCompilerArgs += listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn") |
| 157 | + } |
| 158 | + sourceCompatibility = project.properties["sourceCompatibility"]?.toString() ?: default |
| 159 | + } |
| 160 | + // https://docs.gradle.org/current/userguide/java_testing.html#test_filtering |
| 161 | + test { |
| 162 | + finalizedBy(jacocoTestReport) // report is always generated after tests run |
| 163 | + } |
| 164 | + jar { |
| 165 | + archiveVersion.set(rootProject.version.toString()) |
| 166 | + } |
| 167 | + |
| 168 | + dokkaHtml { |
| 169 | + enabled = false |
| 170 | + dokkaSourceSets.configureEach { |
| 171 | + sourceLink { |
| 172 | + localDirectory.set(file("src/main/kotlin")) |
| 173 | + remoteUrl.set(URL("https://github.com/scenerygraphics/sciview/tree/master/src/main/kotlin")) |
| 174 | + remoteLineSuffix.set("#L") |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + dokkaJavadoc { |
| 180 | + enabled = false |
| 181 | + } |
| 182 | + |
| 183 | + jacocoTestReport { |
| 184 | + reports { |
| 185 | + xml.isEnabled = true |
| 186 | + html.apply { |
| 187 | + isEnabled = false |
| 188 | + // destination = file("$buildDir/jacocoHtml") |
| 189 | + } |
| 190 | + } |
| 191 | + dependsOn(test) // tests are required to run before generating the report |
| 192 | + } |
| 193 | + register("runApp", JavaExec::class.java) { |
| 194 | + classpath = sourceSets.main.get().runtimeClasspath |
| 195 | + |
| 196 | + main = "sc.iview.commands.demo.basic.MeshDemo" |
| 197 | + |
| 198 | + // arguments to pass to the application |
| 199 | + // args 'appArg1' |
| 200 | + } |
| 201 | +} |
| 202 | + |
| 203 | +val dokkaJavadocJar by tasks.register<Jar>("dokkaJavadocJar") { |
| 204 | + dependsOn(tasks.dokkaJavadoc) |
| 205 | + from(tasks.dokkaJavadoc.get().outputDirectory.get()) |
| 206 | + archiveClassifier.set("javadoc") |
| 207 | +} |
| 208 | + |
| 209 | +val dokkaHtmlJar by tasks.register<Jar>("dokkaHtmlJar") { |
| 210 | + dependsOn(tasks.dokkaHtml) |
| 211 | + from(tasks.dokkaHtml.get().outputDirectory.get()) |
| 212 | + archiveClassifier.set("html-doc") |
| 213 | +} |
| 214 | + |
| 215 | + |
| 216 | +artifacts { |
| 217 | + archives(dokkaJavadocJar) |
| 218 | + archives(dokkaHtmlJar) |
| 219 | +} |
| 220 | + |
| 221 | +java.withSourcesJar() |
0 commit comments