Skip to content

Commit

Permalink
Instructions for using Aiven's JDBC connector (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
hariso authored Nov 27, 2023
1 parent aa1e59c commit ed9d5ce
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# Not available in a public Maven repo,
# so we need to provide a pre-built artifact,
# and install to the local Maven repo.
run: mvn install:install-file -Dfile=libs/jdbc-connector-for-apache-kafka-6.7.0.jar -DgroupId=io.aiven -DartifactId=jdbc-connector-for-apache-kafka -Dversion=6.7.0 -Dpackaging=jar
run: mvn install:install-file -Dfile=libs/jdbc-connector-for-apache-kafka-6.8.0.jar -DgroupId=io.aiven -DartifactId=jdbc-connector-for-apache-kafka -Dversion=6.8.0 -Dpackaging=jar

- name: Test and analyze
env:
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Install test library to local Maven repo
# Not available in a public Maven repo, so we need to provide a pre-built artifact,
# and install to the local Maven repo.
run: mvn install:install-file -Dfile=libs/jdbc-connector-for-apache-kafka-6.7.0.jar -DgroupId=io.aiven -DartifactId=jdbc-connector-for-apache-kafka -Dversion=6.7.0 -Dpackaging=jar
run: mvn install:install-file -Dfile=libs/jdbc-connector-for-apache-kafka-6.8.0.jar -DgroupId=io.aiven -DartifactId=jdbc-connector-for-apache-kafka -Dversion=6.8.0 -Dpackaging=jar

- name: Run integration tests
run: mvn integration-test verify
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ when the project is compiled.

In a few integration tests we use [Aiven's JDBC connector](https://github.com/aiven/jdbc-connector-for-apache-kafka).
Since it's not available in public Maven repositories, it needs to be compiled and installed to a local Maven repository,
so it can be used. For convenience, we provide a prebuilt JAR (in the `libs` directory).
so it can be used. A script is included in this repository which lets you clone and build the correct version of the
connector. It can be run like this `./scripts/get-jdbc-connector.sh /path/to/repositories/`.

1. Run `mvn install:install-file -Dfile=libs/jdbc-connector-for-apache-kafka-6.7.0.jar -DgroupId=io.aiven -DartifactId=jdbc-connector-for-apache-kafka -Dversion=6.7.0 -Dpackaging=jar`
2. Run `mvn clean compile` (so that the needed code is generated)
3. Some IDEs may not automatically use the generated sources. If that's the case, you need to change the project settings in your IDE to include the generated source. In IntelliJ, for example, you do that by going
to File > Project structure > Project Settings > Modules. Then, right-click on `target/generated-source` and select "Sources".
After that, run `mvn clean compile` (this also generates needed code from proto files). Some IDEs may not automatically
use the generated sources. If that's the case, you need to change the project settings in your IDE to include the
generated source. In IntelliJ, for example, you do that by going to File > Project structure > Project Settings > Modules.
Then, right-click on `target/generated-source` and select "Sources".

### Code quality
Code analysis is done through SonarCloud, where we have a [conduitio](https://sonarcloud.io/project/overview?id=conduit-kafka-connect-wrapper) organization.
Expand Down
Binary file removed libs/jdbc-connector-for-apache-kafka-6.7.0.jar
Binary file not shown.
Binary file added libs/jdbc-connector-for-apache-kafka-6.8.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<dependency>
<groupId>io.aiven</groupId>
<artifactId>jdbc-connector-for-apache-kafka</artifactId>
<version>6.7.0</version>
<version>6.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
55 changes: 55 additions & 0 deletions scripts/get-jdbc-connector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

#
# Copyright 2022 Meroxa, Inc.
#
# 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.
#

# Function to extract the version from pom.xml
get_version() {
local version
version=$(grep -A 2 '<artifactId>jdbc-connector-for-apache-kafka</artifactId>' pom.xml | grep '<version>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
echo "$version"
}

# Check if the required input directory is provided
if [ -z "$1" ]; then
echo "Usage: $0 <output_directory>"
exit 1
fi

output_directory=$1

# Get the version from pom.xml
version=$(get_version)

if [ -z "$version" ]; then
echo "Error: Version not found in pom.xml"
exit 1
fi

# Clone the repository with the specified version
repo_url="[email protected]:Aiven-Open/jdbc-connector-for-apache-kafka.git"
clone_url="$repo_url"

echo "Cloning repository $clone_url into $output_directory..."
git clone "$clone_url" "$output_directory/jdbc-connector-for-apache-kafka"

cd "$output_directory/jdbc-connector-for-apache-kafka" || exit

git checkout "tags/v$version"

./gradlew clean build publishToMavenLocal -x test

echo "Done."

0 comments on commit ed9d5ce

Please sign in to comment.