8000 up · scijava/pom-scijava@ff3d1af · GitHub
[go: up one dir, main page]

Skip to content

Commit ff3d1af

Browse files
elect86ctrueden
authored andcommitted
up
1 parent 4cf7560 commit ff3d1af

11 files changed

+7037
-117
lines changed

gradle/catalog/build.gradle.kts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import groovy.xml.XmlSlurper
2+
import groovy.xml.slurpersupport.GPathResult
3+
import groovy.xml.slurpersupport.NodeChild
4+
5+
plugins {
6+
`version-catalog`
7+
`maven-publish`
8+
}
9+
10+
group = "org.scijava"
11+
version = "0.1"
12+
13+
catalog.versionCatalog {
14+
15+
operator fun GPathResult.div(child: String) = children().find { (it!! as NodeChild).name() == child } as GPathResult
16+
17+
val effXml = XmlSlurper().parse(projectDir.resolve("eff.xml"))
18+
val deps = effXml / "dependencyManagement" / "dependencies"
19+
val bundles = mutableMapOf<String, ArrayList<String>>()
20+
val skip = listOf("mpicbg" to "mpicbg_")
21+
val cache = mutableSetOf<String>() // skip duplicates, such as org.bytedeco:ffmpeg
22+
for (dep in deps.children()) {
23+
val node = dep as NodeChild
24+
val g = node / "groupId"
25+
val a = node / "artifactId"
26+
val v = node / "version"
27+
val gav = "$g:$a:$v"
28+
29+
if (("$g" to "$a") in skip || gav in cache)
30+
continue
31+
32+
cache += gav
33+
34+
// println(gav)
35+
val camel = "$a".split('-', '_')
36+
.joinToString("") { if (it.isEmpty()) "" else it[0].uppercase() + it.substring(1).lowercase() }
37+
.replaceFirstChar { it.lowercase() }
38+
39+
fun getAlias(group: String = "$g".substringAfterLast('.')) =
40+
"$group." + when {
41+
camel.startsWith(group) -> camel.substringAfter(group).replaceFirstChar { it.lowercase() }.ifEmpty { group }
42+
else -> camel
43+
}.also { bundles.getOrPut(group, ::ArrayList) += it }
44+
45+
val alias = when ("$g") {
46+
in listOf("org.scijava", "net.imagej", "net.imglib2", "sc.fiji", "org.janelia.saalfeldlab") -> getAlias()
47+
"io.scif" -> getAlias("scifio")
48+
else -> "$g.$camel"
49+
}
50+
51+
println("$alias($gav)")
52+
library(alias, gav)
53+
}
54+
for ((alias, aliases) in bundles)
55+
bundle(alias, aliases)
56+
}
57+
58+
publishing.publications {
59+
repositories.maven {
60+
name = "sciJava"
61+
credentials(PasswordCredentials::class)
62+
url = uri("https://maven.scijava.org/content/repositories/releases")
63+
}
64+
create<MavenPublication>("sciJavaCatalog") {
65+
from(components["versionCatalog"])
66+
}
67+
}

0 commit comments

Comments
 (0)
0