Skip to content

Commit 1991537

Browse files
hhughesmichaelsembwever
authored andcommitted
Mark spotbugs-annotation and jcip-annotations as provided dependencies
patch by Henry Hughes; reviewed by Mick Semb Wever for CASSANDRA-18969
1 parent 2bf500e commit 1991537

File tree

17 files changed

+367
-18
lines changed

17 files changed

+367
-18
lines changed

core-shaded/pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@
112112
<dependency>
113113
<groupId>com.github.stephenc.jcip</groupId>
114114
<artifactId>jcip-annotations</artifactId>
115+
<scope>provided</scope>
115116
</dependency>
116117
<dependency>
117118
<groupId>com.github.spotbugs</groupId>
118119
<artifactId>spotbugs-annotations</artifactId>
120+
<scope>provided</scope>
119121
</dependency>
120122
</dependencies>
121123
<!--

core/pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@
119119
<dependency>
120120
<groupId>com.github.stephenc.jcip</groupId>
121121
<artifactId>jcip-annotations</artifactId>
122+
<scope>provided</scope>
122123
</dependency>
123124
<dependency>
124125
<groupId>com.github.spotbugs</groupId>
125126
<artifactId>spotbugs-annotations</artifactId>
127+
<scope>provided</scope>
126128
</dependency>
127129
<dependency>
128130
<groupId>org.graalvm.sdk</groupId>

