Skip to content

Commit da2aa3d

Browse files
committed
Test pom generation and update optional deps
Gradle-generated poms thoroughly tested against 3.1.1 versions, with an eye toward making as many spring-* dependencies optional as possible. All spring-* modules now declare a Gradle dependency on any other spring-* module where there is a direct compile-time usage of the sources in that module. Previously, dependency declarations were minimal, letting transitive resolution do most of the work. However, this creates less than ideal poms and is generally not very informative. So for example, spring-jdbc uses spring-core, spring-beans and spring-tx classes directly. Therefore it has the following declarations: compile project(":spring-core") compile project(":spring-beans") compile project(":spring-tx") spring-core depends on spring-asm, but spring-jdbc does not use spring-asm classes directly. Therefore spring-jdbc does not declare a dependency on spring-asm. Transitive resolution is fine in such a case. As for optional dependencies, it is a matter of degrees what constitutes optional. A rule of thumb is whether there are legitimate and likely use cases in which the module can be used without needing the dependency. spring-jdbc has only one compile-time dependency on spring-context classes, and that's in JndiDataSourceLookup. It is certainly reasonable to imagine using spring-jdbc without JNDI, therefore the spring-context dependency is declared optional as follows: compile(project(":spring-context"), optional) // for JndiDataSourceLookup
1 parent b5b4615 commit da2aa3d

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

