Skip to content

Commit

Permalink
Remove unused test dependencies and reduce scope to runtime if possib…
Browse files Browse the repository at this point in the history
…le (#3159)

Motivation:

Reduce warnings produced by dependency-analysis-gradle-plugin for test dependencies.

Modifications:

- Remove unused test dependencies;
- Reduce scope to runtime-only for some test dependencies;
- Add exclude rules for false positives;
- Add missed `package-info.java` files for benchmarks module;

Result:

Less warnings for our dependencies.
  • Loading branch information
idelpivnitskiy authored Jan 7, 2025
1 parent b8722f6 commit 0c7968d
Show file tree
Hide file tree
Showing 54 changed files with 250 additions and 155 deletions.
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ buildscript {
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-root"

// Unfortunately, we can not make this validation part of our servicetalk-gradle-plugin-internal because it requires
// JDK11 while we build and package out plugin with JDK8.
// JDK11 while we build and package our plugin with JDK8.
if (JavaVersion.current().isJava11Compatible()) {
apply plugin: "com.autonomousapps.dependency-analysis"

Expand All @@ -67,6 +67,13 @@ if (JavaVersion.current().isJava11Compatible()) {
all {
onAny {
severity("warn") // FIXME: switch to "fail" when all issues are addressed
}
onUnusedDependencies {
// We use it for log4j2.xml configuration
exclude(":servicetalk-test-resources")
}
onUsedTransitiveDependencies {
// We import it as api dependency via :servicetalk-annotations
exclude("com.google.code.findbugs:jsr305")
}
}
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,5 @@ spotbugsPluginVersion=5.0.13
dependencyAnalysisPluginVersion=2.6.1

apacheDirectoryServerVersion=1.5.7
commonsLangVersion=2.6
grpcVersion=1.69.0
javaxAnnotationsApiVersion=1.3.5
jsonUnitVersion=2.40.1
6 changes: 1 addition & 5 deletions servicetalk-benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ dependencies {
implementation project(":servicetalk-buffer-netty")
implementation project(":servicetalk-concurrent-api")
implementation project(":servicetalk-concurrent-api-internal")
implementation project(":servicetalk-concurrent-internal")
implementation project(":servicetalk-http-api")
implementation project(":servicetalk-http-netty")
implementation project(":servicetalk-transport-netty-internal")
implementation project(":servicetalk-loadbalancer")
implementation project(":servicetalk-data-jackson")
implementation "io.netty:netty-codec-http"
implementation "org.openjdk.jmh:jmh-core:$jmhCoreVersion"

testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation project(":servicetalk-concurrent-internal")
testImplementation project(":servicetalk-concurrent-api-internal")
testImplementation project(":servicetalk-test-resources")
}

jmh {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import java.io.IOException;
import java.util.Random;
import javax.annotation.Nullable;

import static io.servicetalk.buffer.netty.BufferAllocators.PREFER_HEAP_ALLOCATOR;
import static io.servicetalk.concurrent.api.SourceAdapters.toSource;
Expand Down Expand Up @@ -109,6 +110,7 @@ public class ConnectableBufferOutputStreamBenchmark {
byte[] data;
ConnectableBufferOutputStream cbos;
Publisher<Buffer> publisher;
@Nullable
Subscription subscription;

@Setup(Level.Iteration)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright © 2025 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@ElementsAreNonnullByDefault
package io.servicetalk.benchmark.concurrent;

import io.servicetalk.annotations.ElementsAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright © 2025 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@ElementsAreNonnullByDefault
package io.servicetalk.benchmark.http;

import io.servicetalk.annotations.ElementsAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright © 2025 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@ElementsAreNonnullByDefault
package io.servicetalk.benchmark.loadbalancer;

import io.servicetalk.annotations.ElementsAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright © 2025 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@ElementsAreNonnullByDefault
package io.servicetalk.benchmark;

import io.servicetalk.annotations.ElementsAreNonnullByDefault;
1 change: 0 additions & 1 deletion servicetalk-buffer-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

testFixturesApi "org.hamcrest:hamcrest:$hamcrestVersion"
testFixturesImplementation "com.google.code.findbugs:jsr305:$jsr305Version"
Expand Down
1 change: 0 additions & 1 deletion servicetalk-circuit-breaker-resilience4j/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ dependencies {

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
}
5 changes: 2 additions & 3 deletions servicetalk-client-api-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ dependencies {

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation project(":servicetalk-test-resources")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

testRuntimeOnly testFixtures(project(":servicetalk-concurrent-internal"))
}
5 changes: 2 additions & 3 deletions servicetalk-client-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation project(":servicetalk-concurrent-test-internal")
testImplementation project(":servicetalk-test-resources")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"

testRuntimeOnly testFixtures(project(":servicetalk-concurrent-internal"))
}
1 change: 0 additions & 1 deletion servicetalk-concurrent-api-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ dependencies {
testImplementation project(":servicetalk-test-resources")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
}
3 changes: 1 addition & 2 deletions servicetalk-concurrent-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ dependencies {
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

testFixturesImplementation platform("org.junit:junit-bom:$junit5Version")
testFixturesImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testFixturesImplementation project(":servicetalk-concurrent-internal")
testFixturesImplementation project(":servicetalk-utils-internal")
testFixturesImplementation project(":servicetalk-concurrent-test-internal")
testFixturesImplementation "com.google.code.findbugs:jsr305:$jsr305Version"
testFixturesImplementation "org.junit.jupiter:junit-jupiter-api"
testFixturesImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testFixturesImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
testFixturesImplementation "org.slf4j:slf4j-api:$slf4jVersion"
}
1 change: 0 additions & 1 deletion servicetalk-concurrent-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies {
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

testFixturesImplementation platform("org.junit:junit-bom:$junit5Version")
testFixturesImplementation project(":servicetalk-annotations")
testFixturesImplementation "org.junit.jupiter:junit-jupiter-api"
testFixturesImplementation "org.slf4j:slf4j-api:$slf4jVersion"
}
13 changes: 4 additions & 9 deletions servicetalk-data-jackson-jersey/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,15 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation testFixtures(project(":servicetalk-transport-netty-internal"))
testImplementation testFixtures(project(":servicetalk-http-router-jersey"))
testImplementation project(":servicetalk-http-netty")
testImplementation project(":servicetalk-http-router-predicate")
testImplementation project(":servicetalk-test-resources")
testImplementation project(":servicetalk-transport-netty-internal")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.junit.platform:junit-platform-suite-api:$junitPlatformVersion"
testImplementation "net.javacrumbs.json-unit:json-unit:$jsonUnitVersion"
testImplementation "org.glassfish.jersey.inject:jersey-hk2"
testImplementation "org.glassfish.jersey.media:jersey-media-sse"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
testImplementation "net.javacrumbs.json-unit:json-unit:$jsonUnitVersion"

testRuntimeOnly "org.glassfish.jersey.inject:jersey-hk2"
testRuntimeOnly "org.glassfish.jersey.media:jersey-media-sse"
}
13 changes: 4 additions & 9 deletions servicetalk-data-jackson-jersey3-jakarta10/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,15 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation testFixtures(project(":servicetalk-transport-netty-internal"))
testImplementation testFixtures(project(":servicetalk-http-router-jersey3-jakarta10"))
testImplementation project(":servicetalk-http-netty")
testImplementation project(":servicetalk-http-router-predicate")
testImplementation project(":servicetalk-test-resources")
testImplementation project(":servicetalk-transport-netty-internal")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.junit.platform:junit-platform-suite-api:$junitPlatformVersion"
testImplementation "net.javacrumbs.json-unit:json-unit:$jsonUnitVersion"
testImplementation "org.glassfish.jersey.inject:jersey-hk2"
testImplementation "org.glassfish.jersey.media:jersey-media-sse"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
testImplementation "net.javacrumbs.json-unit:json-unit:$jsonUnitVersion"

testRuntimeOnly "org.glassfish.jersey.inject:jersey-hk2"
testRuntimeOnly "org.glassfish.jersey.media:jersey-media-sse"
}
13 changes: 4 additions & 9 deletions servicetalk-data-jackson-jersey3-jakarta9/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,15 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation testFixtures(project(":servicetalk-transport-netty-internal"))
testImplementation testFixtures(project(":servicetalk-http-router-jersey3-jakarta9"))
testImplementation project(":servicetalk-http-netty")
testImplementation project(":servicetalk-http-router-predicate")
testImplementation project(":servicetalk-test-resources")
testImplementation project(":servicetalk-transport-netty-internal")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.junit.platform:junit-platform-suite-api:$junitPlatformVersion"
testImplementation "net.javacrumbs.json-unit:json-unit:$jsonUnitVersion"
testImplementation "org.glassfish.jersey.inject:jersey-hk2"
testImplementation "org.glassfish.jersey.media:jersey-media-sse"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
testImplementation "net.javacrumbs.json-unit:json-unit:$jsonUnitVersion"

testRuntimeOnly "org.glassfish.jersey.inject:jersey-hk2"
testRuntimeOnly "org.glassfish.jersey.media:jersey-media-sse"
}
5 changes: 2 additions & 3 deletions servicetalk-data-jackson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation project(":servicetalk-test-resources")
testImplementation project(":servicetalk-buffer-netty")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

testRuntimeOnly testFixtures(project(":servicetalk-concurrent-internal"))
}
15 changes: 5 additions & 10 deletions servicetalk-data-protobuf-jersey/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,18 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation testFixtures(project(":servicetalk-transport-netty-internal"))
testImplementation testFixtures(project(":servicetalk-http-router-jersey"))
testImplementation project(":servicetalk-http-netty")
testImplementation project(":servicetalk-http-router-predicate")
testImplementation project(":servicetalk-test-resources")
testImplementation project(":servicetalk-transport-netty-internal")
// BaseJerseyRouterTestSuite assumes JSON serialization is supported.
testImplementation project(":servicetalk-data-jackson-jersey")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.junit.platform:junit-platform-suite-api:$junitPlatformVersion"
testImplementation "org.glassfish.jersey.inject:jersey-hk2"
testImplementation "org.glassfish.jersey.media:jersey-media-sse"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

// BaseJerseyRouterTestSuite assumes JSON serialization is supported.
testRuntimeOnly project(":servicetalk-data-jackson-jersey")
testRuntimeOnly "org.glassfish.jersey.inject:jersey-hk2"
testRuntimeOnly "org.glassfish.jersey.media:jersey-media-sse"
}

