From 5f17f54258459f9415e804fb45528af14350f954 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 14 May 2014 11:06:57 +0100 Subject: [PATCH] Add the Spring IO plugin This commit adds the Spring IO plugin, but it is configured such that it will only take effect when the build is run with -PplatformVersion=x.y.z Some redundant exclusions in spring-cloud-spring-service-connector have been removed and those that only declared a module have been updated to declare both a module and a group. The Spring IO Platform currently specifies a newer version (2.12.1) of the MongoDB driver. This version has changed the behaviour of Mongo.getAddress() such that calling it now results in an attempt to initiate the connection. MongoServiceConnectorCreatorTest has been updated to call Mongo.getAllAddresses() instead. This works on both 2.11.x and 2.12.1. --- build.gradle | 14 +++++++++++++ .../build.gradle | 20 ++++++------------- .../MongoServiceConnectorCreatorTest.java | 8 +++++++- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index cf43df9..953a6ce 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ buildscript { } dependencies { classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.5' + classpath 'org.springframework.build.gradle:spring-io-plugin:0.0.3.RELEASE' } } @@ -59,6 +60,19 @@ subprojects { apply from: "${rootProject.projectDir}/publish-maven.gradle" + if (project.hasProperty('platformVersion')) { + apply plugin: 'spring-io' + + // necessary to resolve the Spring IO versions (which may include snapshots) + repositories { + maven { url "https://repo.spring.io/libs-snapshot" } + } + + dependencies { + springIoVersions "io.spring.platform:platform-versions:${platformVersion}@properties" + } + } + sourceCompatibility = 1.6 targetCompatibility = 1.6 diff --git a/spring-cloud-spring-service-connector/build.gradle b/spring-cloud-spring-service-connector/build.gradle index f03e574..9b68e47 100644 --- a/spring-cloud-spring-service-connector/build.gradle +++ b/spring-cloud-spring-service-connector/build.gradle @@ -20,26 +20,18 @@ dependencies { optional("org.apache.tomcat:tomcat-jdbc:$tomcatVersion") optional("org.apache.tomcat:tomcat-dbcp:$tomcatVersion") optional("org.apache.commons:commons-dbcp2:$commonDbcp2Version") { - exclude(module: 'commons-logging') - exclude(module: 'xerces') - exclude(module: 'xercesImpl') - exclude(module: 'xml-apis') - } - optional("commons-dbcp:commons-dbcp:$commonDbcpVersion") { - exclude(module: 'commons-logging') - exclude(module: 'xerces') - exclude(module: 'xercesImpl') - exclude(module: 'xml-apis') + exclude(group: 'commons-logging', module: 'commons-logging') } + optional("commons-dbcp:commons-dbcp:$commonDbcpVersion") optional("org.springframework.amqp:spring-rabbit:$springAmqpVersion") optional("org.springframework.data:spring-data-redis:$springDataRedisVersion") { - exclude(module: 'spring-context-support') + exclude(group: 'org.springframework', module: 'spring-context-support') } optional("redis.clients:jedis:$jedisVersion") optional("org.springframework.data:spring-data-mongodb:$springDataMongoVersion") { - exclude(module: 'spring-beans') - exclude(module: 'spring-expression') - exclude(module: 'spring-tx') + exclude(group: 'org.springframework', module: 'spring-beans') + exclude(group: 'org.springframework', module: 'spring-expression') + exclude(group: 'org.springframework', module: 'spring-tx') } } diff --git a/spring-cloud-spring-service-connector/src/test/java/org/springframework/cloud/service/mongo/MongoServiceConnectorCreatorTest.java b/spring-cloud-spring-service-connector/src/test/java/org/springframework/cloud/service/mongo/MongoServiceConnectorCreatorTest.java index cdddcc5..9b8a770 100644 --- a/spring-cloud-spring-service-connector/src/test/java/org/springframework/cloud/service/mongo/MongoServiceConnectorCreatorTest.java +++ b/spring-cloud-spring-service-connector/src/test/java/org/springframework/cloud/service/mongo/MongoServiceConnectorCreatorTest.java @@ -3,6 +3,8 @@ package org.springframework.cloud.service.mongo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import java.util.List; + import org.junit.Test; import org.springframework.cloud.service.common.MongoServiceInfo; import org.springframework.cloud.service.document.MongoDbFactoryCreator; @@ -47,7 +49,11 @@ public class MongoServiceConnectorCreatorTest { Mongo mongo = (Mongo) ReflectionTestUtils.getField(connector, "mongo"); UserCredentials credentials = (UserCredentials) ReflectionTestUtils.getField(connector, "credentials"); assertNotNull(mongo); - ServerAddress address = mongo.getAddress(); + + List addresses = mongo.getAllAddress(); + assertEquals(1, addresses.size()); + + ServerAddress address = addresses.get(0); assertEquals(serviceInfo.getHost(), address.getHost()); assertEquals(serviceInfo.getPort(), address.getPort());