Update to gradle 7.5.1 (#415)

* Update to gradle 7.5.1

* Update to 7.5.1

* Fix

* Fix
This commit is contained in:
Trask Stalnaker 2022-09-05 07:22:16 -07:00 committed by GitHub
parent e7d07fdbee
commit 3baf42a87b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 152 additions and 104 deletions

View File

@ -1,9 +1,9 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins { plugins {
`java-platform` `java-platform`
id("com.github.ben-manes.versions") id("com.github.ben-manes.versions")
} }
data class DependencySet(val group: String, val version: String, val modules: List<String>) data class DependencySet(val group: String, val version: String, val modules: List<String>)
@ -15,103 +15,103 @@ rootProject.extra["versions"] = dependencyVersions
val otelVersion = "1.17.0" val otelVersion = "1.17.0"
val DEPENDENCY_BOMS = listOf( val DEPENDENCY_BOMS = listOf(
"com.fasterxml.jackson:jackson-bom:2.13.2.20220328", "com.fasterxml.jackson:jackson-bom:2.13.2.20220328",
"com.google.guava:guava-bom:31.0.1-jre", "com.google.guava:guava-bom:31.0.1-jre",
"com.linecorp.armeria:armeria-bom:1.14.0", "com.linecorp.armeria:armeria-bom:1.14.0",
"org.junit:junit-bom:5.8.2", "org.junit:junit-bom:5.8.2",
"com.linecorp.armeria:armeria-bom:1.9.1", "com.linecorp.armeria:armeria-bom:1.9.1",
"io.grpc:grpc-bom:1.42.1", "io.grpc:grpc-bom:1.42.1",
"io.opentelemetry:opentelemetry-bom:$otelVersion", "io.opentelemetry:opentelemetry-bom:$otelVersion",
"io.opentelemetry:opentelemetry-bom-alpha:${otelVersion}-alpha", "io.opentelemetry:opentelemetry-bom-alpha:${otelVersion}-alpha",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelVersion}-alpha", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelVersion}-alpha",
"org.testcontainers:testcontainers-bom:1.16.3" "org.testcontainers:testcontainers-bom:1.16.3"
) )
val DEPENDENCY_SETS = listOf( val DEPENDENCY_SETS = listOf(
DependencySet( DependencySet(
"com.google.auto.service", "com.google.auto.service",
"1.0.1", "1.0.1",
listOf("auto-service", "auto-service-annotations") listOf("auto-service", "auto-service-annotations")
), ),
DependencySet( DependencySet(
"com.google.auto.value", "com.google.auto.value",
"1.9", "1.9",
listOf("auto-value", "auto-value-annotations") listOf("auto-value", "auto-value-annotations")
), ),
DependencySet( DependencySet(
"com.google.errorprone", "com.google.errorprone",
"2.14.0", "2.14.0",
listOf("error_prone_annotations", "error_prone_core") listOf("error_prone_annotations", "error_prone_core")
), ),
DependencySet( DependencySet(
"io.prometheus", "io.prometheus",
"0.12.0", "0.12.0",
listOf("simpleclient", "simpleclient_common", "simpleclient_httpserver") listOf("simpleclient", "simpleclient_common", "simpleclient_httpserver")
), ),
DependencySet( DependencySet(
"org.mockito", "org.mockito",
"4.3.1", "4.3.1",
listOf("mockito-core", "mockito-junit-jupiter") listOf("mockito-core", "mockito-junit-jupiter")
), ),
DependencySet( DependencySet(
"org.slf4j", "org.slf4j",
"1.7.36", "1.7.36",
listOf("slf4j-api", "slf4j-simple", "log4j-over-slf4j", "jcl-over-slf4j", "jul-to-slf4j") listOf("slf4j-api", "slf4j-simple", "log4j-over-slf4j", "jcl-over-slf4j", "jul-to-slf4j")
) )
) )
val DEPENDENCIES = listOf( val DEPENDENCIES = listOf(
"io.opentelemetry.javaagent:opentelemetry-javaagent:$otelVersion", "io.opentelemetry.javaagent:opentelemetry-javaagent:$otelVersion",
"com.google.code.findbugs:annotations:3.0.1u2", "com.google.code.findbugs:annotations:3.0.1u2",
"com.google.code.findbugs:jsr305:3.0.2", "com.google.code.findbugs:jsr305:3.0.2",
"com.squareup.okhttp3:okhttp:4.9.3", "com.squareup.okhttp3:okhttp:4.9.3",
"com.uber.nullaway:nullaway:0.9.5", "com.uber.nullaway:nullaway:0.9.5",
"org.assertj:assertj-core:3.22.0", "org.assertj:assertj-core:3.22.0",
"org.awaitility:awaitility:4.1.1", "org.awaitility:awaitility:4.1.1",
"org.junit-pioneer:junit-pioneer:1.5.0", "org.junit-pioneer:junit-pioneer:1.7.0",
"org.skyscreamer:jsonassert:1.5.0" "org.skyscreamer:jsonassert:1.5.0"
) )
javaPlatform { javaPlatform {
allowDependencies() allowDependencies()
} }
dependencies { dependencies {
for (bom in DEPENDENCY_BOMS) { for (bom in DEPENDENCY_BOMS) {
api(enforcedPlatform(bom)) api(enforcedPlatform(bom))
val split = bom.split(':') val split = bom.split(':')
dependencyVersions[split[0]] = split[2] dependencyVersions[split[0]] = split[2]
}
constraints {
for (set in DEPENDENCY_SETS) {
for (module in set.modules) {
api("${set.group}:${module}:${set.version}")
dependencyVersions[set.group] = set.version
}
} }
constraints { for (dependency in DEPENDENCIES) {
for (set in DEPENDENCY_SETS) { api(dependency)
for (module in set.modules) { val split = dependency.split(':')
api("${set.group}:${module}:${set.version}") dependencyVersions[split[0]] = split[2]
dependencyVersions[set.group] = set.version
}
}
for (dependency in DEPENDENCIES) {
api(dependency)
val split = dependency.split(':')
dependencyVersions[split[0]] = split[2]
}
} }
}
} }
fun isNonStable(version: String): Boolean { fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex() val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isGuava = version.endsWith("-jre") val isGuava = version.endsWith("-jre")
val isStable = stableKeyword || regex.matches(version) || isGuava val isStable = stableKeyword || regex.matches(version) || isGuava
return isStable.not() return isStable.not()
} }
tasks { tasks {
named<DependencyUpdatesTask>("dependencyUpdates") { named<DependencyUpdatesTask>("dependencyUpdates") {
revision = "release" revision = "release"
checkConstraints = true checkConstraints = true
rejectVersionIf { rejectVersionIf {
isNonStable(candidate.version) isNonStable(candidate.version)
}
} }
}
} }