build.gradle

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ project('spring-beans') {
163163
project('spring-aop') {
164164
description = 'Spring AOP'
165165
dependencies {
166+
compile project(":spring-core")
166167
compile project(":spring-beans")
167168
compile("com.jamonapi:jamon:2.4", optional)
168169
compile("aopalliance:aopalliance:1.0", optional)
@@ -194,9 +195,11 @@ project('spring-instrument-tomcat') {
194195
project('spring-context') {
195196
description = 'Spring Context'
196197
dependencies {
198+
compile(project(":spring-instrument"), optional)
197199
compile project(":spring-aop")
200+
compile project(":spring-beans")
198201
compile project(":spring-expression")
199-
compile project(":spring-instrument")
202+
compile project(":spring-core")
200203
compile("backport-util-concurrent:backport-util-concurrent:3.0", optional)
201204
compile("javax.annotation:jsr250-api:1.0", optional)
202205
compile("javax.ejb:ejb-api:3.0", optional)
@@ -234,10 +237,14 @@ project('spring-context') {
234237
project('spring-tx') {
235238
description = 'Spring Transaction'
236239
dependencies {
237-
compile project(":spring-context")
240+
compile(project(":spring-context"), optional) // for JCA, @EnableTransactionManagement
241+
compile(project(":spring-aop"), optional)
242+
compile project(":spring-beans")
243+
compile project(":spring-core")
238244
compile("com.ibm.websphere:uow:6.0.2.17", provided)
239245
compile("javax.resource:connector-api:1.5", optional)
240246
compile "aopalliance:aopalliance:1.0" // NOT optional, as opposed to in :spring-aop
247+
compile("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1", optional)
241248
testCompile "org.easymock:easymockclassextension:2.3"
242249
}
243250
}
@@ -246,7 +253,9 @@ project('spring-oxm') {
246253
description = 'Spring Object/XML Marshalling'
247254
apply from: 'oxm.gradle'
248255
dependencies {
249-
compile project(":spring-context")
256+
compile project(":spring-beans")
257+
compile project(":spring-core")
258+
compile(project(":spring-context"), optional) // for Jaxb2Marshaller
250259
compile "commons-lang:commons-lang:2.5"
251260
compile("com.thoughtworks.xstream:xstream:1.3.1", optional)
252261
compile("com.sun.xml.bind:jaxb-impl:2.1.7", optional)
@@ -265,28 +274,40 @@ project('spring-oxm') {
265274
project('spring-jms') {
266275
description = 'Spring JMS'
267276
dependencies {
268-
compile project(":spring-oxm")
277+
compile project(":spring-core")
278+
compile project(":spring-beans")
279+
compile project(":spring-aop")
280+
compile project(":spring-context")
269281
compile project(":spring-tx")
282+
compile(project(":spring-oxm"), optional)
270283
compile("org.codehaus.jackson:jackson-mapper-asl:1.4.2", optional)
271284
}
272285
}
273286

274287
project('spring-jdbc') {
275288
description = 'Spring JDBC'
276289
dependencies {
290+
compile project(":spring-core")
291+
compile project(":spring-beans")
292+
compile(project(":spring-context"), optional) // for JndiDataSourceLookup
277293
compile project(":spring-tx")
278294
compile("c3p0:c3p0:0.9.1.2", optional)
279295
compile("hsqldb:hsqldb:1.8.0.7", optional)
280296
compile("com.h2database:h2:1.0.71", optional)
281297
compile("org.apache.derby:derby:10.5.3.0_1", optional)
282298
compile("org.apache.derby:derbyclient:10.5.3.0_1", optional)
299+
compile("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1", optional)
283300
}
284301
}
285302

286303
project('spring-context-support') {
287304
description = 'Spring Context Support'
288305
dependencies {
289-
compile project(":spring-jdbc")
306+
compile project(":spring-core")
307+
compile project(":spring-beans")
308+
compile project(":spring-context")
309+
compile(project(":spring-jdbc"), optional) // for Quartz support
310+
compile(project(":spring-tx"), optional) // for Quartz support
290311
compile("org.codehaus.fabric3.api:commonj:1.1.0", optional)
291312
compile("opensymphony:quartz:1.6.2", optional)
292313
compile("javax.mail:mail:1.4", optional)
@@ -313,7 +334,11 @@ project('spring-context-support') {
313334
project('spring-web') {
314335
description = 'Spring Web'
315336
dependencies {
316-
compile project(":spring-oxm")
337+
compile project(":spring-core")
338+
compile project(":spring-beans") // for MultiPartFilter
339+
compile project(":spring-aop") // for JaxWsPortProxyFactoryBean
340+
compile project(":spring-context")
341+
compile(project(":spring-oxm"), optional) // for MarshallingHttpMessageConverter
317342
compile("com.caucho:hessian:3.2.1", optional)
318343
compile("rome:rome:1.0", optional)
319344
compile("javax.el:el-api:1.0", optional)
@@ -365,16 +390,25 @@ project('spring-orm') {
365390
compile(project(":spring-web")) {
366391
exclude group: 'javax.persistence', module: 'persistence-api'
367392
}
393+
compile project(":spring-core")
394+
compile project(":spring-beans")
395+
compile(project(":spring-aop"), optional)
396+
compile(project(":spring-context"), optional)
397+
compile project(":spring-tx")
368398
compile project(":spring-jdbc")
369399
}
370400
}
371401

372402
project('spring-webmvc') {
373403
description = 'Spring Web MVC'
374404
dependencies {
405+
compile project(":spring-core")
406+
compile project(":spring-expression")
407+
compile project(":spring-beans")
375408
compile project(":spring-web")
376-
compile project(":spring-orm")
377-
compile project(":spring-context-support")
409+
compile project(":spring-context")
410+
compile(project(":spring-context-support"), optional) // for Velocity support
411+
compile(project(":spring-oxm"), optional) // for MarshallingView
378412
compile("org.apache.tiles:tiles-api:2.1.2", optional)
379413
compile("org.apache.tiles:tiles-core:2.1.2", optional)
380414
compile("org.apache.tiles:tiles-jsp:2.1.2", optional)
@@ -390,6 +424,7 @@ project('spring-webmvc') {
390424
}
391425
compile("javax.servlet:jstl:1.1.2", provided)
392426
compile("org.apache.tomcat:tomcat-servlet-api:7.0.8", provided) // servlet-api 3.0
427+
testCompile project(":spring-aop")
393428
testCompile("org.slf4j:slf4j-log4j12:1.6.1") {
394429
exclude group: 'log4j', module: 'log4j'
395430
}
@@ -413,6 +448,10 @@ project('spring-webmvc-portlet') {
413448
description = 'Spring Web Portlet'
414449
dependencies {
415450
compile("javax.servlet:servlet-api:2.5", provided)
451+
compile project(":spring-core")
452+
compile project(":spring-beans")
453+
compile project(":spring-context")
454+
compile project(":spring-web")
416455
compile project(":spring-webmvc")
417456
}
418457

@@ -424,6 +463,12 @@ project('spring-test') {
424463
description = 'Spring TestContext Framework'
425464
dependencies {
426465
compile project(":spring-core")
466+
compile(project(":spring-beans"), optional)
467+
compile(project(":spring-context"), optional)
468+
compile(project(":spring-jdbc"), optional)
469+
compile(project(":spring-tx"), optional)
470+
compile(project(":spring-orm"), optional)
471+
compile(project(":spring-web"), optional)
427472
compile(project(":spring-webmvc"), optional)
428473
compile(project(":spring-webmvc-portlet"), optional)
429474
compile("junit:junit:4.10", optional)
@@ -439,6 +484,10 @@ project('spring-test') {
439484
project('spring-struts') {
440485
description = 'Spring Struts'
441486
dependencies {
487+
compile project(":spring-core")
488+
compile project(":spring-beans")
489+
compile project(":spring-context")
490+
compile project(":spring-web")
442491
compile project(":spring-webmvc")
443492
compile "struts:struts:1.2.9"
444493
compile "commons-beanutils:commons-beanutils:1.7.0"
@@ -451,6 +500,8 @@ project('spring-aspects') {
451500
description = 'Spring Aspects'
452501
apply from: 'aspects.gradle'
453502
dependencies {
503+
compile project(":spring-core")
504+
compile project(":spring-tx")
454505
compile project(":spring-orm")
455506
aspects project(":spring-orm")
456507
ajc "org.aspectj:aspectjtools:${aspectjVersion}"
@@ -477,7 +528,15 @@ configure(rootProject) {
477528
configurations.archives.artifacts.clear()
478529

479530
dependencies { // for integration tests
531+
testCompile project(":spring-core")
532+
testCompile project(":spring-beans")
533+
testCompile project(":spring-aop")
534+
testCompile project(":spring-expression")
535+
testCompile project(":spring-context")
536+
testCompile project(":spring-tx")
537+
testCompile project(":spring-jdbc")
480538
testCompile project(":spring-test")
539+
testCompile project(":spring-web")
481540
testCompile project(":spring-webmvc-portlet")
482541
testCompile "org.hibernate:hibernate-core:4.1.0.Final"
483542
testCompile "javax.servlet:servlet-api:2.5"

0 commit comments

Comments
 (0)