Skip to content

Commit

Permalink
Update to Groovy 4 (#5532)
Browse files Browse the repository at this point in the history
* Update to Groovy 4

* exclude spock from grails tests, update comment

* Update instrumentation/grails-3.0/javaagent/build.gradle.kts

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
  • Loading branch information
laurit and trask authored Mar 9, 2022
1 parent f6cca58 commit e9c1efe
Show file tree
Hide file tree
Showing 38 changed files with 106 additions and 65 deletions.
8 changes: 6 additions & 2 deletions conventions/src/main/kotlin/otel.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ tasks.withType<JavaCompile>().configureEach {
// Groovy and Scala compilers don't actually understand --release option
afterEvaluate {
tasks.withType<GroovyCompile>().configureEach {
sourceCompatibility = otelJava.minJavaVersionSupported.get().majorVersion
targetCompatibility = otelJava.minJavaVersionSupported.get().majorVersion
var javaVersion = otelJava.minJavaVersionSupported.get().majorVersion
if (javaVersion == "8") {
javaVersion = "1.8"
}
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
tasks.withType<ScalaCompile>().configureEach {
sourceCompatibility = otelJava.minJavaVersionSupported.get().majorVersion
Expand Down
13 changes: 7 additions & 6 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ rootProject.extra["versions"] = dependencyVersions
val otelVersion = "1.12.0"
rootProject.extra["otelVersion"] = otelVersion

// Need both BOM and -all
val groovyVersion = "3.0.9"
// Need both BOM and groovy jars
val groovyVersion = "4.0.1"

// We don't force libraries we instrument to new versions since we compile and test against specific
// old baseline versions
Expand All @@ -32,7 +32,7 @@ val groovyVersion = "3.0.9"
val DEPENDENCY_BOMS = listOf(
"com.fasterxml.jackson:jackson-bom:2.13.1",
"com.google.guava:guava-bom:31.0.1-jre",
"org.codehaus.groovy:groovy-bom:${groovyVersion}",
"org.apache.groovy:groovy-bom:${groovyVersion}",
"io.opentelemetry:opentelemetry-bom:${otelVersion}",
"io.opentelemetry:opentelemetry-bom-alpha:${otelVersion}-alpha",
"org.junit:junit-bom:5.8.2"
Expand Down Expand Up @@ -109,11 +109,12 @@ val DEPENDENCIES = listOf(
"org.awaitility:awaitility:4.1.1",
"com.google.code.findbugs:annotations:3.0.1u2",
"com.google.code.findbugs:jsr305:3.0.2",
"org.codehaus.groovy:groovy-all:${groovyVersion}",
"org.apache.groovy:groovy:${groovyVersion}",
"org.apache.groovy:groovy-json:${groovyVersion}",
"org.junit-pioneer:junit-pioneer:1.5.0",
"org.objenesis:objenesis:3.2",
"org.spockframework:spock-core:2.0-groovy-3.0",
"org.spockframework:spock-junit4:2.0-groovy-3.0",
"org.spockframework:spock-core:2.2-M1-groovy-4.0",
"org.spockframework:spock-junit4:2.2-M1-groovy-4.0",
"org.scala-lang:scala-library:2.11.12",
"org.springframework.boot:spring-boot-dependencies:2.3.1.RELEASE",
)
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/apache-dubbo-2.7/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
implementation("javax.annotation:javax.annotation-api:1.3.2")
implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {

api("org.apache.httpcomponents:httpclient:4.3")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
2 changes: 1 addition & 1 deletion instrumentation/armeria-1.3/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
implementation("com.github.stefanbirkner:system-lambda")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
implementation("com.github.stefanbirkner:system-lambda")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
testImplementation("org.codehaus.groovy:groovy-all")
testImplementation("org.apache.groovy:groovy")
testImplementation("org.spockframework:spock-core")

testImplementation(project(":instrumentation-api"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
api("com.couchbase.client:java-client:2.5.0")
api("org.springframework.data:spring-data-couchbase:2.0.0.RELEASE")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
19 changes: 19 additions & 0 deletions instrumentation/grails-3.0/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,22 @@ dependencies {
testLibrary("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
testLibrary("org.springframework.boot:spring-boot-starter-tomcat:$springBootVersion")
}

// testing-common pulls in groovy 4 and spock as dependencies, exclude them
configurations.configureEach {
exclude("org.apache.groovy", "groovy")
exclude("org.apache.groovy", "groovy-json")
exclude("org.spockframework", "spock-core")
}

configurations.configureEach {
if (!name.contains("muzzle")) {
resolutionStrategy {
eachDependency {
if (requested.group == "org.codehaus.groovy") {
useVersion("3.0.9")
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ package test

import grails.artefact.Controller
import grails.web.Action
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.api.trace.Span
import io.opentelemetry.instrumentation.testing.GlobalTraceUtil
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint
import java.util.concurrent.Callable

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.INDEXED_CHILD
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.PATH_PARAM
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.QUERY_PARAM
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.REDIRECT
Expand All @@ -27,59 +31,71 @@ class TestController implements Controller {

@Action
def success() {
HttpServerTest.controller(SUCCESS) {
controller(SUCCESS) {
render SUCCESS.body
}
}

@Action
def query() {
HttpServerTest.controller(QUERY_PARAM) {
controller(QUERY_PARAM) {
render "some=${params.some}"
}
}

@Action
def redirect() {
HttpServerTest.controller(REDIRECT) {
controller(REDIRECT) {
response.sendRedirect(REDIRECT.body)
}
}

@Action
def error() {
HttpServerTest.controller(ERROR) {
controller(ERROR) {
response.sendError(ERROR.status, "unused")
}
}

@Action
def exception() {
HttpServerTest.controller(EXCEPTION) {
controller(EXCEPTION) {
throw new Exception(EXCEPTION.body)
}
}

@Action
def path() {
HttpServerTest.controller(PATH_PARAM) {
controller(PATH_PARAM) {
render params.id
}
}

@Action
def captureHeaders() {
HttpServerTest.controller(CAPTURE_HEADERS) {
controller(CAPTURE_HEADERS) {
response.setHeader("X-Test-Response", request.getHeader("X-Test-Request"))
render CAPTURE_HEADERS.body
}
}

@Action
def child() {
HttpServerTest.controller(INDEXED_CHILD) {
controller(INDEXED_CHILD) {
INDEXED_CHILD.collectSpanAttributes({ name -> name == "id" ? params.id : null })
render INDEXED_CHILD.body
}
}
}

// copied from HttpServerTest
// groovy classes in testing-common are compiled with a different groovy version, we don't want
// to use them here
static <T> T controller(ServerEndpoint endpoint, Callable<T> closure) {
assert Span.current().getSpanContext().isValid(): "Controller should have a parent span."
if (endpoint == NOT_FOUND) {
return closure.call()
}
return GlobalTraceUtil.runWithSpan("controller") {
closure.call()
}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
api(project(":testing-common"))
api("javax.ws.rs:javax.ws.rs-api:2.0")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
implementation("org.slf4j:slf4j-api")
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/jdbc/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ plugins {
}

dependencies {
implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {

implementation("org.junit.jupiter:junit-jupiter-api")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
implementation("org.testcontainers:testcontainers")
implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ abstract class AbstractLogbackTest extends InstrumentationSpecification {
def "ids when span"() {
when:
Span span1 = runWithSpan("test") {
logger.info("log message 1")
AbstractLogbackTest.logger.info("log message 1")
Span.current()
}

logger.info("log message 2")

Span span2 = runWithSpan("test 2") {
logger.info("log message 3")
AbstractLogbackTest.logger.info("log message 3")
Span.current()
}

Expand Down
2 changes: 1 addition & 1 deletion instrumentation/mongo/mongo-3.1/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {

compileOnly("org.mongodb:mongo-java-driver:3.1.0")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
api(project(":testing-common"))
api("org.testcontainers:mongodb:${versions["org.testcontainers"]}")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
2 changes: 1 addition & 1 deletion instrumentation/okhttp/okhttp-3.0/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {

implementation("com.google.guava:guava")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
api(project(":testing-common"))
api("com.typesafe.play:play-ahc-ws-standalone_$scalaVersion:1.0.2")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
implementation("io.ratpack:ratpack-core:1.4.0")
implementation("io.ratpack:ratpack-test:1.4.0")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {

api("io.projectreactor:reactor-core:3.1.0.RELEASE")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
implementation("org.restlet:org.restlet.ext.spring:1.1.5")
implementation("org.springframework:spring:2.5.6")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
implementation("org.restlet.jse:org.restlet:2.0.2")
implementation("org.restlet.jse:org.restlet.ext.spring:2.0.2")

implementation("org.codehaus.groovy:groovy-all")
implementation("org.apache.groovy:groovy")
implementation("io.opentelemetry:opentelemetry-api")
implementation("org.spockframework:spock-core")
}
Loading

0 comments on commit e9c1efe

Please sign in to comment.