Skip to content

Commit

Permalink
Move test code depending on Spring to separate module
Browse files Browse the repository at this point in the history
It is difficult to depend on Spring 6 in test code in our published modules because we maintain a Java 8 baseline while Spring 6 requires Java 17. Moving this code to a separate module avoids that issue. There is still one usage of Spring in our normal test code for ModifiedClassPathClassLoader.
  • Loading branch information
shakuzen committed Oct 10, 2024
1 parent cef3b9c commit fad8326
Show file tree
Hide file tree
Showing 20 changed files with 2,215 additions and 1,962 deletions.
2 changes: 0 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ def VERSIONS = [
libs.mongoSync,
libs.postgre,
libs.slf4jApi,
libs.spring.context,
libs.spring.core,
libs.testcontainers.junitJupiter,
libs.testcontainers.kafka,
libs.testcontainers.postgresql,
Expand Down
21 changes: 20 additions & 1 deletion docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,29 @@ apply plugin: 'org.antora'

description = 'Micrometer Docs'

// Spring 6 requires Java 17+
// skip this module when building with jdk <17
if (!javaLanguageVersion.canCompileOrRun(17)) {
project.tasks.configureEach { task -> task.enabled = false }
}

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion = javaLanguageVersion
}
}

compileTestJava {
// need to override the config applied in the root build.gradle to all subprojects
// TODO can we not do this with Gradle's toolchains instead?
sourceCompatibility = javaLanguageVersion
targetCompatibility = javaLanguageVersion
}

dependencies {
implementation project(':micrometer-core')
implementation 'io.micrometer:context-propagation'
Expand All @@ -31,7 +50,7 @@ dependencies {
testImplementation libs.aspectjweaver
testImplementation libs.junitJupiter
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.springframework:spring-context'
testImplementation(libs.spring6.context)
testImplementation 'io.projectreactor:reactor-core'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'io.netty:netty-transport'
Expand Down
10 changes: 7 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ rest-assured = "5.5.0"
signalfx = "1.0.46"
slf4j = "1.7.36"
spectator-atlas = "1.7.21"
spring = "5.3.36"
spring5 = "5.3.39"
spring6 = "6.1.13"
spring-javaformat = "0.0.43"
testcontainers = "1.20.2"
tomcat = "8.5.100"
Expand Down Expand Up @@ -134,6 +135,8 @@ httpcomponents-client = { module = "org.apache.httpcomponents:httpclient", versi
httpcomponents-client5 = { module = "org.apache.httpcomponents.client5:httpclient5", version.ref = "httpcomponents-client5" }
hystrix = { module = "com.netflix.hystrix:hystrix-core", version.ref = "hystrix" }
jacksonDatabind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson-databind" }
jakarta-annotationAPi = { module = "jakarta.annotation:jakarta.annotation-api", version = "3.0.0" }
jakarta-injectApi = { module = "jakarta.inject:jakarta.inject-api", version = "2.0.1" }
jakarta-jmsApi = { module = "jakarta.jms:jakarta.jms-api", version = "3.0.0" }
jakarta-servletApi = { module = "jakarta.servlet:jakarta.servlet-api", version = "5.0.0" }
javalin = { module = "io.javalin:javalin", version = "5.6.5" }
Expand Down Expand Up @@ -202,10 +205,11 @@ signalfx = { module = "com.signalfx.public:signalfx-java", version.ref = "signal
slf4jApi = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
slfj4Simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
spectatorAtlas = { module = "com.netflix.spectator:spectator-reg-atlas", version.ref = "spectator-atlas" }
spring-context = { module = "org.springframework:spring-context", version.ref = "spring" }
spring-core = { module = "org.springframework:spring-core", version.ref = "spring" }
spring5-core = { module = "org.springframework:spring-core", version.ref = "spring5" }
spring-cloud = { module = "org.springframework.cloud:spring-cloud-dependencies", version = "2021.0.9" }
spring-javaformatCheckstyle = { module = "io.spring.javaformat:spring-javaformat-checkstyle", version.ref = "spring-javaformat" }
spring6-aop = { module = "org.springframework:spring-aop", version.ref = "spring6" }
spring6-context = { module = "org.springframework:spring-context", version.ref = "spring6" }
systemStubsJupiter = { module = "uk.org.webcompere:system-stubs-jupiter", version = "2.1.7" }
testcontainers-junitJupiter = { module = "org.testcontainers:junit-jupiter", version.ref = "testcontainers" }
testcontainers-kafka = { module = "org.testcontainers:kafka", version.ref = "testcontainers" }
Expand Down
4 changes: 3 additions & 1 deletion micrometer-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ dependencies {

// dependency injection tests
testImplementation 'javax.inject:javax.inject'
testImplementation 'org.springframework:spring-context'
testImplementation 'com.google.inject:guice'

// Uncomment these if you are interested in testing injection with dagger in MeterRegistryInjectionTest
// testImplementation 'com.google.dagger:dagger'
// testAnnotationProcessor 'com.google.dagger:dagger-compiler'

// Only needed for ModifiedClassPathClassLoader
testImplementation(libs.spring5.core)

// JUnit 5
testImplementation libs.junitJupiter
testImplementation(libs.archunitJunit5) {
Expand Down
Loading

0 comments on commit fad8326

Please sign in to comment.