protobuf {
Expand Down
15 changes: 5 additions & 10 deletions servicetalk-data-protobuf-jersey3-jakarta10/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,18 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation testFixtures(project(":servicetalk-transport-netty-internal"))
testImplementation testFixtures(project(":servicetalk-http-router-jersey3-jakarta10"))
testImplementation project(":servicetalk-http-netty")
testImplementation project(":servicetalk-http-router-predicate")
testImplementation project(":servicetalk-test-resources")
testImplementation project(":servicetalk-transport-netty-internal")
// BaseJerseyRouterTestSuite assumes JSON serialization is supported.
testImplementation project(":servicetalk-data-jackson-jersey3-jakarta10")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.junit.platform:junit-platform-suite-api:$junitPlatformVersion"
testImplementation "org.glassfish.jersey.inject:jersey-hk2"
testImplementation "org.glassfish.jersey.media:jersey-media-sse"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

// BaseJerseyRouterTestSuite assumes JSON serialization is supported.
testRuntimeOnly project(":servicetalk-data-jackson-jersey3-jakarta10")
testRuntimeOnly "org.glassfish.jersey.inject:jersey-hk2"
testRuntimeOnly "org.glassfish.jersey.media:jersey-media-sse"
}

protobuf {
Expand Down
15 changes: 5 additions & 10 deletions servicetalk-data-protobuf-jersey3-jakarta9/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,18 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"

testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
testImplementation testFixtures(project(":servicetalk-concurrent-api"))
testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
testImplementation testFixtures(project(":servicetalk-transport-netty-internal"))
testImplementation testFixtures(project(":servicetalk-http-router-jersey3-jakarta9"))
testImplementation project(":servicetalk-http-netty")
testImplementation project(":servicetalk-http-router-predicate")
testImplementation project(":servicetalk-test-resources")
testImplementation project(":servicetalk-transport-netty-internal")
// BaseJerseyRouterTestSuite assumes JSON serialization is supported.
testImplementation project(":servicetalk-data-jackson-jersey3-jakarta9")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.junit.platform:junit-platform-suite-api:$junitPlatformVersion"
testImplementation "org.glassfish.jersey.inject:jersey-hk2"
testImplementation "org.glassfish.jersey.media:jersey-media-sse"
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"

// BaseJerseyRouterTestSuite assumes JSON serialization is supported.
testRuntimeOnly project(":servicetalk-data-jackson-jersey3-jakarta9")
testRuntimeOnly "org.glassfish.jersey.inject:jersey-hk2"
testRuntimeOnly "org.glassfish.jersey.media:jersey-media-sse"
}

protobuf {
Expand Down
Loading

0 comments on commit 0c7968d

Please sign in to comment.