Binary file not shown.

View File

@ -1,6 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

6
gradlew vendored
View File

@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

14
gradlew.bat vendored
View File

@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

View File

@ -20,15 +20,9 @@ dependencies {
testImplementation("io.opentelemetry.javaagent:opentelemetry-javaagent") testImplementation("io.opentelemetry.javaagent:opentelemetry-javaagent")
testImplementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations") testImplementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations")
testImplementation("org.junit.jupiter:junit-jupiter-api") testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit-pioneer:junit-pioneer")
testImplementation("org.assertj:assertj-core") testImplementation("org.assertj:assertj-core")
} }
tasks.test {
useJUnitPlatform()
setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
}
tasks { tasks {
jar { jar {
inputs.files(agent) inputs.files(agent)
@ -37,4 +31,36 @@ tasks {
}) })
rename { "otel-agent.jar" } rename { "otel-agent.jar" }
} }
withType<Test>().configureEach {
setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
}
val testAgentDisabledByEnvironmentVariable by registering(Test::class) {
filter {
includeTestsMatching("AgentDisabledByEnvironmentVariableTest")
}
include("**/AgentDisabledByEnvironmentVariableTest.*")
environment("OTEL_JAVAAGENT_ENABLED", "false")
}
val testAgentDisabledBySystemProperty by registering(Test::class) {
filter {
includeTestsMatching("AgentDisabledBySystemPropertyTest")
}
include("**/AgentDisabledBySystemPropertyTest.*")
jvmArgs("-Dotel.javaagent.enabled=false")
}
test {
filter {
excludeTestsMatching("AgentDisabledByEnvironmentVariableTest")
excludeTestsMatching("AgentDisabledBySystemPropertyTest")
}
}
check {
dependsOn(testAgentDisabledByEnvironmentVariable)
dependsOn(testAgentDisabledBySystemProperty)
}
} }

View File

@ -9,12 +9,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import io.opentelemetry.instrumentation.annotations.WithSpan; import io.opentelemetry.instrumentation.annotations.WithSpan;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetEnvironmentVariable;
import org.junitpioneer.jupiter.SetSystemProperty;
public class AgentDisabledTest extends AbstractAttachmentTest { public class AgentDisabledByEnvironmentVariableTest extends AbstractAttachmentTest {
@SetEnvironmentVariable(key = "OTEL_JAVAAGENT_ENABLED", value = "false")
@Test @Test
void shouldNotAttachWhenAgentDisabledWithEnvVariable() { void shouldNotAttachWhenAgentDisabledWithEnvVariable() {
RuntimeAttach.attachJavaagentToCurrentJVM(); RuntimeAttach.attachJavaagentToCurrentJVM();
@ -25,11 +22,4 @@ public class AgentDisabledTest extends AbstractAttachmentTest {
void verifyNoAttachment() { void verifyNoAttachment() {
assertThat(isAttached()).as("Agent should not be attached").isFalse(); assertThat(isAttached()).as("Agent should not be attached").isFalse();
} }
@SetSystemProperty(key = "otel.javaagent.enabled", value = "false")
@Test
void shouldNotAttachWhenAgentDisabledWithProperty() {
RuntimeAttach.attachJavaagentToCurrentJVM();
verifyNoAttachment();
}
} }

View File

@ -0,0 +1,25 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.contrib.attach;
import static org.assertj.core.api.Assertions.assertThat;
import io.opentelemetry.instrumentation.annotations.WithSpan;
import org.junit.jupiter.api.Test;
public class AgentDisabledBySystemPropertyTest extends AbstractAttachmentTest {
@Test
void shouldNotAttachWhenAgentDisabledWithProperty() {
RuntimeAttach.attachJavaagentToCurrentJVM();
verifyNoAttachment();
}
@WithSpan
void verifyNoAttachment() {
assertThat(isAttached()).as("Agent should not be attached").isFalse();
}
}