Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pom generation in gradle #417

Merged
merged 37 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1912789
WIP: use pom-scijava as implementation platform
ctrueden Sep 17, 2021
ead11a1
Initialize with more required services
Oct 7, 2021
2587078
Add method to check the available services in this sciview instance
Oct 7, 2021
ee0d3f9
Inc scijava pom and add conditions for versions
Oct 13, 2021
db6621f
Merge remote-tracking branch 'origin/scijava-bom' into pyimagej-compa…
Oct 13, 2021
5c5f9b6
Specify scijava-common version for kapt processing
Oct 13, 2021
32bb002
wip: update to match scenery branch scijava-compatible-pom
Oct 15, 2021
4025b0c
Update scenery version for Debo's changes
Oct 16, 2021
f8d5ec9
Add extra fixes for pom generation
Oct 19, 2021
a000eb6
fixed kapt
elect86 Oct 19, 2021
e2bc8a6
Fix jackson versions
Oct 19, 2021
3bded27
Update scenery version for spirvcrossj native specification in pom
Oct 19, 2021
359e24e
Bump scenery version for pom native dep fix
Oct 20, 2021
a4ba8c4
Bump to scenery with natives fix in pom
Oct 20, 2021
6c2f4ce
Try adding scenery's runtime deps in sciview pom
Oct 20, 2021
c7de3d5
Update for scenery with jinput native in pom
Oct 22, 2021
bf95b5d
Update for scenery with lwjgl-vulkan natives for macos
Oct 22, 2021
3d3cf75
Depend on scenery with scijava-compatibility branch merged
Oct 22, 2021
79d618d
Initialize with more required services
Oct 7, 2021
a8f9532
Add method to check the available services in this sciview instance
Oct 7, 2021
b7947be
Inc scijava pom and add conditions for versions
Oct 13, 2021
675795c
WIP: use pom-scijava as implementation platform
ctrueden Sep 17, 2021
78f311a
Specify scijava-common version for kapt processing
Oct 13, 2021
57fb5d1
wip: update to match scenery branch scijava-compatible-pom
Oct 15, 2021
cb705d2
Update scenery version for Debo's changes
Oct 16, 2021
3b3b9dc
Add extra fixes for pom generation
Oct 19, 2021
a8a9b06
fixed kapt
elect86 Oct 19, 2021
472fe31
Fix jackson versions
Oct 19, 2021
c2d40e5
Update scenery version for spirvcrossj native specification in pom
Oct 19, 2021
abf66a3
Bump scenery version for pom native dep fix
Oct 20, 2021
151ee92
Bump to scenery with natives fix in pom
Oct 20, 2021
6032dde
Try adding scenery's runtime deps in sciview pom
Oct 20, 2021
3c1a466
Update for scenery with jinput native in pom
Oct 22, 2021
b48f5bf
Update for scenery with lwjgl-vulkan natives for macos
Oct 22, 2021
83a1693
Depend on scenery with scijava-compatibility branch merged
Oct 22, 2021
7e69e1b
Merge branch 'pyimagej-compatibility' of github.com:scenerygraphics/s…
Oct 22, 2021
317d357
Merge branch 'master' into pyimagej-compatibility
kephale Oct 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 186 additions & 83 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import sciview.joglNatives
import java.net.URL
import sciview.*

//System.setProperty("scijava.platform.family.long", "linux")

