Skip to content

Commit f7ff2f7

Browse files
elect86ctrueden
authored andcommitted
cleaned
1 parent 2f3b0b2 commit f7ff2f7

File tree

101 files changed

+233
-9789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+233
-9789
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.project
22
/.settings/
33
/target/
4+
/gradle-scijava/.gradle

.idea/compiler.xml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 2 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradle-scijava/build.gradle.kts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import groovy.xml.XmlSlurper
2+
import groovy.xml.slurpersupport.GPathResult
3+
import groovy.xml.slurpersupport.NodeChild
4+
import java.io.ByteArrayOutputStream
5+
6+
plugins {
7+
`java-platform`
8+
`version-catalog`
9+
`maven-publish`
10+
// id("org.gradlex.java-ecosystem-capabilities-base") // only rules
11+
// id("org.gradlex.logging-capabilities") // logging extension
12+
}
13+
14+
layout.buildDirectory.set(layout.projectDirectory.asFile.parentFile.resolve("target/gradle"))
15+
16+
group = "org.scijava"
17+
version = "0.13" //(effXml / "version").toString()
18+
19+
//operator fun GPathResult.div(child: String) = children().find { (it!! as NodeChild).name() == child } as GPathResult
20+
21+
//val effXml = XmlSlurper().parse(projectDir.resolve("eff.xml"))
22+
23+
javaPlatform {
24+
allowDependencies()
25+
}
26+
val computeCatalogAndPlatform = tasks.register<Exec>("generateCatalog") {
27+
28+
workingDir = projectDir.parentFile
29+
commandLine("sh", "-c", "mvn -B -f pom.xml help:effective-pom")
30+
standardOutput = ByteArrayOutputStream()
31+
32+
doLast {
33+
var output = standardOutput.toString()
34+
// clean output from dirty
35+
output = output.substringAfter("\n\n").substringBefore("\n\n")
36+
37+
operator fun GPathResult.div(child: String) = children().find { (it!! as NodeChild).name() == child } as GPathResult
38+
39+
val xml = XmlSlurper().parseText(output)
40+
val deps = xml / "dependencyManagement" / "dependencies"
41+
val bundles = mutableMapOf<String, ArrayList<String>>()
42+
val skip = listOf("mpicbg" to "mpicbg_")
43+
val cache = mutableSetOf<String>() // skip duplicates, such as org.bytedeco:ffmpeg
44+
for (dep in deps.children()) {
45+
val node = dep as NodeChild
46+
val g = node / "groupId"
47+
val a = node / "artifactId"
48+
val v = node / "version"
49+
val gav = "$g:$a:$v"
50+
51+
if (("$g" to "$a") in skip || gav in cache)
52+
continue
53+
54+
cache += gav
55+
56+
val camel = "$a".split('-', '_')
57+
.joinToString("") { if (it.isEmpty()) "" else it[0].uppercase() + it.substring(1).lowercase() }
58+
.replaceFirstChar { it.lowercase() }
59+
60+
fun getAlias(group: String): String {
61+
val alias = "$group." + when {
62+
camel.startsWith(group) -> camel.substringAfter(group).replaceFirstChar { it.lowercase() }.ifEmpty { group }
63+
else -> camel
64+
}
65+
bundles.getOrPut(group, ::ArrayList) += alias
66+
return alias
67+
}
68+
69+
val lastWordAsGroup = listOf("org.scijava", "net.imagej", "net.imglib2", "sc.fiji", "org.janelia.saalfeldlab")
70+
val alias = when ("$g") {
71+
in lastWordAsGroup -> getAlias(g.toString().substringAfterLast('.'))
72+
"io.scif" -> getAlias("scifio")
73+
else -> "$g.$camel"
74+
}
75+
76+
catalog.versionCatalog { library(alias, gav) }
77+
78+
dependencies {
79+
constraints {
80+
val ga = "$g:$a"
81+
if (ga in runtimeDeps || jogampNatives.any { it.startsWith(ga) })
82+
runtime(gav) //.also { println("runtime($dep)") }
83+
else
84+
api(gav) //.also{ println("api($dep)") }
85+
}
86+
}
87+
}
88+
89+
for ((alias, aliases) in bundles)
90+
catalog.versionCatalog { bundle(alias, aliases) }
91+
}
92+
}
93+
94+
publishing {
95+
publications {
96+
repositories {
97+
maven {
98+
name = "sciJava"
99+
// credentials(PasswordCredentials::class)
100+
// url = uri("https://maven.scijava.org/content/repositories/releases")
101+
url = uri("repo")
102+
}
103+
}
104+
create<MavenPublication>("pomScijava") {
105+
from(components["javaPlatform"])
106+
}
107+
}
108+
}
109+
110+
tasks {
111+
// dependsOn runs only if the src is successful, finalizedBy not
112+
generateCatalogAsToml { dependsOn(computeCatalogAndPlatform) }
113+
val generateMetadataFileForPomScijavaPublication by getting { dependsOn(computeCatalogAndPlatform) }
114+
register("generateCatalogAndPlatform") { dependsOn(generateMetadataFileForPomScijavaPublication, generateCatalogAsToml) }
115+
}
116+
117+
val runtimeDeps = listOf("org.antlr:antlr-runtime",
118+
"xalan:serializer",
119+
"xalan:xalan",
120+
"com.github.vbmacher:java-cup-runtime",
121+
"nz.ac.waikato.cms.weka.thirdparty:java-cup-11b-runtime",
122+
"org.jogamp.gluegen:gluegen-rt-main",
123+
"org.jogamp.gluegen:gluegen-rt",
124+
"org.jogamp.joal:joal",
125+
"org.jogamp.jocl:jocl",
126+
"org.jogamp.jogl:jogl-all-main",
127+
"org.jogamp.jogl:jogl-all",
128+
"org.jogamp.jogl:jogl-all-noawt",
129+
"com.nativelibs4java:bridj",
130+
"org.bytedeco:ffmpeg",
131+
"org.bytedeco:hdf5",
132+
"org.bytedeco:leptonica",
133+
"org.bytedeco:openblas",
134+
"org.bytedeco:opencv",
135+
"org.bytedeco:tesseract",
136+
"org.jline:jline-native",
137+
"com.github.jnr:jffi",
138+
"org.jzy3d:jzy3d-native-jogl-awt",
139+
"org.jzy3d:jzy3d-native-jogl-swing")
140+
141+
val jogampNatives = listOf("org.jogamp.gluegen:gluegen-rt-natives-",
142+
"org.jogamp.jogl:jogl-all-natives-",
143+
"org.jogamp.gluegen:gluegen-rt-natives-",
144+
"org.jogamp.jogl:jogl-all-natives-")
File renamed without changes.
File renamed without changes.
File renamed without changes.

gradle-scijava/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "pom-scijava"

gradle/.gitattributes

Lines changed: 0 additions & 6 deletions
This file was deleted.

gradle/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)