From da2aa3d35c27c4ba3489393788352452ab3e7c6f Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Mon, 28 May 2012 15:19:09 +0300 Subject: [PATCH] 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 --- build.gradle | 75 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 34fda66988f..507c5f3add9 100644 --- a/build.gradle +++ b/build.gradle @@ -163,6 +163,7 @@ project('spring-beans') { project('spring-aop') { description = 'Spring AOP' dependencies { + compile project(":spring-core") compile project(":spring-beans") compile("com.jamonapi:jamon:2.4", optional) compile("aopalliance:aopalliance:1.0", optional) @@ -194,9 +195,11 @@ project('spring-instrument-tomcat') { project('spring-context') { description = 'Spring Context' dependencies { + compile(project(":spring-instrument"), optional) compile project(":spring-aop") + compile project(":spring-beans") compile project(":spring-expression") - compile project(":spring-instrument") + compile project(":spring-core") compile("backport-util-concurrent:backport-util-concurrent:3.0", optional) compile("javax.annotation:jsr250-api:1.0", optional) compile("javax.ejb:ejb-api:3.0", optional) @@ -234,10 +237,14 @@ project('spring-context') { project('spring-tx') { description = 'Spring Transaction' dependencies { - compile project(":spring-context") + compile(project(":spring-context"), optional) // for JCA, @EnableTransactionManagement + compile(project(":spring-aop"), optional) + compile project(":spring-beans") + compile project(":spring-core") compile("com.ibm.websphere:uow:6.0.2.17", provided) compile("javax.resource:connector-api:1.5", optional) compile "aopalliance:aopalliance:1.0" // NOT optional, as opposed to in :spring-aop + compile("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1", optional) testCompile "org.easymock:easymockclassextension:2.3" } } @@ -246,7 +253,9 @@ project('spring-oxm') { description = 'Spring Object/XML Marshalling' apply from: 'oxm.gradle' dependencies { - compile project(":spring-context") + compile project(":spring-beans") + compile project(":spring-core") + compile(project(":spring-context"), optional) // for Jaxb2Marshaller compile "commons-lang:commons-lang:2.5" compile("com.thoughtworks.xstream:xstream:1.3.1", optional) compile("com.sun.xml.bind:jaxb-impl:2.1.7", optional) @@ -265,8 +274,12 @@ project('spring-oxm') { project('spring-jms') { description = 'Spring JMS' dependencies { - compile project(":spring-oxm") + compile project(":spring-core") + compile project(":spring-beans") + compile project(":spring-aop") + compile project(":spring-context") compile project(":spring-tx") + compile(project(":spring-oxm"), optional) compile("org.codehaus.jackson:jackson-mapper-asl:1.4.2", optional) } } @@ -274,19 +287,27 @@ project('spring-jms') { project('spring-jdbc') { description = 'Spring JDBC' dependencies { + compile project(":spring-core") + compile project(":spring-beans") + compile(project(":spring-context"), optional) // for JndiDataSourceLookup compile project(":spring-tx") compile("c3p0:c3p0:0.9.1.2", optional) compile("hsqldb:hsqldb:1.8.0.7", optional) compile("com.h2database:h2:1.0.71", optional) compile("org.apache.derby:derby:10.5.3.0_1", optional) compile("org.apache.derby:derbyclient:10.5.3.0_1", optional) + compile("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1", optional) } } project('spring-context-support') { description = 'Spring Context Support' dependencies { - compile project(":spring-jdbc") + compile project(":spring-core") + compile project(":spring-beans") + compile project(":spring-context") + compile(project(":spring-jdbc"), optional) // for Quartz support + compile(project(":spring-tx"), optional) // for Quartz support compile("org.codehaus.fabric3.api:commonj:1.1.0", optional) compile("opensymphony:quartz:1.6.2", optional) compile("javax.mail:mail:1.4", optional) @@ -313,7 +334,11 @@ project('spring-context-support') { project('spring-web') { description = 'Spring Web' dependencies { - compile project(":spring-oxm") + compile project(":spring-core") + compile project(":spring-beans") // for MultiPartFilter + compile project(":spring-aop") // for JaxWsPortProxyFactoryBean + compile project(":spring-context") + compile(project(":spring-oxm"), optional) // for MarshallingHttpMessageConverter compile("com.caucho:hessian:3.2.1", optional) compile("rome:rome:1.0", optional) compile("javax.el:el-api:1.0", optional) @@ -365,6 +390,11 @@ project('spring-orm') { compile(project(":spring-web")) { exclude group: 'javax.persistence', module: 'persistence-api' } + compile project(":spring-core") + compile project(":spring-beans") + compile(project(":spring-aop"), optional) + compile(project(":spring-context"), optional) + compile project(":spring-tx") compile project(":spring-jdbc") } } @@ -372,9 +402,13 @@ project('spring-orm') { project('spring-webmvc') { description = 'Spring Web MVC' dependencies { + compile project(":spring-core") + compile project(":spring-expression") + compile project(":spring-beans") compile project(":spring-web") - compile project(":spring-orm") - compile project(":spring-context-support") + compile project(":spring-context") + compile(project(":spring-context-support"), optional) // for Velocity support + compile(project(":spring-oxm"), optional) // for MarshallingView compile("org.apache.tiles:tiles-api:2.1.2", optional) compile("org.apache.tiles:tiles-core:2.1.2", optional) compile("org.apache.tiles:tiles-jsp:2.1.2", optional) @@ -390,6 +424,7 @@ project('spring-webmvc') { } compile("javax.servlet:jstl:1.1.2", provided) compile("org.apache.tomcat:tomcat-servlet-api:7.0.8", provided) // servlet-api 3.0 + testCompile project(":spring-aop") testCompile("org.slf4j:slf4j-log4j12:1.6.1") { exclude group: 'log4j', module: 'log4j' } @@ -413,6 +448,10 @@ project('spring-webmvc-portlet') { description = 'Spring Web Portlet' dependencies { compile("javax.servlet:servlet-api:2.5", provided) + compile project(":spring-core") + compile project(":spring-beans") + compile project(":spring-context") + compile project(":spring-web") compile project(":spring-webmvc") } @@ -424,6 +463,12 @@ project('spring-test') { description = 'Spring TestContext Framework' dependencies { compile project(":spring-core") + compile(project(":spring-beans"), optional) + compile(project(":spring-context"), optional) + compile(project(":spring-jdbc"), optional) + compile(project(":spring-tx"), optional) + compile(project(":spring-orm"), optional) + compile(project(":spring-web"), optional) compile(project(":spring-webmvc"), optional) compile(project(":spring-webmvc-portlet"), optional) compile("junit:junit:4.10", optional) @@ -439,6 +484,10 @@ project('spring-test') { project('spring-struts') { description = 'Spring Struts' dependencies { + compile project(":spring-core") + compile project(":spring-beans") + compile project(":spring-context") + compile project(":spring-web") compile project(":spring-webmvc") compile "struts:struts:1.2.9" compile "commons-beanutils:commons-beanutils:1.7.0" @@ -451,6 +500,8 @@ project('spring-aspects') { description = 'Spring Aspects' apply from: 'aspects.gradle' dependencies { + compile project(":spring-core") + compile project(":spring-tx") compile project(":spring-orm") aspects project(":spring-orm") ajc "org.aspectj:aspectjtools:${aspectjVersion}" @@ -477,7 +528,15 @@ configure(rootProject) { configurations.archives.artifacts.clear() dependencies { // for integration tests + testCompile project(":spring-core") + testCompile project(":spring-beans") + testCompile project(":spring-aop") + testCompile project(":spring-expression") + testCompile project(":spring-context") + testCompile project(":spring-tx") + testCompile project(":spring-jdbc") testCompile project(":spring-test") + testCompile project(":spring-web") testCompile project(":spring-webmvc-portlet") testCompile "org.hibernate:hibernate-core:4.1.0.Final" testCompile "javax.servlet:servlet-api:2.5"