plugins {
val ktVersion = "1.5.10"
val dokkaVersion = "1.4.32"
Expand All @@ -16,7 +18,6 @@ plugins {
sciview.sign
id("org.jetbrains.dokka") version dokkaVersion
jacoco
id("sciJava.platform") version "30.0.0+15"
`maven-publish`
`java-library`
signing
Expand All @@ -25,25 +26,54 @@ plugins {
repositories {
mavenCentral()
maven("https://maven.scijava.org/content/groups/public")
maven("https://raw.githubusercontent.com/kotlin-graphics/mary/master")
maven("https://jitpack.io")
}

dependencies {

implementation(platform("org.scijava:pom-scijava:31.1.0"))

// Graphics dependencies

annotationProcessor(sciJava.common)
kapt(sciJava.common)
annotationProcessor("org.scijava:scijava-common:2.87.0")
kapt("org.scijava:scijava-common:2.87.0") { // MANUAL version increment
exclude("org.lwjgl")
}

val sceneryVersion = "1f1f9c2"
api("graphics.scenery:scenery:$sceneryVersion")
val sceneryVersion = "4d07a30"
api("graphics.scenery:scenery:$sceneryVersion") { version { strictly(sceneryVersion) } }
api("graphics.scenery:spirvcrossj:0.8.0-1.1.106.0", lwjglNatives)
// check if build is triggered on https://jitpack.io/#scenerygraphics/sciview `build` tab
// if not, uncomment this only to trigger it
// api("com.github.scenerygraphics:scenery:$scenery")
// api("com.github.scenerygraphics:scenery:$scenery")

// This seams to be still necessary
implementation(platform("org.lwjgl:lwjgl-bom:3.2.3"))
listOf("", "-glfw", "-jemalloc", "-vulkan", "-opengl", "-openvr", "-xxhash", "-remotery").forEach { lwjglProject ->
api("org.lwjgl:lwjgl$lwjglProject:3.2.3")

if (lwjglProject != "-vulkan") {
lwjglNatives.forEach { native ->
runtimeOnly("org.lwjgl:lwjgl$lwjglProject:3.2.3:$native")
}
}
}
// listOf("", "-glfw", "-jemalloc", "-vulkan", "-opengl", "-openvr", "-xxhash", "-remotery").forEach { lwjglProject ->
// if (lwjglProject == "-vulkan")
// api("org.lwjgl:lwjgl$lwjglProject:3.2.3")
// else {
// lwjglNatives.forEach { native ->
// //api("org.lwjgl:lwjgl$lwjglProject:3.2.3-$native")
// api("org.lwjgl", "lwjgl$lwjglProject", "3.2.3", null, null, "$native.jar", null)
// }
// }
// }
//implementation(jackson.bundles.all)

implementation("com.fasterxml.jackson.core:jackson-databind:2.12.5")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.5")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.5")
implementation("org.msgpack:jackson-dataformat-msgpack:0.8.20")

implementation(misc.cleargl)
implementation(misc.coreMem)
Expand All @@ -53,35 +83,30 @@ dependencies {

// SciJava dependencies

implementation(sciJava.common)
implementation(sciJava.uiBehaviour)
implementation(sciJava.scriptEditor)
implementation(sciJava.uiSwing)
implementation(sciJava.uiAwt)
implementation(sciJava.search)
implementation(sciJava.scriptingJython)
implementation("org.scijava:scijava-common")
implementation("org.scijava:ui-behaviour")
implementation("org.scijava:script-editor")
implementation("org.scijava:scijava-ui-swing")
implementation("org.scijava:scijava-ui-awt")
implementation("org.scijava:scijava-search")
implementation("org.scijava:scripting-jython")
implementation(migLayout.swing)

// ImageJ dependencies

implementation(imagej.core)
// sciJava("net.imagej") {
// exclude("org.scijava", "scripting-renjin")
// exclude("org.scijava", "scripting-jruby")
// }
implementation(imagej.common)
implementation(imagej.mesh) { version { strictly("0.8.1") } } // FIXME
implementation(imagej.meshIo)
implementation(imagej.ops)
implementation(imagej.launcher)
implementation(imagej.uiSwing)
implementation(imagej.legacy)
implementation(scifio.core)
implementation(scifio.bfCompat)
implementation("net.imagej:imagej-common")
implementation("net.imagej:imagej-mesh:0.8.1")
implementation("net.imagej:imagej-mesh-io")
implementation("net.imagej:imagej-ops")
implementation("net.imagej:imagej-launcher")
implementation("net.imagej:imagej-ui-swing")
implementation("net.imagej:imagej-legacy")
implementation("io.scif:scifio")
implementation("io.scif:scifio-bf-compat")

// ImgLib2 dependencies
implementation(imgLib2.core)
implementation(imgLib2.roi)
implementation("net.imglib2:imglib2")
implementation("net.imglib2:imglib2-roi")

// Math dependencies
implementation(commons.math3)
Expand All @@ -95,41 +120,37 @@ dependencies {
// Test scope

testImplementation(misc.junit4)
implementation(imagej.ij)
implementation(imgLib2.ij)
implementation("net.imagej:ij")
implementation("net.imglib2:imglib2-ij")

implementation(n5.core)
implementation(n5.hdf5)
implementation(n5.imglib2)
// implementation("org.janelia.saalfeldlab:n5-aws-s3")
// implementation("org.janelia.saalfeldlab:n5-ij:2.0.1-SNAPSHOT")
implementation(bigDataViewer.spimData)
// implementation("org.janelia.saalfeldlab:n5-aws-s3")
// implementation("org.janelia.saalfeldlab:n5-ij:2.0.1-SNAPSHOT")
implementation("sc.fiji:spim_data")

implementation(platform(kotlin("bom")))
implementation(kotlin("stdlib-jdk8"))
testImplementation(kotlin("test-junit"))

implementation(bigDataViewer.core)
implementation(bigDataViewer.visTools)
implementation("sc.fiji:bigdataviewer-core")
implementation("sc.fiji:bigdataviewer-vistools")

// OME

// https://mvnrepository.com/artifact/ome/formats-bsd
implementation("ome:formats-bsd:6.6.1")
// https://mvnrepository.com/artifact/ome/formats-gpl
implementation("ome:formats-gpl:6.6.1")

implementation("ome:formats-bsd")
implementation("ome:formats-gpl")


}

kapt {
useBuildCache = false // safe
arguments {
arg("-Werror")
arg("-Xopt-in", "kotlin.RequiresOptIn")
}
}
//kapt {
// useBuildCache = false // safe
// arguments {
// arg("-Werror")
// arg("-Xopt-in", "kotlin.RequiresOptIn")
// }
//}

tasks {
withType<KotlinCompile>().all {
Expand Down Expand Up @@ -159,56 +180,138 @@ tasks {
var parent = asNode().appendNode("parent")
parent.appendNode("groupId", "org.scijava")
parent.appendNode("artifactId", "pom-scijava")
parent.appendNode("version", "30.0.0")
parent.appendNode("version", "31.1.0")
parent.appendNode("relativePath")

var repositories = asNode().appendNode("repositories")
var jitpackRepo = repositories.appendNode("repository")
jitpackRepo.appendNode("id", "jitpack.io")
jitpackRepo.appendNode("url", "https://jitpack.io")

var scijavaRepo = repositories.appendNode("repository")
scijavaRepo.appendNode("id", "scijava.public")
scijavaRepo.appendNode("url", "https://maven.scijava.org/content/groups/public")

// Update the dependencies and properties
var dependenciesNode = asNode().appendNode("dependencies")
var propertiesNode = asNode().appendNode("properties")
propertiesNode.appendNode("inceptionYear", 2016)

configurations.implementation.allDependencies.forEach {
var artifactId = it.name
// spirvcrossj natives
lwjglNatives.forEach {
var dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", "graphics.scenery")
dependencyNode.appendNode("artifactId", "spirvcrossj")
dependencyNode.appendNode("version", "\${spirvcrossj.version}")
dependencyNode.appendNode("classifier", "$it")
dependencyNode.appendNode("scope", "runtime")
}

var propertyName = "$artifactId.version"
propertiesNode.appendNode(propertyName, it.version)
// lwjgl natives
lwjglNatives.forEach { nativePlatform ->
listOf(
"",
"-glfw",
"-jemalloc",
"-opengl",
"-openvr",
"-xxhash",
"-remotery"
).forEach { lwjglProject ->
var dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", "org.lwjgl")
dependencyNode.appendNode("artifactId", "lwjgl$lwjglProject")
dependencyNode.appendNode("version", "\${lwjgl.version}")
dependencyNode.appendNode("classifier", "$nativePlatform")
dependencyNode.appendNode("scope", "runtime")
}
}

// jvrpn natives
lwjglNatives.forEach {
var dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", artifactId)
dependencyNode.appendNode("version", "\${$propertyName}")

// Custom per artifact tweaks
println(artifactId)
if("\\-bom".toRegex().find(artifactId) != null) {
dependencyNode.appendNode("type", "pom")
}
// from https://github.com/scenerygraphics/sciview/pull/399#issuecomment-904732945
if(artifactId == "formats-gpl") {
var exclusions = dependencyNode.appendNode("exclusions")
var jacksonCore = exclusions.appendNode("exclusion")
jacksonCore.appendNode("groupId", "com.fasterxml.jackson.core")
jacksonCore.appendNode("artifactId", "jackson-core")
var jacksonAnnotations = exclusions.appendNode("exclusion")
jacksonAnnotations.appendNode("groupId", "com.fasterxml.jackson.core")
jacksonAnnotations.appendNode("artifactId", "jackson-annotations")
dependencyNode.appendNode("groupId", "graphics.scenery")
dependencyNode.appendNode("artifactId", "jvrpn")
dependencyNode.appendNode("version", "\${jvrpn.version}")
dependencyNode.appendNode("classifier", "$it")
dependencyNode.appendNode("scope", "runtime")
}
// add jvrpn property because it only has runtime native deps
propertiesNode.appendNode("jvrpn.version", "1.2.0")

val versionedArtifacts = listOf("scenery",
"flatlaf",
"kotlin-stdlib-common",
"kotlin-stdlib",
"kotlinx-coroutines-core",
"spirvcrossj",
"pom-scijava",
"lwjgl-bom",
"jackson-module-kotlin",
"jackson-dataformat-yaml",
"jackson-dataformat-msgpack",
"jogl-all",
"kotlin-bom",
"lwjgl",
"lwjgl-glfw",
"lwjgl-jemalloc",
"lwjgl-vulkan",
"lwjgl-opengl",
"lwjgl-openvr",
"lwjgl-xxhash",
"lwjgl-remotery")

val toSkip = listOf("pom-scijava")

configurations.implementation.allDependencies.forEach {
var artifactId = it.name

if (!toSkip.contains(artifactId)) {

var propertyName = "$artifactId.version"

if (versionedArtifacts.contains(artifactId)) {
// add "<artifactid.version>[version]</artifactid.version>" to pom
propertiesNode.appendNode(propertyName, it.version)
}

var dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", artifactId)
dependencyNode.appendNode("version", "\${$propertyName}")

// Custom per artifact tweaks
println(artifactId)
if ("\\-bom".toRegex().find(artifactId) != null) {
dependencyNode.appendNode("type", "pom")
}
// from https://github.com/scenerygraphics/sciview/pull/399#issuecomment-904732945
if (artifactId == "formats-gpl") {
var exclusions = dependencyNode.appendNode("exclusions")
var jacksonCore = exclusions.appendNode("exclusion")
jacksonCore.appendNode("groupId", "com.fasterxml.jackson.core")
jacksonCore.appendNode("artifactId", "jackson-core")
var jacksonAnnotations = exclusions.appendNode("exclusion")
jacksonAnnotations.appendNode("groupId", "com.fasterxml.jackson.core")
jacksonAnnotations.appendNode("artifactId", "jackson-annotations")
}
//dependencyNode.appendNode("scope", it.scope)
}
//dependencyNode.appendNode("scope", it.scope)
}

var depStartIdx = "<dependencyManagement>".toRegex().find(asString())?.range?.start
var depEndIdx = "</dependencyManagement>".toRegex().find(asString())?.range?.last
if (depStartIdx != null) {
if (depEndIdx != null) {
asString().replace(depStartIdx, depEndIdx+1, "")
asString().replace(depStartIdx, depEndIdx + 1, "")
}
}

depStartIdx = "<dependencies>".toRegex().find(asString())?.range?.start
depEndIdx = "</dependencies>".toRegex().find(asString())?.range?.last
if (depStartIdx != null) {
if (depEndIdx != null) {
asString().replace(depStartIdx, depEndIdx+1, "")
asString().replace(depStartIdx, depEndIdx + 1, "")
}
}
}
Expand Down Expand Up @@ -271,7 +374,7 @@ tasks {
.filter { it.path.contains("demo") && (it.name.endsWith(".kt") || it.name.endsWith(".java")) }
.map {
val p = it.path
if(p.endsWith(".kt")) {
if (p.endsWith(".kt")) {
p.substringAfter("kotlin${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".kt")
} else {
p.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".java")
Expand Down Expand Up @@ -306,11 +409,11 @@ tasks {
classpath = sourceSets.test.get().runtimeClasspath

println("Target is $target")
// if(target.endsWith(".kt")) {
// main = target.substringAfter("kotlin${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".kt")
// } else {
// main = target.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".java")
// }
// if(target.endsWith(".kt")) {
// main = target.substringAfter("kotlin${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".kt")
// } else {
// main = target.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".java")
// }

main = "$target"
val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("scenery.") }
Expand All @@ -324,7 +427,7 @@ tasks {

println("Will run target $target with classpath $classpath, main=$main")
println("JVM arguments passed to target: $allJvmArgs")
}
}
}
}
}
Expand Down
Loading