1
1
plugins {
2
2
embeddedKotlin(" jvm" )
3
+ id(" org.gradlex.java-ecosystem-capabilities-base" )
3
4
}
4
5
5
6
repositories {
@@ -8,221 +9,65 @@ repositories {
8
9
maven(" https://maven.scijava.org/content/groups/public" )
9
10
}
10
11
11
- // configurations.filter { it.isCanBeResolved }.map { println(it) }
12
-
13
- dependencies {
14
- api(libs.imagej.ij)
15
-
16
- // Activate the "ScijavaCapability" rule
17
- // components.all<ScijavaCapability>()
12
+ // it will appear as this was the original downloaded metadata of the dependency
13
+ // @CacheableRule is more verbose but more efficient, because the rule will be applied before the dependency get cached,
14
+ inline fun <reified T : ComponentMetadataRule > ComponentMetadataHandler.withModules (vararg modules : String ) {
15
+ for (module in modules) withModule<T >(module)
18
16
}
19
-
20
- open class ConflictCapability (val group : String ,
21
- val artifact : String = group,
22
- val modules : List <String >,
23
- val reason : String? = null ) {
24
- val ga get() = " $group :$artifact "
17
+ abstract class Rule : ComponentMetadataRule {
18
+ fun ComponentMetadataContext.remove (vararg modules : String ) = details.allVariants { withDependencies { removeIf { it.module.toString() in modules } } }
25
19
}
20
+ dependencies {
21
+ components {
22
+ @CacheableRule open class NoXalan : Rule () {
23
+ override fun execute (context : ComponentMetadataContext ) = context.remove(" xalan:serializer" , " xalan:xalan" )
24
+ }
25
+ withModules<NoXalan >(" org.openmicroscopy:ome-common" , " ome:bio-formats-tools" , " ome:formats-api" , " ome:formats-bsd" ,
26
+ " org.apache.xmlgraphics:batik-bridge" , " org.apache.xmlgraphics:batik-dom" )
26
27
27
- class ResolutionCapability (group : String , artifact : String = group, modules : List <String >, reason : String? = null ) : ConflictCapability(group, artifact, modules, reason)
28
-
29
- // the right module to select will be always the last in the list
30
- val resolutions = listOf (
31
- ResolutionCapability (" jzy3d" , " emul-gl" , listOf (" org.jzy3d:jzy3d-emul-gl" , " org.jzy3d:jzy3d-emul-gl-awt" ), " Replaced by org.jzy3d:jzy3d-emul-gl-awt" ),
32
- ResolutionCapability (" jzy3d" , " jGL" , listOf (" org.jzy3d:jGL" , " jzy3d-jGL-awt" ), " Replaced by org.jzy3d:jzy3d-jGL-awt" ),
33
- ResolutionCapability (" javax" , " transaction" , listOf (" javax.transaction:jta" , " jzy3d-jGL-awt" ), " Replaced by org.jzy3d:jzy3d-jGL-awt" ),
34
- ResolutionCapability (" javax" , " servlet" , listOf (" javax.servlet:servlet-api" , " javax.servlet:javax.servlet-api" )))
35
- val conflicts = listOf (
36
- ConflictCapability (" slf4j" , modules = listOf (" ch.qos.logback:logback-classic" , " org.slf4j:slf4j-simple" )),
37
- ConflictCapability (" jcl" , modules = listOf (" commons-logging:commons-logging" , " org.slf4j:jcl-over-slf4j" )),
38
- ConflictCapability (" jakarta" , " activation" ,
39
- listOf (" jakarta.activation:jakarta.activation-api" , " com.sun.activation:javax.activation" , " javax.activation:activation" ),
40
- " See: https://wiki.eclipse.org/Jakarta_EE_Maven_Coordinates" ),
41
- ConflictCapability (" javax" , " transaction" , listOf (" javax.transaction:javax.transaction-api" , " javax.transaction:jta" )),
42
- ConflictCapability (" apache" , " commonsCsv" , listOf (" org.apache.commons:commons-csv" , " org.apache.solr:solr-commons-csv" )),
43
- ConflictCapability (" c3p0" , modules = listOf (" com.mchange:c3p0" , " com.mchange:mchange-commons-java" , " c3p0:c3p0" )),
44
- ConflictCapability (" javax" , " mail" , listOf (" javax.mail:mail" , " com.sun.mail:javax.mail" )),
45
- ConflictCapability (" jersey" , " core" , listOf (" javax.ws.rs:javax.ws.rs-api" , " com.sun.jersey:jersey-core" )),
46
- ConflictCapability (" commons" , " beanutils" , listOf (" commons-beanutils:commons-beanutils" , " commons-collections:commons-collections" , " commons-beanutils:commons-beanutils-core" )))
47
-
48
- // TODO
49
-
50
- // Uber-JAR of all batik components
51
- // org.apache.xmlgraphics:batik-all
52
-
53
- // Conflicts with junit:junit. We don't need Android here.
54
- // com.google.android.tools:dx
55
-
56
- // Brings in all gluegen-rt native classifiers.
57
- // org.jogamp.gluegen:gluegen-rt-main
58
-
59
- // Brings in all jogl-all native classifiers.
60
- // org.jogamp.jogl:jogl-all-main
61
-
62
- // Uber-JAR of all netty components
63
- // io.netty:netty-all
64
-
65
- /*
66
- <groupId>org.jzy3d</groupId>
67
- <artifactId>jzy3d-native-jogl-awt</artifactId>
68
- <version>${org.jzy3d.jzy3d-native-jogl-awt.version}</version>
69
- <exclusions>
70
- <!-- Conflicts with properly packaged jogamp native classifiers. -->
71
- <exclusion>
72
- <groupId>org.jogamp.gluegen</groupId>
73
- <artifactId>gluegen-rt-natives-macosx-universal</artifactId>
74
- </exclusion>
75
- <exclusion>
76
- <groupId>org.jogamp.gluegen</groupId>
77
- <artifactId>gluegen-rt-natives-linux-aarch64</artifactId>
78
- </exclusion>
79
- <exclusion>
80
- <groupId>org.jogamp.gluegen</groupId>
81
- <artifactId>gluegen-rt-natives-linux-amd64</artifactId>
82
- </exclusion>
83
- <exclusion>
84
- <groupId>org.jogamp.gluegen</groupId>
85
- <artifactId>gluegen-rt-natives-linux-armv6hf</artifactId>
86
- </exclusion>
87
- <exclusion>
88
- <groupId>org.jogamp.gluegen</groupId>
89
- <artifactId>gluegen-rt-natives-linux-i586</artifactId>
90
- </exclusion>
91
- <exclusion>
92
- <groupId>org.jogamp.gluegen</groupId>
93
- <artifactId>gluegen-rt-natives-macosx-universal</artifactId>
94
- </exclusion>
95
- <exclusion>
96
- <groupId>org.jogamp.gluegen</groupId>
97
- <artifactId>gluegen-rt-natives-windows-amd64</artifactId>
98
- </exclusion>
99
- <exclusion>
100
- <groupId>org.jogamp.gluegen</groupId>
101
- <artifactId>gluegen-rt-natives-windows-i586</artifactId>
102
- </exclusion>
103
- <exclusion>
104
- <groupId>org.jogamp.jogl</groupId>
105
- <artifactId>jogl-all-natives-linux-aarch64</artifactId>
106
- </exclusion>
107
- <exclusion>
108
- <groupId>org.jogamp.jogl</groupId>
109
- <artifactId>jogl-all-natives-linux-amd64</artifactId>
110
- </exclusion>
111
- <exclusion>
112
- <groupId>org.jogamp.jogl</groupId>
113
- <artifactId>jogl-all-natives-linux-armv6hf</artifactId>
114
- </exclusion>
115
- <exclusion>
116
- <groupId>org.jogamp.jogl</groupId>
117
- <artifactId>jogl-all-natives-linux-i586</artifactId>
118
- </exclusion>
119
- <exclusion>
120
- <groupId>org.jogamp.jogl</groupId>
121
- <artifactId>jogl-all-natives-macosx-universal</artifactId>
122
- </exclusion>
123
- <exclusion>
124
- <groupId>org.jogamp.jogl</groupId>
125
- <artifactId>jogl-all-natives-windows-amd64</artifactId>
126
- </exclusion>
127
- <exclusion>
128
- <groupId>org.jogamp.jogl</groupId>
129
- <artifactId>jogl-all-natives-windows-i586</artifactId>
130
- </exclusion>
28
+ @CacheableRule open class NoUeberJars : Rule () {
29
+ override fun execute (context : ComponentMetadataContext ) = context.remove(" org.apache.xmlgraphics:batik-all" , " it.unimi.dsi:fastutil" )
30
+ }
31
+ withModules<NoUeberJars >(" org.openmicroscopy:omero-blitz" , " org.openmicroscopy:omero-server" )
131
32
33
+ @CacheableRule open class NoAndroid : Rule () {
34
+ override fun execute (context : ComponentMetadataContext ) = context.remove(" com.google.android.tools:dx" )
35
+ }
36
+ withModules<NoAndroid >(" net.clearcontrol:coremem" , " com.nativelibs4java:bridj" )
132
37
133
- <groupId>org.jzy3d</groupId>
134
- <artifactId>jzy3d-native-jogl-core</artifactId>
135
- <version>${org.jzy3d.jzy3d-native-jogl-core.version}</version>
136
- <exclusions>
137
- <!-- Conflicts with properly packaged jogamp native classifiers. -->
138
- <exclusion>
139
- <groupId>org.jogamp.gluegen</groupId>
140
- <artifactId>gluegen-rt-natives-macosx-universal</artifactId>
141
- </exclusion>
142
- <exclusion>
143
- <groupId>org.jogamp.gluegen</groupId>
144
- <artifactId>gluegen-rt-natives-linux-aarch64</artifactId>
145
- </exclusion>
146
- <exclusion>
147
- <groupId>org.jogamp.gluegen</groupId>
148
- <artifactId>gluegen-rt-natives-linux-amd64</artifactId>
149
- </exclusion>
150
- <exclusion>
151
- <groupId>org.jogamp.gluegen</groupId>
152
- <artifactId>gluegen-rt-natives-linux-armv6hf</artifactId>
153
- </exclusion>
154
- <exclusion>
155
- <groupId>org.jogamp.gluegen</groupId>
156
- <artifactId>gluegen-rt-natives-linux-i586</artifactId>
157
- </exclusion>
158
- <exclusion>
159
- <groupId>org.jogamp.gluegen</groupId>
160
- <artifactId>gluegen-rt-natives-macosx-universal</artifactId>
161
- </exclusion>
162
- <exclusion>
163
- <groupId>org.jogamp.gluegen</groupId>
164
- <artifactId>gluegen-rt-natives-windows-amd64</artifactId>
165
- </exclusion>
166
- <exclusion>
167
- <groupId>org.jogamp.gluegen</groupId>
168
- <artifactId>gluegen-rt-natives-windows-i586</artifactId>
169
- </exclusion>
170
- <exclusion>
171
- <groupId>org.jogamp.jogl</groupId>
172
- <artifactId>jogl-all-natives-linux-aarch64</artifactId>
173
- </exclusion>
174
- <exclusion>
175
- <groupId>org.jogamp.jogl</groupId>
176
- <artifactId>jogl-all-natives-linux-amd64</artifactId>
177
- </exclusion>
178
- <exclusion>
179
- <groupId>org.jogamp.jogl</groupId>
180
- <artifactId>jogl-all-natives-linux-armv6hf</artifactId>
181
- </exclusion>
182
- <exclusion>
183
- <groupId>org.jogamp.jogl</groupId>
184
- <artifactId>jogl-all-natives-linux-i586</artifactId>
185
- </exclusion>
186
- <exclusion>
187
- <groupId>org.jogamp.jogl</groupId>
188
- <artifactId>jogl-all-natives-macosx-universal</artifactId>
189
- </exclusion>
190
- <exclusion>
191
- <groupId>org.jogamp.jogl</groupId>
192
- <artifactId>jogl-all-natives-windows-amd64</artifactId>
193
- </exclusion>
194
- <exclusion>
195
- <groupId>org.jogamp.jogl</groupId>
196
- <artifactId>jogl-all-natives-windows-i586</artifactId>
197
- </exclusion>
198
- */
38
+ @CacheableRule open class ClearGl : Rule () {
39
+ override fun execute (context : ComponentMetadataContext ) = context.remove(" org.jogamp.gluegen:gluegen-rt-main" , " org.jogamp.jogl:jogl-all-main" )
40
+ }
41
+ withModule<ClearGl >(" net.clearvolume:cleargl" )
199
42
200
- class ScijavaCapability : ComponentMetadataRule {
201
- override
202
- fun execute (context : ComponentMetadataContext ) = context.details.run {
203
- for (res in resolutions + conflicts) {
204
- if (id.module.toString() in res.modules)
205
- allVariants {
206
- withCapabilities {
207
- // Declare that all of them provide the same capability
208
- addCapability(res.group, res.artifact, id.version)
209
- }
210
- }
43
+ @CacheableRule open class SparkCore211 : Rule () {
44
+ override fun execute (context : ComponentMetadataContext ) = context.remove(" io.netty:netty-all" )
211
45
}
212
- }
213
- }
46
+ withModule<SparkCore211 >(" org.apache.spark:spark-core_2.11" )
214
47
215
- configurations.all {
216
- // dependencies.forEach { it. }
217
- resolutionStrategy.capabilitiesResolution {
218
- for (res in resolutions)
219
- withCapability(res.ga) {
220
- for (cand in candidates) {
221
- val id = cand.id
222
- if (id is ModuleComponentIdentifier && id.moduleIdentifier.toString() == res.modules.last())
223
- select(cand)
224
- }
225
- res.reason?.let (::because)
48
+ @CacheableRule open class NoBatikExtensions : Rule () {
49
+ override fun execute (context : ComponentMetadataContext ) = context.remove(" org.apache.xmlgraphics:batik-extensions" )
50
+ }
51
+ withModules<NoBatikExtensions >(" org.apache.xmlgraphics:batik-rasterizer-ext" , " org.apache.xmlgraphics:batik-squiggle-ext" )
52
+
53
+ @CacheableRule open class NoJogampNatives : Rule () {
54
+ override fun execute (context : ComponentMetadataContext ) {
55
+ // Conflicts with properly packaged jogamp native classifiers.
56
+ val libs = listOf (" gluegen:gluegen-rt" , " jogl:jogl-all" )
57
+ val modules = listOf (" linux-aarch64" , " linux-amd64" , " linux-armv6hf" , " linux-i586" , " macosx-universal" , " windows-amd64" , " windows-i586" )
58
+ .flatMap { p -> libs.map { " org.jogamp.$it -natives-$p " } }.toTypedArray()
59
+ context.remove(* modules)
226
60
}
61
+ }
62
+ withModules<NoJogampNatives >(" org.jzy3d:jzy3d-native-jogl-awt" , " org.jzy3d:jzy3d-native-jogl-core" )
63
+
64
+ @CacheableRule open class Weka : Rule () {
65
+ override fun execute (context : ComponentMetadataContext ) = context.remove(
66
+ " com.github.fommil.netlib:all" , " com.googlecode.netlib-java:netlib-java" , " net.sourceforge.f2j:arpack_combined_all" ,
67
+ " nz.ac.waikato.cms.weka.thirdparty:java-cup-11b" , " nz.ac.waikato.cms.weka.thirdparty:java-cup-11b-runtime" )
68
+ }
69
+ withModule<Weka >(" nz.ac.waikato.cms.weka:weka-dev" )
227
70
}
71
+ implementation(libs.org.morphonets.snt)
72
+ implementation(" org.jzy3d:jzy3d-emul-gl-awt:2.1.0" )
228
73
}
0 commit comments