Skip to content

Commit

Permalink
Merge pull request #98 from Aiven-Open/jeqo/bump-gradle
Browse files Browse the repository at this point in the history
chore: bump gradle and fix version loading
  • Loading branch information
eliax1996 authored Mar 13, 2024
2 parents 3a4f2a7 + 6d3eb0d commit e7bcbc8
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 64 deletions.
88 changes: 47 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* limitations under the License.
*/

import org.gradle.util.DistributionLocator
import org.gradle.util.GradleVersion

plugins {

// https://docs.gradle.org/current/userguide/java_library_plugin.html
Expand All @@ -40,25 +37,33 @@ repositories {
mavenCentral()
}

group = "io.aiven"

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

withJavadocJar()
withSourcesJar()
}

wrapper {
distributionType = 'ALL'
doLast {
final DistributionLocator locator = new DistributionLocator()
final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
final URI distributionUri = locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
final URI sha256Uri = new URI(distributionUri.toString() + ".sha256")
final String sha256Sum = new String(sha256Uri.toURL().bytes)
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
def sha256Sum = new String(new URL("${distributionUrl}.sha256").bytes)
propertiesFile << "distributionSha256Sum=${sha256Sum}\n"
println "Added checksum to wrapper properties"
}
}

ext {
kafkaVersion = "2.2.0"
slf4jVersion = "1.7.36"
elasticSearchVersion = "2.4.1"
luceneVersion = "5.5.2"
jestVersion = "6.3.1"
}

compileJava {
options.compilerArgs = ['-Xlint:all', '-Werror']
}
Expand All @@ -72,6 +77,32 @@ jacoco {
toolVersion = "0.8.7"
}

dependencies {
compileOnly "org.apache.kafka:connect-api:$kafkaVersion"
compileOnly "org.apache.kafka:connect-json:$kafkaVersion"

implementation "org.slf4j:slf4j-api:$slf4jVersion"
implementation "io.searchbox:jest:$jestVersion"

testImplementation("junit:junit:4.13.2") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
testImplementation "org.hamcrest:hamcrest-all:1.3"
testImplementation "org.mockito:mockito-core:5.4.0"
testImplementation "org.mockito:mockito-all:1.10.19"

testImplementation "org.apache.kafka:connect-api:$kafkaVersion"
testImplementation "org.apache.kafka:connect-json:$kafkaVersion"
testImplementation "org.apache.lucene:lucene-test-framework:$luceneVersion"
testImplementation "com.fasterxml.jackson.core:jackson-core:2.15.2"
testImplementation "com.fasterxml.jackson.core:jackson-databind:2.15.2"
testImplementation "com.fasterxml.jackson.core:jackson-annotations:2.15.2"
testImplementation "org.elasticsearch:elasticsearch:$elasticSearchVersion:tests"
testImplementation "org.elasticsearch:elasticsearch:$elasticSearchVersion"
testImplementation "org.apache.lucene:lucene-expressions:$luceneVersion"
testRuntimeOnly "org.slf4j:slf4j-log4j12:$slf4jVersion"
}

distributions {
main {
contents {
Expand Down Expand Up @@ -122,46 +153,21 @@ publishing {
}
}

ext {
kafkaVersion = "2.2.0"
slf4jVersion = "1.7.36"
elasticSearchVersion = "2.4.1"
luceneVersion = "5.5.2"
jestVersion = "6.3.1"
}

processResources {
filesMatching('elasticsearch-connector-for-apache-kafka-version.properties') {
expand(version: version)
}
}

dependencies {
compileOnly "org.apache.kafka:connect-api:$kafkaVersion"
compileOnly "org.apache.kafka:connect-json:$kafkaVersion"

implementation "org.slf4j:slf4j-api:$slf4jVersion"
implementation "io.searchbox:jest:$jestVersion"

testImplementation("junit:junit:4.13.2") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
jar {
manifest {
attributes(
'Version': "${project.version}"
)
}
testImplementation "org.hamcrest:hamcrest-all:1.3"
testImplementation "org.mockito:mockito-core:5.11.0"
testImplementation "org.mockito:mockito-all:1.10.19"

testImplementation "org.apache.kafka:connect-api:$kafkaVersion"
testImplementation "org.apache.kafka:connect-json:$kafkaVersion"
testImplementation "org.apache.lucene:lucene-test-framework:$luceneVersion"
testImplementation "com.fasterxml.jackson.core:jackson-core:2.15.2"
testImplementation "com.fasterxml.jackson.core:jackson-databind:2.15.2"
testImplementation "com.fasterxml.jackson.core:jackson-annotations:2.15.2"
testImplementation "org.elasticsearch:elasticsearch:$elasticSearchVersion:tests"
testImplementation "org.elasticsearch:elasticsearch:$elasticSearchVersion"
testImplementation "org.apache.lucene:lucene-expressions:$luceneVersion"
testRuntimeOnly "org.slf4j:slf4j-log4j12:$slf4jVersion"
}


test {

//we do not need to check classpath hell for testing
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
group=io.aiven
version=6.2.0-SNAPSHOT
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionSha256Sum=f2b9ed0faf8472cbe469255ae6c86eddb77076c75191741b4a462f33128dd419
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=cd5c2958a107ee7f0722004a12d0f8559b4564c34daad7df06cffd4d12a426d0
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ElasticsearchSinkConnector extends SinkConnector {

@Override
public String version() {
return Version.getVersion();
return Version.VERSION;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ElasticsearchSinkTask extends SinkTask {

@Override
public String version() {
return Version.getVersion();
return Version.VERSION;
}

@Override
Expand Down
21 changes: 8 additions & 13 deletions src/main/java/io/aiven/connect/elasticsearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,18 @@

public class Version {
private static final Logger log = LoggerFactory.getLogger(Version.class);
private static String version = "unknown";
private static final String PROPERTIES_FILENAME = "elasticsearch-connector-for-apache-kafka-version.properties";

private static final String VERSION_FILE = "/aiven-kafka-connect-elasticsearch-version.properties";
static final String VERSION;

static {
try {
final Properties props = new Properties();
try (InputStream versionFileStream = Version.class.getResourceAsStream(VERSION_FILE)) {
props.load(versionFileStream);
version = props.getProperty("version", version).trim();
}
final Properties props = new Properties();
try (final InputStream resourceStream =
Version.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME)) {
props.load(resourceStream);
} catch (final Exception e) {
log.warn("Error while loading version:", e);
log.warn("Error while loading {}: {}", PROPERTIES_FILENAME, e.getMessage());
}
}

public static String getVersion() {
return version;
VERSION = props.getProperty("version", "unknown").trim();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
##
# Copyright 2019 Aiven Oy
# Copyright 2016 Confluent Inc.
# Copyright 2020 Aiven Oy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
##
version=${version ?: 'unknown'}
version=${version ?: 'unknown'}
2 changes: 0 additions & 2 deletions version.txt

This file was deleted.

0 comments on commit e7bcbc8

Please sign in to comment.