Skip to content

Commit

Permalink
Move DataStax shaded Guava module into Java driver
Browse files Browse the repository at this point in the history
patch by Lukasz Antoniak; reviewed by Alexandre Dutra and Erik Merkle for CASSJAVA-52

Update pom.xml

Co-authored-by: Alexandre Dutra <[email protected]>
  • Loading branch information
lukasz-antoniak and adutra committed Nov 15, 2024
1 parent 7877837 commit 3ef49df
Show file tree
Hide file tree
Showing 15 changed files with 351 additions and 21 deletions.
10 changes: 5 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<artifactId>java-driver-query-builder</artifactId>
<version>4.18.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>java-driver-guava-shaded</artifactId>
<version>4.18.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>java-driver-test-infra</artifactId>
Expand All @@ -75,11 +80,6 @@
<artifactId>native-protocol</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-shaded-guava</artifactId>
<version>25.1-jre-graal-sub-1</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
Expand Down
4 changes: 2 additions & 2 deletions core-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
<artifactId>native-protocol</artifactId>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-shaded-guava</artifactId>
<groupId>org.apache.cassandra</groupId>
<artifactId>java-driver-guava-shaded</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
Expand Down
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<artifactId>netty-handler</artifactId>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-shaded-guava</artifactId>
<groupId>org.apache.cassandra</groupId>
<artifactId>java-driver-guava-shaded</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
Expand Down
6 changes: 3 additions & 3 deletions distribution/src/assembly/binary-tarball.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<exclude>org.apache.cassandra:java-driver-core</exclude>
<exclude>org.apache.cassandra:java-driver-mapper-runtime</exclude>
<exclude>org.apache.cassandra:java-driver-mapper-processor</exclude>
<exclude>org.apache.cassandra:java-driver-guava-shaded</exclude>
<!-- Don't reinclude dependencies that core also has -->
<exclude>com.datastax.oss:java-driver-shaded-guava</exclude>
<exclude>com.github.stephenc.jcip:jcip-annotations</exclude>
<exclude>com.github.spotbugs:spotbugs-annotations</exclude>
</excludes>
Expand All @@ -91,8 +91,8 @@
<exclude>org.apache.cassandra:java-driver-core</exclude>
<exclude>org.apache.cassandra:java-driver-query-builder</exclude>
<exclude>org.apache.cassandra:java-driver-mapper-processor</exclude>
<exclude>org.apache.cassandra:java-driver-guava-shaded</exclude>
<!-- Don't reinclude dependencies that core also has -->
<exclude>com.datastax.oss:java-driver-shaded-guava</exclude>
<exclude>com.github.stephenc.jcip:jcip-annotations</exclude>
<exclude>com.github.spotbugs:spotbugs-annotations</exclude>
</excludes>
Expand All @@ -116,8 +116,8 @@
<exclude>org.apache.cassandra:java-driver-core</exclude>
<exclude>org.apache.cassandra:java-driver-query-builder</exclude>
<exclude>org.apache.cassandra:java-driver-mapper-runtime</exclude>
<exclude>org.apache.cassandra:java-driver-guava-shaded</exclude>
<!-- Don't reinclude dependencies that core also has -->
<exclude>com.datastax.oss:java-driver-shaded-guava</exclude>
<exclude>com.github.stephenc.jcip:jcip-annotations</exclude>
<exclude>com.github.spotbugs:spotbugs-annotations</exclude>
</excludes>
Expand Down
215 changes: 215 additions & 0 deletions guava-shaded/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.cassandra</groupId>
<artifactId>java-driver-parent</artifactId>
<version>4.18.2-SNAPSHOT</version>
</parent>
<artifactId>java-driver-guava-shaded</artifactId>
<name>Apache Cassandra Java Driver - guava shaded dep</name>
<description>Shaded Guava artifact for use in the Java driver for Apache Cassandra®</description>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>20.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>shade-guava-dependency</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.apache.cassandra:java-driver-guava-shaded</include>
<include>com.google.guava:guava</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.datastax.oss.driver.shaded.guava</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>com.google.guava:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
<createSourcesJar>true</createSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-classes</id>
<phase>package</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<directory>${project.build.outputDirectory}</directory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-shaded-classes</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>org.apache.cassandra</groupId>
<artifactId>java-driver-guava-shaded</artifactId>
<version>${project.version}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<!--
Using later version of the plugin will scan all dynamically loaded classes
with Class.forName(). In the end, more packages will be imported in MANIFEST.MF
and OSGi integration tests will break.
-->
<version>3.5.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>generate-shaded-manifest</id>
<phase>package</phase>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Bundle-SymbolicName>com.datastax.oss.driver.shaded.guava</Bundle-SymbolicName>
<Export-Package>!com.datastax.oss.driver.shaded.guava.errorprone.*, !org.checkerframework.*, *</Export-Package>
<Import-Package>javax.annotation.*;resolution:=optional;version="[3.0,4)", javax.crypto.*;resolution:=optional, sun.misc.*;resolution:=optional, !com.oracle.svm.*, !com.datastax.oss.driver.shaded.guava.errorprone.*, !org.checkerframework.*, *</Import-Package>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>generate-final-shaded-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<!-- this is the manifest generated by the bundle plugin -->
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<descriptors>
<descriptor>src/assembly/shaded-jar.xml</descriptor>
</descriptors>
<!-- Replace the original artifact -->
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>empty-javadoc-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>javadoc</classifier>
<classesDirectory>${basedir}/src/main/javadoc</classesDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
48 changes: 48 additions & 0 deletions guava-shaded/src/assembly/shaded-jar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>shaded-jar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!--
Include everything from the shaded jar created with the shade plugin and
unpacked by the dependency plugin
-->
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<excludes>
<exclude>META-INF/maven/org.apache.cassandra/java-driver-guava-shaded/pom.xml</exclude>
</excludes>
<outputDirectory/>
</fileSet>
</fileSets>
<!-- Include the transformed pom with shaded deps created by the shade plugin -->
<files>
<file>
<source>${project.basedir}/dependency-reduced-pom.xml</source>
<outputDirectory>META-INF/maven/org.apache.cassandra/java-driver-guava-shaded</outputDirectory>
<destName>pom.xml</destName>
</file>
</files>
</assembly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package com.google.common.primitives;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import java.util.Comparator;

@TargetClass(UnsignedBytes.LexicographicalComparatorHolder.class)
final class LexicographicalComparatorHolderSubstitution {

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
static Comparator<byte[]> BEST_COMPARATOR = UnsignedBytes.lexicographicalComparatorJavaImpl();

/* All known cases should be covered by the field substitution above... keeping this only
* for sake of completeness */
@Substitute
static Comparator<byte[]> getBestComparator() {
return UnsignedBytes.lexicographicalComparatorJavaImpl();
}
}
Loading

0 comments on commit 3ef49df

Please sign in to comment.