Update 2026.11.06-01
This commit is contained in:
parent
7ee35194be
commit
ba557628e3
1
.gitignore
vendored
1
.gitignore
vendored
@ -44,5 +44,4 @@ bin/
|
|||||||
|
|
||||||
### Weapie ###
|
### Weapie ###
|
||||||
/**/config
|
/**/config
|
||||||
/**/src/test
|
|
||||||
/**/tmp
|
/**/tmp
|
||||||
|
|||||||
@ -3,44 +3,57 @@ import org.gradle.api.credentials.PasswordCredentials
|
|||||||
plugins {
|
plugins {
|
||||||
id("java-library")
|
id("java-library")
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("com.github.johnrengelman.shadow") version("8.1.1")
|
alias(libs.plugins.shadow)
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java-library")
|
apply(plugin = "java-library")
|
||||||
apply(plugin = "maven-publish")
|
apply(plugin = "maven-publish")
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "com.gradleup.shadow")
|
||||||
|
|
||||||
group = "de.weapie"
|
group = "de.weapie"
|
||||||
version = "2024.07.12-01"
|
version = "2026.11.06-01"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(rootProject.libs.lombok)
|
compileOnly(rootProject.libs.lombok)
|
||||||
annotationProcessor(rootProject.libs.lombok)
|
annotationProcessor(rootProject.libs.lombok)
|
||||||
|
|
||||||
implementation(rootProject.libs.annotations)
|
compileOnlyApi(rootProject.libs.annotations)
|
||||||
annotationProcessor(rootProject.libs.annotations)
|
|
||||||
|
|
||||||
testAnnotationProcessor(rootProject.libs.lombok)
|
testAnnotationProcessor(rootProject.libs.lombok)
|
||||||
testImplementation(rootProject.libs.lombok)
|
testCompileOnly(rootProject.libs.lombok)
|
||||||
|
testImplementation(platform(rootProject.libs.junit.bom))
|
||||||
|
testImplementation(rootProject.libs.junit.jupiter)
|
||||||
|
testRuntimeOnly(rootProject.libs.junit.launcher)
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<JavaCompile> {
|
tasks.withType<JavaCompile> {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17.toString()
|
options.release.set(17)
|
||||||
targetCompatibility = JavaVersion.VERSION_17.toString()
|
|
||||||
// options
|
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.isIncremental = true
|
options.isIncremental = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test>().configureEach {
|
||||||
|
useJUnitPlatform()
|
||||||
|
testLogging {
|
||||||
|
events("passed", "skipped", "failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = "jfHomeRepoPrivate"
|
name = "repo"
|
||||||
url = uri("https://repo.jf.home/private")
|
url = uri("https://repo.jf.home/private")
|
||||||
credentials(PasswordCredentials::class)
|
credentials(PasswordCredentials::class)
|
||||||
authentication {
|
authentication {
|
||||||
@ -59,8 +72,11 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.shadowJar {
|
tasks.shadowJar {
|
||||||
archiveBaseName.set("${project.name}")
|
archiveClassifier.set("all")
|
||||||
archiveVersion.set("${project.version}")
|
filesMatching("META-INF/services/**") {
|
||||||
archiveFileName.set("${archiveBaseName.get()}-${archiveVersion.get()}.jar")
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
mergeServiceFiles()
|
||||||
|
exclude("META-INF/*.SF", "META-INF/*.RSA", "META-INF/*.DSA")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,27 +1,13 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.mongodb)
|
api(libs.mongodb)
|
||||||
implementation(libs.mysql)
|
implementation(libs.mysql)
|
||||||
implementation(libs.postgres)
|
implementation(libs.postgres)
|
||||||
implementation(libs.sqlite)
|
implementation(libs.sqlite)
|
||||||
|
|
||||||
compileOnly(libs.gson)
|
|
||||||
api(project(":devlok-utils"))
|
api(project(":devlok-utils"))
|
||||||
api(project(":devlok-files"))
|
api(project(":devlok-files"))
|
||||||
|
|
||||||
testImplementation(libs.gson)
|
|
||||||
testImplementation(platform("org.junit:junit-bom:5.10.2"))
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
dependsOn(":devlok-utils:shadowJar")
|
|
||||||
dependsOn(":devlok-files:shadowJar")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
useJUnitPlatform()
|
dependsOn(tasks.shadowJar)
|
||||||
testLogging {
|
systemProperty("devlok.shadowJar", tasks.shadowJar.get().archiveFile.get().asFile.absolutePath)
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package de.weapie.devlok.database.mongodb;
|
package de.weapie.devlok.database.mongodb;
|
||||||
|
|
||||||
import com.mongodb.MongoClient;
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoClients;
|
||||||
import com.mongodb.MongoClientSettings;
|
import com.mongodb.MongoClientSettings;
|
||||||
import com.mongodb.MongoCredential;
|
import com.mongodb.MongoCredential;
|
||||||
import com.mongodb.ServerAddress;
|
import com.mongodb.ServerAddress;
|
||||||
@ -44,12 +45,11 @@ public class MongoDBDatabase extends BasicDatabase {
|
|||||||
this.password.toCharArray()
|
this.password.toCharArray()
|
||||||
);
|
);
|
||||||
|
|
||||||
this.mongoClient = new MongoClient(
|
this.mongoClient = MongoClients.create(MongoClientSettings.builder()
|
||||||
new ServerAddress(
|
.applyToClusterSettings(settings -> settings.hosts(List.of(new ServerAddress(this.host, this.port))))
|
||||||
this.host,
|
.credential(mongoCredential)
|
||||||
this.port
|
.uuidRepresentation(org.bson.UuidRepresentation.JAVA_LEGACY)
|
||||||
), List.of(mongoCredential)
|
.build());
|
||||||
);
|
|
||||||
|
|
||||||
CodecRegistry pojoCodecRegistry = CodecRegistries.fromRegistries(
|
CodecRegistry pojoCodecRegistry = CodecRegistries.fromRegistries(
|
||||||
MongoClientSettings.getDefaultCodecRegistry(),
|
MongoClientSettings.getDefaultCodecRegistry(),
|
||||||
@ -71,6 +71,8 @@ public class MongoDBDatabase extends BasicDatabase {
|
|||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
if (!this.isConnected()) return;
|
if (!this.isConnected()) return;
|
||||||
this.mongoClient.close();
|
this.mongoClient.close();
|
||||||
|
this.mongoClient = null;
|
||||||
|
this.mongoDatabase = null;
|
||||||
System.out.println("Successfully disconnected to MongoDB database");
|
System.out.println("Successfully disconnected to MongoDB database");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package de.weapie.devlok.database.mongodb;
|
|||||||
import com.mongodb.client.MongoCollection;
|
import com.mongodb.client.MongoCollection;
|
||||||
import com.mongodb.client.MongoCursor;
|
import com.mongodb.client.MongoCursor;
|
||||||
import com.mongodb.client.model.Sorts;
|
import com.mongodb.client.model.Sorts;
|
||||||
import com.mongodb.client.model.UpdateOptions;
|
import com.mongodb.client.model.ReplaceOptions;
|
||||||
import de.weapie.devlok.database.Database;
|
import de.weapie.devlok.database.Database;
|
||||||
import de.weapie.devlok.database.utils.BasicService;
|
import de.weapie.devlok.database.utils.BasicService;
|
||||||
import de.weapie.devlok.utils.data.Pair;
|
import de.weapie.devlok.utils.data.Pair;
|
||||||
@ -44,7 +44,7 @@ public class MongoDBService implements BasicService {
|
|||||||
@Override
|
@Override
|
||||||
public long count(String collection) {
|
public long count(String collection) {
|
||||||
if(!this.database().isConnected()) return 0;
|
if(!this.database().isConnected()) return 0;
|
||||||
return this.collection(collection).count();
|
return this.collection(collection).countDocuments();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -110,7 +110,7 @@ public class MongoDBService implements BasicService {
|
|||||||
@Override
|
@Override
|
||||||
public void replace(String collection, Document filter, Document replace) {
|
public void replace(String collection, Document filter, Document replace) {
|
||||||
if(!this.database().isConnected()) return;
|
if(!this.database().isConnected()) return;
|
||||||
this.collection(collection).replaceOne(filter, replace, new UpdateOptions().upsert(true));
|
this.collection(collection).replaceOne(filter, replace, new ReplaceOptions().upsert(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class MySQLDatabase extends BasicDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
try {
|
try {
|
||||||
return this.connection != null || this.connection.isValid(1);
|
return this.connection != null && !this.connection.isClosed() && this.connection.isValid(1);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ public class MySQLDatabase extends BasicDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public void connect() {
|
public void connect() {
|
||||||
try {
|
try {
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
|
|
||||||
String dataSourceName = this.getDataSourceName();
|
String dataSourceName = this.getDataSourceName();
|
||||||
this.connection = DriverManager.getConnection(dataSourceName, this.user, this.password);
|
this.connection = DriverManager.getConnection(dataSourceName, this.user, this.password);
|
||||||
@ -56,7 +56,7 @@ public class MySQLDatabase extends BasicDatabase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
this.autoReconnect.interrupt();
|
if (this.autoReconnect != null) this.autoReconnect.interrupt();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.connection != null) {
|
if (this.connection != null) {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class PostgresDatabase extends BasicDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
try {
|
try {
|
||||||
return this.connection != null || this.connection.isValid(1);
|
return this.connection != null && !this.connection.isClosed() && this.connection.isValid(1);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public class SQLiteDatabase extends BasicDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
try {
|
try {
|
||||||
return this.connection != null || this.connection.isValid(1);
|
return this.connection != null && !this.connection.isClosed() && this.connection.isValid(1);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,4 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.gson)
|
api(libs.gson)
|
||||||
api(project(":devlok-utils"))
|
api(project(":devlok-utils"))
|
||||||
|
|
||||||
testImplementation(libs.gson)
|
|
||||||
testImplementation(platform("org.junit:junit-bom:5.10.2"))
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
dependsOn(":devlok-utils:shadowJar")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class JsonUtils {
|
public class JsonUtils {
|
||||||
|
|
||||||
@ -35,10 +36,9 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void writeJson(Object object, File file) {
|
public static void writeJson(Object object, File file) {
|
||||||
try(FileWriter fileWriter = new FileWriter(file)) {
|
try(FileWriter fileWriter = new FileWriter(file, StandardCharsets.UTF_8)) {
|
||||||
String jsonString = JSON.toJson(object);
|
String jsonString = JSON.toJson(object);
|
||||||
fileWriter.write(jsonString);
|
fileWriter.write(jsonString);
|
||||||
fileWriter.close();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("Exception thrown while writing the file " + file.getPath());
|
System.out.println("Exception thrown while writing the file " + file.getPath());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -46,10 +46,9 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void writePrettyJson(Object object, File file) {
|
public static void writePrettyJson(Object object, File file) {
|
||||||
try(FileWriter fileWriter = new FileWriter(file)) {
|
try(FileWriter fileWriter = new FileWriter(file, StandardCharsets.UTF_8)) {
|
||||||
String prettyJsonString = PRETTY_JSON.toJson(object);
|
String prettyJsonString = PRETTY_JSON.toJson(object);
|
||||||
fileWriter.write(prettyJsonString);
|
fileWriter.write(prettyJsonString);
|
||||||
fileWriter.close();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("Exception thrown while writing the file " + file.getPath());
|
System.out.println("Exception thrown while writing the file " + file.getPath());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -61,11 +60,8 @@ public class JsonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T fromJson(File file, Class<T> tClass) {
|
public static <T> T fromJson(File file, Class<T> tClass) {
|
||||||
try {
|
try (FileReader fileReader = new FileReader(file, StandardCharsets.UTF_8)) {
|
||||||
FileReader fileReader = new FileReader(file);
|
return JSON.fromJson(fileReader, tClass);
|
||||||
T config = JSON.fromJson(fileReader, tClass);
|
|
||||||
fileReader.close();
|
|
||||||
return config;
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println("Exception thrown while reading the file " + file.getPath());
|
System.out.println("Exception thrown while reading the file " + file.getPath());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|||||||
@ -1,20 +1,4 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(project(":devlok-utils"))
|
api(project(":devlok-utils"))
|
||||||
api(project(":devlok-files"))
|
api(project(":devlok-files"))
|
||||||
|
|
||||||
testImplementation(platform("org.junit:junit-bom:5.10.2"))
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
dependsOn(":devlok-utils:shadowJar")
|
|
||||||
dependsOn(":devlok-files:shadowJar")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,25 +1,9 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.netty5)
|
api(platform(libs.netty.bom))
|
||||||
compileOnly(libs.gson)
|
api(libs.bundles.netty)
|
||||||
|
runtimeOnly("io.netty:netty-transport-native-epoll:${libs.versions.netty.get()}:linux-x86_64")
|
||||||
|
runtimeOnly("io.netty:netty-transport-native-epoll:${libs.versions.netty.get()}:linux-aarch_64")
|
||||||
api(project(":devlok-utils"))
|
api(project(":devlok-utils"))
|
||||||
api(project(":devlok-files"))
|
api(project(":devlok-files"))
|
||||||
api(project(":devlok-reflections"))
|
api(project(":devlok-reflections"))
|
||||||
|
|
||||||
testImplementation(libs.gson)
|
|
||||||
testImplementation(platform("org.junit:junit-bom:5.10.2"))
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
dependsOn(":devlok-reflections:shadowJar")
|
|
||||||
dependsOn(":devlok-utils:shadowJar")
|
|
||||||
dependsOn(":devlok-files:shadowJar")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,9 +1,9 @@
|
|||||||
package de.weapie.devlok.networking;
|
package de.weapie.devlok.networking;
|
||||||
|
|
||||||
import de.weapie.devlok.utils.executers.FutureResult;
|
import de.weapie.devlok.utils.executers.FutureResult;
|
||||||
import io.netty5.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty5.channel.EventLoopGroup;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import io.netty5.util.concurrent.FutureListener;
|
import io.netty.channel.EventLoopGroup;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -15,6 +15,7 @@ public abstract class CommunicationComponent extends CommunicationListener {
|
|||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
@Setter(AccessLevel.PROTECTED)
|
@Setter(AccessLevel.PROTECTED)
|
||||||
private FutureResult<Void> connectionFuture = new FutureResult<>();
|
private FutureResult<Void> connectionFuture = new FutureResult<>();
|
||||||
|
private volatile Channel connectionChannel;
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
private final EventLoopGroup bossGroup;
|
private final EventLoopGroup bossGroup;
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
@ -30,11 +31,11 @@ public abstract class CommunicationComponent extends CommunicationListener {
|
|||||||
|
|
||||||
public abstract void initialize();
|
public abstract void initialize();
|
||||||
|
|
||||||
public FutureListener<? super Channel> handleConnectionRelease() {
|
public ChannelFutureListener handleConnectionRelease() {
|
||||||
return it -> {
|
return it -> {
|
||||||
if (it.isSuccess()) {
|
if (it.isSuccess()) {
|
||||||
|
connectionChannel = it.channel();
|
||||||
connectionFuture.complete(null);
|
connectionFuture.complete(null);
|
||||||
it.getNow().closeFuture();
|
|
||||||
} else {
|
} else {
|
||||||
connectionFuture.completeExceptionally(it.cause());
|
connectionFuture.completeExceptionally(it.cause());
|
||||||
}
|
}
|
||||||
@ -42,7 +43,7 @@ public abstract class CommunicationComponent extends CommunicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return connectionFuture.isDone();
|
return connectionChannel != null && connectionChannel.isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlive() {
|
public boolean isAlive() {
|
||||||
@ -50,6 +51,7 @@ public abstract class CommunicationComponent extends CommunicationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
if (connectionChannel != null) connectionChannel.close();
|
||||||
bossGroup.shutdownGracefully();
|
bossGroup.shutdownGracefully();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
package de.weapie.devlok.networking;
|
package de.weapie.devlok.networking;
|
||||||
|
|
||||||
import io.netty5.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import io.netty5.channel.MultithreadEventLoopGroup;
|
import io.netty.channel.MultiThreadIoEventLoopGroup;
|
||||||
import io.netty5.channel.ServerChannel;
|
import io.netty.channel.ServerChannel;
|
||||||
import io.netty5.channel.ServerChannelFactory;
|
import io.netty.channel.ChannelFactory;
|
||||||
import io.netty5.channel.epoll.Epoll;
|
import io.netty.channel.epoll.Epoll;
|
||||||
import io.netty5.channel.epoll.EpollHandler;
|
import io.netty.channel.epoll.EpollIoHandler;
|
||||||
import io.netty5.channel.epoll.EpollServerSocketChannel;
|
import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||||
import io.netty5.channel.epoll.EpollSocketChannel;
|
import io.netty.channel.epoll.EpollSocketChannel;
|
||||||
import io.netty5.channel.nio.NioHandler;
|
import io.netty.channel.nio.NioIoHandler;
|
||||||
import io.netty5.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import io.netty5.channel.socket.nio.NioServerSocketChannel;
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||||
import io.netty5.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -20,15 +20,19 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class CommunicationNetworkUtils {
|
public class CommunicationNetworkUtils {
|
||||||
|
|
||||||
@Contract("_ -> new")
|
@Contract("_ -> new")
|
||||||
public static @NotNull MultithreadEventLoopGroup createEventLoopGroup(int threads) {
|
public static @NotNull MultiThreadIoEventLoopGroup createEventLoopGroup(int threads) {
|
||||||
return new MultithreadEventLoopGroup(threads, Epoll.isAvailable() ? EpollHandler.newFactory() : NioHandler.newFactory());
|
return new MultiThreadIoEventLoopGroup(threads, Epoll.isAvailable() ? EpollIoHandler.newFactory() : NioIoHandler.newFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull SocketChannel createChannelFactory(EventLoop loop) {
|
public static @NotNull SocketChannel createChannelFactory(EventLoop loop) {
|
||||||
return Epoll.isAvailable() ? new EpollSocketChannel(loop) : new NioSocketChannel(loop);
|
return createChannelFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ServerChannelFactory<? extends ServerChannel> generateChannelFactory() {
|
public static @NotNull SocketChannel createChannelFactory() {
|
||||||
|
return Epoll.isAvailable() ? new EpollSocketChannel() : new NioSocketChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ChannelFactory<? extends ServerChannel> generateChannelFactory() {
|
||||||
return Epoll.isAvailable() ? EpollServerSocketChannel::new : NioServerSocketChannel::new;
|
return Epoll.isAvailable() ? EpollServerSocketChannel::new : NioServerSocketChannel::new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,9 +2,10 @@ package de.weapie.devlok.networking;
|
|||||||
|
|
||||||
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
||||||
import de.weapie.devlok.networking.packet.Packet;
|
import de.weapie.devlok.networking.packet.Packet;
|
||||||
import io.netty5.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty5.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty5.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ChannelHandler.Sharable
|
||||||
public final class CommunicationTransmitHandler extends SimpleChannelInboundHandler<Packet> {
|
public final class CommunicationTransmitHandler extends SimpleChannelInboundHandler<Packet> {
|
||||||
|
|
||||||
private final Function<Channel, List<ChannelTransmit>> findTransmitFunction;
|
private final Function<Channel, List<ChannelTransmit>> findTransmitFunction;
|
||||||
@ -21,7 +23,7 @@ public final class CommunicationTransmitHandler extends SimpleChannelInboundHand
|
|||||||
private final Consumer<ChannelTransmit> channelTransmitConsumer;
|
private final Consumer<ChannelTransmit> channelTransmitConsumer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void messageReceived(ChannelHandlerContext channelHandlerContext, Packet packet) {
|
protected void channelRead0(ChannelHandlerContext channelHandlerContext, Packet packet) {
|
||||||
channelTransmitPacketConsumer.accept(packet, findTransmitFunction.apply(channelHandlerContext.channel()).stream().filter(it -> it.channel().equals(channelHandlerContext.channel())).findFirst().orElseThrow());
|
channelTransmitPacketConsumer.accept(packet, findTransmitFunction.apply(channelHandlerContext.channel()).stream().filter(it -> it.channel().equals(channelHandlerContext.channel())).findFirst().orElseThrow());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ public final class CommunicationTransmitHandler extends SimpleChannelInboundHand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelExceptionCaught(ChannelHandlerContext ctx, @NotNull Throwable cause) {
|
public void exceptionCaught(ChannelHandlerContext ctx, @NotNull Throwable cause) {
|
||||||
if (!cause.getMessage().equals("Connection reset")) cause.printStackTrace();
|
if (!"Connection reset".equals(cause.getMessage())) cause.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package de.weapie.devlok.networking.channel;
|
|||||||
import de.weapie.devlok.networking.codec.PacketDecoder;
|
import de.weapie.devlok.networking.codec.PacketDecoder;
|
||||||
import de.weapie.devlok.networking.codec.PacketEncoder;
|
import de.weapie.devlok.networking.codec.PacketEncoder;
|
||||||
import de.weapie.devlok.networking.CommunicationTransmitHandler;
|
import de.weapie.devlok.networking.CommunicationTransmitHandler;
|
||||||
import io.netty5.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty5.handler.codec.LengthFieldBasedFrameDecoder;
|
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||||
import io.netty5.handler.codec.LengthFieldPrepender;
|
import io.netty.handler.codec.LengthFieldPrepender;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
@Setter
|
@Setter
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public final class ChannelInitializer extends io.netty5.channel.ChannelInitializer<Channel> {
|
public final class ChannelInitializer extends io.netty.channel.ChannelInitializer<Channel> {
|
||||||
|
|
||||||
private final CommunicationTransmitHandler transmitHandler;
|
private final CommunicationTransmitHandler transmitHandler;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package de.weapie.devlok.networking.channel;
|
|||||||
|
|
||||||
import de.weapie.devlok.networking.CommunicationListener;
|
import de.weapie.devlok.networking.CommunicationListener;
|
||||||
import de.weapie.devlok.networking.packet.Packet;
|
import de.weapie.devlok.networking.packet.Packet;
|
||||||
import io.netty5.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|||||||
@ -6,9 +6,9 @@ import de.weapie.devlok.networking.packet.Packet;
|
|||||||
import de.weapie.devlok.networking.CommunicationComponent;
|
import de.weapie.devlok.networking.CommunicationComponent;
|
||||||
import de.weapie.devlok.networking.CommunicationNetworkUtils;
|
import de.weapie.devlok.networking.CommunicationNetworkUtils;
|
||||||
import de.weapie.devlok.networking.CommunicationTransmitHandler;
|
import de.weapie.devlok.networking.CommunicationTransmitHandler;
|
||||||
import io.netty5.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty5.channel.ChannelOption;
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty5.channel.epoll.Epoll;
|
import io.netty.channel.epoll.Epoll;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -43,14 +43,7 @@ public final class CommunicationClient extends CommunicationComponent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
this.bootstrap.connect(hostname(), port()).addListener(future -> {
|
this.bootstrap.connect(hostname(), port()).addListener(handleConnectionRelease());
|
||||||
if (future.isSuccess()) {
|
|
||||||
this.connectionFuture().complete(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.connectionFuture().completeExceptionally(future.cause());
|
|
||||||
this.connectionFuture(null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package de.weapie.devlok.networking.client;
|
|||||||
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
||||||
import de.weapie.devlok.networking.packet.Packet;
|
import de.weapie.devlok.networking.packet.Packet;
|
||||||
import de.weapie.devlok.networking.CommunicationComponent;
|
import de.weapie.devlok.networking.CommunicationComponent;
|
||||||
import io.netty5.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|||||||
@ -3,31 +3,31 @@ package de.weapie.devlok.networking.codec;
|
|||||||
import de.weapie.devlok.networking.packet.Packet;
|
import de.weapie.devlok.networking.packet.Packet;
|
||||||
import de.weapie.devlok.networking.packet.PacketBuffer;
|
import de.weapie.devlok.networking.packet.PacketBuffer;
|
||||||
import de.weapie.devlok.reflections.common.Allocator;
|
import de.weapie.devlok.reflections.common.Allocator;
|
||||||
import io.netty5.buffer.Buffer;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty5.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty5.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.CorruptedFrameException;
|
||||||
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
|
|
||||||
public class PacketDecoder extends ByteToMessageDecoder {
|
import java.util.List;
|
||||||
|
|
||||||
|
// The preceding LengthFieldBasedFrameDecoder supplies one complete frame.
|
||||||
|
public class PacketDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, Buffer in) {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
var buffer = new PacketBuffer(in);
|
var buffer = new PacketBuffer(in);
|
||||||
|
|
||||||
var className = buffer.readString();
|
var className = buffer.readString();
|
||||||
|
var readableBytes = buffer.readInt();
|
||||||
try {
|
if (readableBytes < 0 || readableBytes != in.readableBytes()) {
|
||||||
var readableBytes = buffer.readInt();
|
throw new CorruptedFrameException("Invalid packet payload length: " + readableBytes);
|
||||||
var content = new PacketBuffer(in.copy(in.readerOffset(), readableBytes, true));
|
|
||||||
in.skipReadableBytes(readableBytes);
|
|
||||||
|
|
||||||
var packet = (Packet) Allocator.allocate(Class.forName(className));
|
|
||||||
|
|
||||||
packet.read(content);
|
|
||||||
|
|
||||||
buffer.resetBuffer();
|
|
||||||
ctx.fireChannelRead(packet);
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error while decoding packet " + className);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var packetType = Class.forName(className, false, getClass().getClassLoader()).asSubclass(Packet.class);
|
||||||
|
var packet = Allocator.allocate(packetType);
|
||||||
|
if (packet == null) {
|
||||||
|
throw new CorruptedFrameException("Cannot allocate packet: " + className);
|
||||||
|
}
|
||||||
|
// The slice is borrowed from the frame and released by MessageToMessageDecoder.
|
||||||
|
packet.read(new PacketBuffer(in.readSlice(readableBytes)));
|
||||||
|
out.add(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,60 +2,20 @@ package de.weapie.devlok.networking.codec;
|
|||||||
|
|
||||||
import de.weapie.devlok.networking.packet.Packet;
|
import de.weapie.devlok.networking.packet.Packet;
|
||||||
import de.weapie.devlok.networking.packet.PacketBuffer;
|
import de.weapie.devlok.networking.packet.PacketBuffer;
|
||||||
import io.netty5.buffer.Buffer;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty5.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty5.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
import lombok.SneakyThrows;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class PacketEncoder extends MessageToByteEncoder<Packet> {
|
public class PacketEncoder extends MessageToByteEncoder<Packet> {
|
||||||
|
|
||||||
private static final HashMap<Packet, PacketBuffer> tempPacketEncoderList = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
protected void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf out) {
|
||||||
protected Buffer allocateBuffer(ChannelHandlerContext ctx, Packet packet) {
|
try (var content = PacketBuffer.allocate()) {
|
||||||
try {
|
packet.write(content);
|
||||||
var buffer = PacketBuffer.allocate();
|
|
||||||
|
|
||||||
packet.write(buffer);
|
|
||||||
|
|
||||||
tempPacketEncoderList.put(packet, buffer);
|
|
||||||
|
|
||||||
// amount of chars in class name
|
|
||||||
var bytes = Integer.BYTES +
|
|
||||||
// class name
|
|
||||||
packet.getClass().getName().getBytes(StandardCharsets.UTF_8).length +
|
|
||||||
// amount of bytes in buffer
|
|
||||||
Integer.BYTES +
|
|
||||||
// buffer content
|
|
||||||
buffer.getOrigin().readableBytes();
|
|
||||||
|
|
||||||
return ctx.bufferAllocator().allocate(bytes);
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void encode(ChannelHandlerContext ctx, Packet msg, Buffer out) {
|
|
||||||
try {
|
|
||||||
var origin = tempPacketEncoderList.get(msg).getOrigin();
|
|
||||||
var buffer = new PacketBuffer(out);
|
var buffer = new PacketBuffer(out);
|
||||||
var readableBytes = origin.readableBytes();
|
buffer.writeString(packet.getClass().getName());
|
||||||
|
buffer.writeInt(content.getOrigin().readableBytes());
|
||||||
buffer.writeString(msg.getClass().getName());
|
out.writeBytes(content.getOrigin());
|
||||||
buffer.writeInt(readableBytes);
|
|
||||||
|
|
||||||
origin.copyInto(0, out, out.writerOffset(), readableBytes);
|
|
||||||
out.skipWritableBytes(readableBytes);
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error while encoding packet " + msg.getClass().getName());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
tempPacketEncoderList.remove(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,7 @@
|
|||||||
package de.weapie.devlok.networking.packet;
|
package de.weapie.devlok.networking.packet;
|
||||||
|
|
||||||
import io.netty5.buffer.Buffer;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty5.buffer.BufferAllocator;
|
import io.netty.buffer.ByteBufAllocator;
|
||||||
import io.netty5.buffer.DefaultBufferAllocators;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -13,20 +12,25 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public final class PacketBuffer {
|
public final class PacketBuffer implements AutoCloseable {
|
||||||
private static final BufferAllocator BUFFER_ALLOCATOR = DefaultBufferAllocators.offHeapAllocator();
|
private static final ByteBufAllocator BUFFER_ALLOCATOR = ByteBufAllocator.DEFAULT;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Buffer origin;
|
private final ByteBuf origin;
|
||||||
|
|
||||||
public static PacketBuffer allocate() {
|
public static PacketBuffer allocate() {
|
||||||
return new PacketBuffer(BUFFER_ALLOCATOR.allocate(0));
|
return new PacketBuffer(BUFFER_ALLOCATOR.buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
origin.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetBuffer() {
|
public void resetBuffer() {
|
||||||
if (origin.readableBytes() > 0) {
|
if (origin.readableBytes() > 0) {
|
||||||
System.err.println("Buffer not empty! Skipping remaining bytes: " + origin.readableBytes());
|
System.err.println("Buffer not empty! Skipping remaining bytes: " + origin.readableBytes());
|
||||||
origin.skipReadableBytes(origin.readableBytes());
|
origin.skipBytes(origin.readableBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +149,7 @@ public final class PacketBuffer {
|
|||||||
return this.origin.readByte();
|
return this.origin.readByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketBuffer writeBytes(Buffer bytes) {
|
public PacketBuffer writeBytes(ByteBuf bytes) {
|
||||||
this.origin.writeBytes(bytes);
|
this.origin.writeBytes(bytes);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,20 +6,20 @@ import de.weapie.devlok.networking.CommunicationTransmitHandler;
|
|||||||
import de.weapie.devlok.networking.channel.ChannelInitializer;
|
import de.weapie.devlok.networking.channel.ChannelInitializer;
|
||||||
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
||||||
import de.weapie.devlok.networking.packet.Packet;
|
import de.weapie.devlok.networking.packet.Packet;
|
||||||
import io.netty5.bootstrap.ServerBootstrap;
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
import io.netty5.channel.ChannelOption;
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty5.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
public final class CommunicationServer extends CommunicationComponent {
|
public final class CommunicationServer extends CommunicationComponent {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final List<ChannelTransmit> channels = new ArrayList<>();
|
private final List<ChannelTransmit> channels = new CopyOnWriteArrayList<>();
|
||||||
private final EventLoopGroup workerGroup = CommunicationNetworkUtils.createEventLoopGroup(0);
|
private final EventLoopGroup workerGroup = CommunicationNetworkUtils.createEventLoopGroup(0);
|
||||||
|
|
||||||
public CommunicationServer(String hostname, int port) {
|
public CommunicationServer(String hostname, int port) {
|
||||||
@ -50,4 +50,12 @@ public final class CommunicationServer extends CommunicationComponent {
|
|||||||
public void sendPacket(Packet packet) {
|
public void sendPacket(Packet packet) {
|
||||||
this.channels.forEach(channelTransmit -> channelTransmit.sendPacket(packet));
|
this.channels.forEach(channelTransmit -> channelTransmit.sendPacket(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
channels.forEach(channelTransmit -> channelTransmit.channel().close());
|
||||||
|
channels.clear();
|
||||||
|
workerGroup.shutdownGracefully();
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import de.weapie.devlok.networking.CommunicationComponent;
|
|||||||
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
import de.weapie.devlok.networking.channel.ChannelTransmit;
|
||||||
import de.weapie.devlok.networking.packet.Packet;
|
import de.weapie.devlok.networking.packet.Packet;
|
||||||
import de.weapie.devlok.networking.packet.RequestPacket;
|
import de.weapie.devlok.networking.packet.RequestPacket;
|
||||||
import io.netty5.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class CommunicationServerTransmit extends ChannelTransmit {
|
public class CommunicationServerTransmit extends ChannelTransmit {
|
||||||
|
|||||||
@ -1,19 +1,4 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(project(":devlok-utils"))
|
api(project(":devlok-utils"))
|
||||||
|
|
||||||
testImplementation(project(":devlok-logger"))
|
testImplementation(project(":devlok-logger"))
|
||||||
testImplementation(platform("org.junit:junit-bom:5.10.2"))
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
dependsOn(":devlok-utils:shadowJar")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,22 +1,5 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.redis)
|
api(libs.redis)
|
||||||
api(project(":devlok-utils"))
|
api(project(":devlok-utils"))
|
||||||
api(project(":devlok-files"))
|
api(project(":devlok-files"))
|
||||||
|
|
||||||
testImplementation(libs.gson)
|
|
||||||
testImplementation(platform("org.junit:junit-bom:5.10.2"))
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
dependsOn(":devlok-utils:shadowJar")
|
|
||||||
dependsOn(":devlok-files:shadowJar")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,2 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,3 +1,2 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,23 +1,36 @@
|
|||||||
[versions]
|
[versions]
|
||||||
annotations = "24.1.0"
|
annotations = "26.1.0"
|
||||||
lombok = "1.18.32"
|
lombok = "1.18.48"
|
||||||
gson = "2.11.0"
|
gson = "2.15.0"
|
||||||
netty5 = "5.0.0.Alpha5"
|
netty = "4.2.20.Final"
|
||||||
mongodb = "3.12.14"
|
mongodb = "5.14.0"
|
||||||
mysql = "5.1.36"
|
mysql = "26.10.0"
|
||||||
postgres = "42.7.4"
|
postgres = "42.7.14"
|
||||||
sqlite = "3.46.0.0"
|
sqlite = "3.54.1.0"
|
||||||
redis = "4.2.0"
|
redis = "8.0.2"
|
||||||
|
junit = "6.1.3"
|
||||||
|
shadow = "9.6.1"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
lombok = { group = "org.projectlombok", name="lombok", version.ref = "lombok" }
|
lombok = { group = "org.projectlombok", name="lombok", version.ref = "lombok" }
|
||||||
annotations = { group = "org.jetbrains", name="annotations", version.ref = "annotations" }
|
annotations = { group = "org.jetbrains", name="annotations", version.ref = "annotations" }
|
||||||
gson = { group = "com.google.code.gson", name="gson", version.ref = "gson" }
|
gson = { group = "com.google.code.gson", name="gson", version.ref = "gson" }
|
||||||
netty5 = { group = "io.netty", name = "netty5-all", version.ref = "netty5" }
|
netty-bom = { group = "io.netty", name = "netty-bom", version.ref = "netty" }
|
||||||
mongodb = { group = "org.mongodb", name = "mongodb-driver", version.ref = "mongodb" }
|
netty-buffer = { group = "io.netty", name = "netty-buffer" }
|
||||||
mysql = { group = "mysql", name = "mysql-connector-java", version.ref = "mysql" }
|
netty-transport = { group = "io.netty", name = "netty-transport" }
|
||||||
|
netty-codec = { group = "io.netty", name = "netty-codec-base" }
|
||||||
|
netty-epoll = { group = "io.netty", name = "netty-transport-classes-epoll" }
|
||||||
|
mongodb = { group = "org.mongodb", name = "mongodb-driver-sync", version.ref = "mongodb" }
|
||||||
|
mysql = { group = "com.mysql", name = "mysql-connector-j", version.ref = "mysql" }
|
||||||
postgres = { group = "org.postgresql", name = "postgresql", version.ref = "postgres" }
|
postgres = { group = "org.postgresql", name = "postgresql", version.ref = "postgres" }
|
||||||
sqlite = { group = "org.xerial", name = "sqlite-jdbc", version.ref = "sqlite" }
|
sqlite = { group = "org.xerial", name = "sqlite-jdbc", version.ref = "sqlite" }
|
||||||
redis = { group = "redis.clients", name = "jedis", version.ref = "redis" }
|
redis = { group = "redis.clients", name = "jedis", version.ref = "redis" }
|
||||||
|
junit-bom = { group = "org.junit", name = "junit-bom", version.ref = "junit" }
|
||||||
|
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter" }
|
||||||
|
junit-launcher = { group = "org.junit.platform", name = "junit-platform-launcher" }
|
||||||
|
|
||||||
|
[bundles]
|
||||||
|
netty = ["netty-buffer", "netty-transport", "netty-codec", "netty-epoll"]
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
|
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
8
gradle/wrapper/gradle-wrapper.properties
vendored
8
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,10 @@
|
|||||||
#Tue Jan 23 09:21:27 CET 2024
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
distributionSha256Sum=0b00b0ffe07c4d4789c12d4935a44a7057d55774b7540bd4a3f76f336deb177a
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.0-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
retries=0
|
||||||
|
retryBackOffMs=500
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
54
gradlew
vendored
54
gradlew
vendored
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright © 2015 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -15,10 +15,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
# gradlew start up script for POSIX generated by Gradle.
|
||||||
#
|
#
|
||||||
# Important for running:
|
# Important for running:
|
||||||
#
|
#
|
||||||
@ -27,7 +29,7 @@
|
|||||||
# bash, then to run this script, type that shell name before the whole
|
# bash, then to run this script, type that shell name before the whole
|
||||||
# command line, like:
|
# command line, like:
|
||||||
#
|
#
|
||||||
# ksh Gradle
|
# ksh gradlew
|
||||||
#
|
#
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@ -80,13 +82,11 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@ -114,7 +114,6 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@ -133,22 +132,29 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@ -165,7 +171,6 @@ fi
|
|||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
@ -193,18 +198,27 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|||||||
93
gradlew.bat
vendored
93
gradlew.bat
vendored
@ -13,19 +13,49 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem gradlew startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
setlocal EnableExtensions
|
||||||
|
|
||||||
|
@rem Catch executions from older scripts and ensure they exit cleanly.
|
||||||
|
@rem This can be removed once we can be reasonably confident that few people
|
||||||
|
@rem will be migrating directly to this new wrapper.
|
||||||
|
goto afterSafetyNet
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
goto exitWithErrorLevel
|
||||||
|
:afterSafetyNet
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@ -40,15 +70,16 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
1>&2 echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo.
|
1>&2 echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
1>&2 echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
goto exitWithErrorLevel
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
:findJavaFromJavaHome
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
@ -56,34 +87,26 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
1>&2 echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo.
|
1>&2 echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
1>&2 echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
goto exitWithErrorLevel
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute gradlew
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||||
|
@rem which allows us to clear the local environment before executing the java command
|
||||||
|
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel
|
||||||
|
|
||||||
:end
|
@rem This label must not be changed. We rely on old scripts being able to jump to this point.
|
||||||
@rem End local scope for the variables with windows NT shell
|
:exitWithErrorLevel
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
||||||
exit /b 1
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user