distribution-tests/pom.xml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
-->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
<parent>
24+
<groupId>com.datastax.oss</groupId>
25+
<artifactId>java-driver-parent</artifactId>
26+
<version>4.17.1-SNAPSHOT</version>
27+
</parent>
28+
<artifactId>java-driver-distribution-tests</artifactId>
29+
<name>Apache Cassandra Java Driver - distribution tests</name>
30+
<dependencyManagement>
31+
<dependencies>
32+
<dependency>
33+
<groupId>${project.groupId}</groupId>
34+
<artifactId>java-driver-bom</artifactId>
35+
<version>${project.version}</version>
36+
<type>pom</type>
37+
<scope>import</scope>
38+
</dependency>
39+
</dependencies>
40+
</dependencyManagement>
41+
<dependencies>
42+
<dependency>
43+
<groupId>com.datastax.oss</groupId>
44+
<artifactId>java-driver-test-infra</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.datastax.oss</groupId>
49+
<artifactId>java-driver-query-builder</artifactId>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.datastax.oss</groupId>
54+
<artifactId>java-driver-mapper-processor</artifactId>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>com.datastax.oss</groupId>
59+
<artifactId>java-driver-mapper-runtime</artifactId>
60+
<scope>test</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>com.datastax.oss</groupId>
64+
<artifactId>java-driver-core</artifactId>
65+
<scope>test</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>com.datastax.oss</groupId>
69+
<artifactId>java-driver-metrics-micrometer</artifactId>
70+
<scope>test</scope>
71+
</dependency>
72+
<dependency>
73+
<groupId>com.datastax.oss</groupId>
74+
<artifactId>java-driver-metrics-microprofile</artifactId>
75+
<scope>test</scope>
76+
</dependency>
77+
<dependency>
78+
<groupId>junit</groupId>
79+
<artifactId>junit</artifactId>
80+
<scope>test</scope>
81+
</dependency>
82+
</dependencies>
83+
<build>
84+
<plugins>
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-surefire-plugin</artifactId>
88+
<configuration>
89+
<jvm>${testing.jvm}/bin/java</jvm>
90+
<argLine>${mockitoopens.argline}</argLine>
91+
<threadCount>1</threadCount>
92+
</configuration>
93+
</plugin>
94+
<plugin>
95+
<groupId>org.revapi</groupId>
96+
<artifactId>revapi-maven-plugin</artifactId>
97+
<configuration>
98+
<skip>true</skip>
99+
</configuration>
100+
</plugin>
101+
<plugin>
102+
<artifactId>maven-install-plugin</artifactId>
103+
<configuration>
104+
<skip>true</skip>
105+
</configuration>
106+
</plugin>
107+
<plugin>
108+
<artifactId>maven-deploy-plugin</artifactId>
109+
<configuration>
110+
<skip>true</skip>
111+
</configuration>
112+
</plugin>
113+
<plugin>
114+
<groupId>org.sonatype.plugins</groupId>
115+
<artifactId>nexus-staging-maven-plugin</artifactId>
116+
<configuration>
117+
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
118+
</configuration>
119+
</plugin>
120+
</plugins>
121+
</build>
122+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.datastax.oss.driver.api.core;
19+
20+
import static org.assertj.core.api.Assertions.assertThat;
21+
22+
import com.datastax.oss.driver.api.core.session.Session;
23+
import com.datastax.oss.driver.api.mapper.MapperBuilder;
24+
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
25+
import com.datastax.oss.driver.api.testinfra.CassandraResourceRule;
26+
import com.datastax.oss.driver.internal.core.util.Reflection;
27+
import com.datastax.oss.driver.internal.mapper.processor.MapperProcessor;
28+
import com.datastax.oss.driver.internal.metrics.micrometer.MicrometerMetricsFactory;
29+
import com.datastax.oss.driver.internal.metrics.microprofile.MicroProfileMetricsFactory;
30+
import org.junit.Test;
31+
32+
public class DriverDependencyTest {
33+
@Test
34+
public void should_include_core_jar() {
35+
assertThat(Reflection.loadClass(null, "com.datastax.oss.driver.api.core.session.Session"))
36+
.isEqualTo(Session.class);
37+
}
38+
39+
@Test
40+
public void should_include_query_builder_jar() {
41+
assertThat(Reflection.loadClass(null, "com.datastax.oss.driver.api.querybuilder.QueryBuilder"))
42+
.isEqualTo(QueryBuilder.class);
43+
}
44+
45+
@Test
46+
public void should_include_mapper_processor_jar() {
47+
assertThat(
48+
Reflection.loadClass(
49+
null, "com.datastax.oss.driver.internal.mapper.processor.MapperProcessor"))
50+
.isEqualTo(MapperProcessor.class);
51+
}
52+
53+
@Test
54+
public void should_include_mapper_runtime_jar() {
55+
assertThat(Reflection.loadClass(null, "com.datastax.oss.driver.api.mapper.MapperBuilder"))
56+
.isEqualTo(MapperBuilder.class);
57+
}
58+
59+
@Test
60+
public void should_include_metrics_micrometer_jar() {
61+
assertThat(
62+
Reflection.loadClass(
63+
null,
64+
"com.datastax.oss.driver.internal.metrics.micrometer.MicrometerMetricsFactory"))
65+
.isEqualTo(MicrometerMetricsFactory.class);
66+
}
67+
68+
@Test
69+
public void should_include_metrics_microprofile_jar() {
70+
assertThat(
71+
Reflection.loadClass(
72+
null,
73+
"com.datastax.oss.driver.internal.metrics.microprofile.MicroProfileMetricsFactory"))
74+
.isEqualTo(MicroProfileMetricsFactory.class);
75+
}
76+
77+
@Test
78+
public void should_include_test_infra_jar() {
79+
assertThat(
80+
Reflection.loadClass(
81+
null, "com.datastax.oss.driver.api.testinfra.CassandraResourceRule"))
82+
.isEqualTo(CassandraResourceRule.class);
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.datastax.oss.driver.api.core;
19+
20+
import static org.assertj.core.api.Assertions.assertThat;
21+
22+
import com.datastax.oss.driver.internal.core.util.Dependency;
23+
import com.datastax.oss.driver.internal.core.util.Reflection;
24+
import org.junit.Test;
25+
26+
public class OptionalDependencyTest {
27+
@Test
28+
public void should_not_include_snappy_jar() {
29+
Dependency.SNAPPY
30+
.classes()
31+
.forEach(clazz -> assertThat(Reflection.loadClass(null, clazz)).isNull());
32+
}
33+
34+
@Test
35+
public void should_not_include_l4z_jar() {
36+
Dependency.LZ4
37+
.classes()
38+
.forEach(clazz -> assertThat(Reflection.loadClass(null, clazz)).isNull());
39+
}
40+
41+
@Test
42+
public void should_not_include_esri_jar() {
43+
Dependency.ESRI
44+
.classes()
45+
.forEach(clazz -> assertThat(Reflection.loadClass(null, clazz)).isNull());
46+
}
47+
48+
@Test
49+
public void should_not_include_tinkerpop_jar() {
50+
Dependency.TINKERPOP
51+
.classes()
52+
.forEach(clazz -> assertThat(Reflection.loadClass(null, clazz)).isNull());
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.datastax.oss.driver.api.core;
19+
20+
import static org.assertj.core.api.Assertions.assertThat;
21+
22+
import com.datastax.oss.driver.internal.core.util.Reflection;
23+
import org.junit.Test;
24+
25+
public class ProvidedDependencyTest {
26+
@Test
27+
public void should_not_include_graal_sdk_jar() {
28+
assertThat(Reflection.loadClass(null, "org.graalvm.nativeimage.VMRuntime")).isNull();
29+
}
30+
31+
@Test
32+
public void should_not_include_spotbugs_annotations_jar() {
33+
assertThat(Reflection.loadClass(null, "edu.umd.cs.findbugs.annotations.NonNull")).isNull();
34+
}
35+
36+
@Test
37+
public void should_not_include_jicp_annotations_jar() {
38+
assertThat(Reflection.loadClass(null, "net.jcip.annotations.ThreadSafe")).isNull();
39+
}
40+
41+
@Test
42+
public void should_not_include_blockhound_jar() {
43+
assertThat(Reflection.loadClass(null, "reactor.blockhound.BlockHoundRuntime")).isNull();
44+
}
45+
}

examples/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@
142142
<groupId>io.projectreactor</groupId>
143143
<artifactId>reactor-core</artifactId>
144144
</dependency>
145+
<dependency>
146+
<groupId>com.github.spotbugs</groupId>
147+
<artifactId>spotbugs-annotations</artifactId>
148+
<scope>provided</scope>
149+
</dependency>
145150
</dependencies>
146151
<build>
147152
<plugins>

integration-tests/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@
8383
<artifactId>java-driver-metrics-microprofile</artifactId>
8484
<scope>test</scope>
8585
</dependency>
86+
<dependency>
87+
<groupId>com.github.stephenc.jcip</groupId>
88+
<artifactId>jcip-annotations</artifactId>
89+
<scope>test</scope>
90+
</dependency>
8691
<dependency>
8792
<groupId>com.github.spotbugs</groupId>
8893
<artifactId>spotbugs-annotations</artifactId>

manual/core/integration/README.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -610,25 +610,22 @@ The driver team uses annotations to document certain aspects of the code:
610610
* nullability with [SpotBugs](https://spotbugs.github.io/) annotations `@Nullable` and `@NonNull`.
611611

612612
This is mostly used during development; while these annotations are retained in class files, they
613-
serve no purpose at runtime. If you want to minimize the number of JARs in your classpath, you can
614-
exclude them:
613+
serve no purpose at runtime. This class is an optional dependency of the driver. If you wish to
614+
make use of these annotations in your own code you have to explicitly depend on these jars:
615615

616616
```xml
617-
<dependency>
618-
<groupId>com.datastax.oss</groupId>
619-
<artifactId>java-driver-core</artifactId>
620-
<version>${driver.version}</version>
621-
<exclusions>
622-
<exclusion>
623-
<groupId>com.github.stephenc.jcip</groupId>
624-
<artifactId>jcip-annotations</artifactId>
625-
</exclusion>
626-
<exclusion>
627-
<groupId>com.github.spotbugs</groupId>
628-
<artifactId>spotbugs-annotations</artifactId>
629-
</exclusion>
630-
</exclusions>
631-
</dependency>
617+
<dependencies>
618+
<dependency>
619+
<groupId>com.github.stephenc.jcip</groupId>
620+
<artifactId>jcip-annotations</artifactId>
621+
<version>1.0-1</version>
622+
</dependency>
623+
<dependency>
624+
<groupId>com.github.spotbugs</groupId>
625+
<artifactId>spotbugs-annotations</artifactId>
626+
<version>3.1.12</version>
627+
</dependency>
628+
</dependencies>
632629
```
633630

634631
However, there is one case when excluding those dependencies won't work: if you use [annotation

0 commit comments

Comments
 (0)