Skip to content

Commit

Permalink
Merge branch 'master' into pil0txia/admin_4847
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed May 23, 2024
2 parents a1bb519 + 9e4e87f commit ec4f10b
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 29 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ buildscript {

plugins {
id 'org.cyclonedx.bom' version '1.8.2'
id 'com.github.jk1.dependency-license-report' version '2.6'
id 'com.github.jk1.dependency-license-report' version '2.7'
}

// Remove doclint warnings that pollute javadoc logs when building
Expand Down Expand Up @@ -653,7 +653,7 @@ subprojects {
dependencyManagement {
dependencies {
dependency "org.apache.commons:commons-lang3:3.6"
dependency "org.apache.commons:commons-collections4:4.1"
dependency "org.apache.commons:commons-collections4:4.4"
dependency "org.apache.commons:commons-text:1.9"

dependency "commons-io:commons-io:2.11.0"
Expand Down Expand Up @@ -699,9 +699,9 @@ subprojects {

dependency "com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0"
dependency "com.mebigfatguy.fb-contrib:fb-contrib:7.6.0"
dependency "com.jayway.jsonpath:json-path:2.7.0"
dependency "com.jayway.jsonpath:json-path:2.9.0"

dependency "org.springframework.boot:spring-boot-starter-web:2.7.10"
dependency "org.springframework.boot:spring-boot-starter-web:2.7.18"
dependency "io.openmessaging:registry-server:0.0.1"

dependency "org.junit.jupiter:junit-jupiter:5.6.0"
Expand All @@ -725,14 +725,14 @@ subprojects {
dependency "javax.annotation:javax.annotation-api:1.3.2"

dependency "com.github.seancfoley:ipaddress:5.3.3"
dependency "com.google.code.gson:gson:2.8.2"
dependency "com.google.code.gson:gson:2.11.0"

dependency "org.yaml:snakeyaml:1.30"
dependency "org.javassist:javassist:3.30.2-GA"

dependency "com.alibaba.nacos:nacos-client:2.2.3"

dependency 'org.apache.zookeeper:zookeeper:3.7.1'
dependency 'org.apache.zookeeper:zookeeper:3.9.2'
dependency 'org.apache.curator:curator-client:5.4.0'
dependency 'org.apache.curator:curator-framework:5.4.0'
dependency 'org.apache.curator:curator-recipes:5.4.0'
Expand All @@ -743,7 +743,7 @@ subprojects {
dependency "javax.annotation:javax.annotation-api:1.3.2"
dependency "com.alibaba.fastjson2:fastjson2:2.0.48"

dependency "software.amazon.awssdk:s3:2.20.29"
dependency "software.amazon.awssdk:s3:2.25.55"
dependency "com.github.rholder:guava-retrying:2.0.0"
}
}
Expand Down
6 changes: 3 additions & 3 deletions eventmesh-connectors/eventmesh-connector-kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

dependencies {
implementation project(":eventmesh-openconnect:eventmesh-openconnect-java")
implementation 'io.cloudevents:cloudevents-kafka:2.4.2'
implementation 'org.apache.kafka:kafka-clients:3.0.0'
implementation 'io.cloudevents:cloudevents-kafka:2.5.0'
implementation 'org.apache.kafka:kafka-clients:3.6.2'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation project(":eventmesh-openconnect:eventmesh-openconnect-java")
implementation project(":eventmesh-common")

implementation 'org.mongodb:mongodb-driver:3.12.11'
implementation 'org.mongodb:mongodb-driver:3.12.14'

implementation 'io.cloudevents:cloudevents-json-jackson'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies {
implementation project(":eventmesh-sdks:eventmesh-sdk-java")
implementation project(":eventmesh-openconnect:eventmesh-openconnect-java")

implementation "com.slack.api:bolt:1.1.+"
implementation "com.slack.api:bolt:1.39.+"
implementation 'com.google.guava:guava'

compileOnly 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,137 @@

package org.apache.eventmesh.runtime.constants;

import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.CodeSource;
import java.util.Objects;
import java.util.Properties;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class EventMeshVersion {

public static final String CURRENT_VERSION = Version.V3_0_0.name();
private static String CURRENT_VERSION = "";

private static final String VERSION_KEY = "Implementation-Version";

private static final String SPEC_VERSION_KEY = "Specification-Version";

/**
* The version pattern in build.gradle. In general, it is like version='0.0.1' or version="0.0.1" if exists.
*/
private static final String VERSION_PATTERN = "version\\s*=\\s*['\"](.+)['\"]";

/**
* @return Eg: "v0.0.1-release"
*/
public static String getCurrentVersionDesc() {
return CURRENT_VERSION.replace("V", "")
.replace("_", ".")
.replace("_SNAPSHOT", "-SNAPSHOT");
if (StringUtils.isNotBlank(getCurrentVersion())) {
return "v" + CURRENT_VERSION;
}
return "";
}

/**
* @return Eg: "0.0.1-release"
*/
public static String getCurrentVersion() {
if (StringUtils.isNotBlank(CURRENT_VERSION)) {
return CURRENT_VERSION;
}
// get version from jar.
getVersionFromJarFile();
// get version from build file.
if (StringUtils.isBlank(CURRENT_VERSION)) {
getVersionFromBuildFile();
}
return CURRENT_VERSION;
}

private static void getVersionFromJarFile() {
// get version from MANIFEST.MF in jar.
CodeSource codeSource = EventMeshVersion.class.getProtectionDomain().getCodeSource();
if (Objects.isNull(codeSource)) {
log.warn("Failed to get CodeSource for EventMeshVersion.class");
return;
}
URL url = codeSource.getLocation();
if (Objects.isNull(url)) {
log.warn("Failed to get URL for EventMeshVersion.class");
return;
}
try (JarFile jarFile = new JarFile(url.getPath())) {
Manifest manifest = jarFile.getManifest();
Attributes attributes = manifest.getMainAttributes();
CURRENT_VERSION = StringUtils.isBlank(attributes.getValue(VERSION_KEY))
? attributes.getValue(SPEC_VERSION_KEY) : attributes.getValue(VERSION_KEY);

// get version from the file name of jar.
if (StringUtils.isBlank(CURRENT_VERSION)) {
getVersionFromJarFileName(url.getFile());
}
} catch (IOException e) {
log.error("Failed to load project version from MANIFEST.MF due to IOException {}.", e.getMessage());
}
}

private static void getVersionFromBuildFile() {
String projectDir = System.getProperty("user.dir");

String gradlePropertiesPath = projectDir + File.separator + "gradle.properties";
Properties properties = new Properties();
try (FileInputStream fis = new FileInputStream(gradlePropertiesPath)) {
properties.load(fis);
CURRENT_VERSION = properties.getProperty("version");
} catch (IOException e) {
log.error("Failed to load version from gradle.properties due to IOException {}.", e.getMessage());
}

if (StringUtils.isBlank(CURRENT_VERSION)) {
String buildGradlePath = projectDir + File.separator + "build.gradle";
try {
File buildFile = new File(buildGradlePath);
String content = new String(Files.readAllBytes(buildFile.toPath()));
Pattern pattern = Pattern.compile(VERSION_PATTERN);
Matcher matcher = pattern.matcher(content);
if (matcher.find()) {
CURRENT_VERSION = matcher.group(1);
} else {
log.warn("Failed to load version from build.gradle due to missing the configuration of \"version='xxx'\".");
}
} catch (IOException e) {
log.error("Failed to load version from build.gradle due to IOException {}.", e.getMessage());
}
}
}

public enum Version {
V3_0_0,
V3_0_1,
V3_1_0,
V3_2_0,
V3_3_0
// path: /.../.../eventmesh-runtime-0.0.1-xxx.jar, version: 0.0.1-xxx
private static void getVersionFromJarFileName(String path) {
if (!StringUtils.isEmpty(path) && path.endsWith(".jar")) {
Path filePath = Paths.get(path);
String fileName = filePath.getFileName().toString();
fileName = fileName.replace(".jar", "");
Pattern pattern = Pattern.compile("-\\d");
Matcher matcher = pattern.matcher(fileName);
if (matcher.find()) {
int index = matcher.start();
CURRENT_VERSION = fileName.substring(index + 1);
} else {
log.info("Failed to load version from jar name due to missing related info.");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

package org.apache.eventmesh.runtime.util;

import static org.apache.eventmesh.runtime.constants.EventMeshVersion.getCurrentVersionDesc;

import org.apache.commons.lang3.StringUtils;

import lombok.extern.slf4j.Slf4j;

/**
Expand Down Expand Up @@ -45,11 +49,12 @@ public class BannerUtil {
+ " MEMEMEMEMEMEMEMEMEMEMEMEMEMEME EMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEME";

private static final String LOGONAME =
" ____ _ __ __ _ " + System.lineSeparator()
+ " / ____|_ _____ _ __ | |_| \\/ | ___ ___| |__ " + System.lineSeparator()
+ " | __|\\ \\ / / _ | '_ \\| __| |\\/| |/ _ |/ __| '_ \\ " + System.lineSeparator()
+ " | |___ \\ V / __| | | | |_| | | | __|\\__ \\ | | |" + System.lineSeparator()
+ " \\ ____| \\_/ \\___|_| |_|\\__|_| |_|\\___||___/_| |_|";
" ____ _ __ __ _ " + System.lineSeparator()
+ " / ____|_ _____ _ __ | |_| \\/ | ___ ___| |__ " + System.lineSeparator()
+ " | __|\\ \\ / / _ | '_ \\| __| |\\/| |/ _ |/ __| '_ \\ " + System.lineSeparator()
+ " | |___ \\ V / __| | | | |_| | | | __|\\__ \\ | | |" + System.lineSeparator()
+ " \\ ____| \\_/ \\___|_| |_|\\__|_| |_|\\___||___/_| |_| "
+ (StringUtils.isNotBlank(getCurrentVersionDesc()) ? "(" + getCurrentVersionDesc() + ")" : "");

public static void generateBanner() {
String banner =
Expand Down
4 changes: 2 additions & 2 deletions eventmesh-storage-plugin/eventmesh-storage-kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ dependencies {
implementation project(":eventmesh-storage-plugin:eventmesh-storage-api")
implementation project(":eventmesh-common")
// https://mavenlibs.com/maven/dependency/io.cloudevents/cloudevents-kafka
implementation group: 'io.cloudevents', name: 'cloudevents-kafka', version: '2.4.2'
implementation group: 'io.cloudevents', name: 'cloudevents-kafka', version: '2.5.0'

// https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients
implementation 'org.apache.kafka:kafka-clients:3.0.0'
implementation 'org.apache.kafka:kafka-clients:3.6.2'

testImplementation 'org.junit.jupiter:junit-jupiter:5.6.0'

Expand Down

0 comments on commit ec4f10b

Please sign in to comment.