Skip to content

Commit

Permalink
build(github): add kotlin and refactor lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiYuANg committed Dec 10, 2024
1 parent 70e31cd commit 46a923e
Show file tree
Hide file tree
Showing 73 changed files with 499 additions and 330 deletions.
16 changes: 8 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
jdk = "21"
ikonliJavafx = "12.3.1"
slf4j = "2.1.0-alpha1"
slf4j = "2.0.16"
ikonli = "12.3.1"
junit = "5.11.3"
testcontainers = "1.20.4"
Expand All @@ -15,11 +15,11 @@ jgit = "7.1.0.202411261347-r"
vertx = "4.5.11"
jdbi = "3.45.0"
fury = "0.9.0"
avajeValidaor = "2.3"
avajeValidaor = "2.4"
h2 = "2.3.232"
asciidoctor = "4.0.3"
avajeInject = "11.1-RC1"
recordBuilder = "43"
record-builder = "44"
mutinyVertx = "3.17.1"
schemacrawler = "16.23.2"
polyglot = "24.1.1"
Expand Down Expand Up @@ -125,8 +125,6 @@ jackson-data-type-jsonP = { group = "com.fasterxml.jackson.datatype", name = "ja
jackson-data-type-xml = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-xml", version.ref = "jackson" }
eclipse-parsson = { group = "org.eclipse.parsson", name = "parsson", version = "1.1.7" }

picocli = { group = "info.picocli", name = "picocli", version.ref = "picocli" }
picocli-codegen = { group = "info.picocli", name = "picocli-codegen", version.ref = "picocli" }
avaje-validaor = { group = "io.avaje", name = "avaje-validator", version.ref = "avajeValidaor" }
avaje-validaor-constraints = { group = "io.avaje", name = "avaje-validator-constraints", version.ref = "avajeValidaor" }
avaje-validaor-codegen = { group = "io.avaje", name = "avaje-validator-generator", version.ref = "avajeValidaor" }
Expand Down Expand Up @@ -177,8 +175,8 @@ mutiny-vertx-web-client = { group = "io.smallrye.reactive", name = "smallrye-mut
mutiny-vertx-tcp-eventbus-bridge = { group = "io.smallrye.reactive", name = "smallrye-mutiny-vertx-tcp-eventbus-bridge", version.ref = "mutinyVertx" }
netty-resolver-dns-native-macos = { group = "io.netty", name = "netty-resolver-dns-native-macos", version = "4.2.0.Beta1" }

record-builder-core = { group = "io.soabase.record-builder", name = "record-builder-core", version.ref = "recordBuilder" }
record-builder-processor = { group = "io.soabase.record-builder", name = "record-builder-processor", version.ref = "recordBuilder" }
record-builder-core = { group = "io.soabase.record-builder", name = "record-builder-core", version.ref = "record-builder" }
record-builder-processor = { group = "io.soabase.record-builder", name = "record-builder-processor", version.ref = "record-builder" }

jsqlparser = { group = "com.github.jsqlparser", name = "jsqlparser", version = "4.9" }
jdbiCore = { group = "org.jdbi", name = "jdbi3-core", version.ref = "jdbi" }
Expand Down Expand Up @@ -210,4 +208,6 @@ theme-detector = { group = "com.github.Dansoftowner", name = "jSystemThemeDetect

lombok-plugin = { group = "name.remal.gradle-plugins.lombok", name = "lombok", version = "2.2.12" }

deezpatch = { group = "io.github.joel-jeremy.deezpatch", name = "deezpatch-core", version = "1.0.0-beta.1" }
deezpatch = { group = "io.github.joel-jeremy.deezpatch", name = "deezpatch-core", version = "1.0.0-beta.1" }

kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging-jvm", version = "7.0.3" }
2 changes: 0 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ include("visual-database")

include("visual-data-structure")

include("visual-api")

include("visual-i18n")

include("visual-collaboration-server")
3 changes: 0 additions & 3 deletions visual-api/build.gradle.kts

This file was deleted.

5 changes: 0 additions & 5 deletions visual-api/src/main/java/module-info.java

This file was deleted.

26 changes: 20 additions & 6 deletions visual-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
alias(libs.plugins.graalvm)
alias(libs.plugins.shadow)
alias(libs.plugins.sass)
kotlin("jvm") version "2.1.0"
}

apply<ModulePlugin>()
Expand All @@ -27,7 +28,6 @@ dependencies {
implementation(projects.visualCore)
implementation(projects.visualDataStructure)
implementation(projects.visualDatabase)
implementation(projects.visualApi)
implementation(projects.visualI18n)
implementation(libs.fastutil)
testImplementation(libs.vertx.junit5)
Expand Down Expand Up @@ -55,9 +55,6 @@ dependencies {

implementation(libs.logback)

implementation(libs.picocli)
annotationProcessor(libs.picocli.codegen)

testImplementation(libs.javafxUnitTest)

runtimeOnly(libs.h2)
Expand Down Expand Up @@ -111,6 +108,7 @@ dependencies {
implementation(libs.fury.core)
implementation(libs.fury.format)

implementation(libs.kotlin.logging)
compileOnly(libs.avaje.spi.service)
annotationProcessor(libs.avaje.spi.service)
antlr(libs.antlr)
Expand Down Expand Up @@ -187,7 +185,14 @@ jlink {
}
}

tasks.compileJava { dependsOn(tasks.compileSass) }
tasks.compileJava {
options.compilerArgumentProviders.add(
CommandLineArgumentProvider {
listOf("--patch-module", "$group=${sourceSets["main"].output.asPath}")
},
)
dependsOn(tasks.compileSass)
}

tasks.compileSass {
style = compressed
Expand All @@ -200,4 +205,13 @@ tasks.compileSass {
.asFile
}

tasks.prepareMergedJarsDir { dependsOn(tasks.jar) }
tasks.prepareMergedJarsDir { dependsOn(tasks.jar) }

kotlin {
jvmToolchain(libs.versions.jdk.get().toInt())
}

tasks.compileKotlin {
val compileJava: JavaCompile by tasks
destinationDirectory.set(compileJava.destinationDirectory)
}
10 changes: 6 additions & 4 deletions visual-app/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
requires javafx.controls;
requires javafx.web;
requires javafx.base;
requires info.picocli;
requires org.slf4j.jdk.platform.logging;
requires io.smallrye.mutiny;
requires it.unimi.dsi.fastutil;
Expand Down Expand Up @@ -67,7 +66,6 @@
exports org.visual.app.view to
javafx.graphics;

requires org.visual.api;
requires net.sourceforge.plantuml;

requires org.github.gestalt.core;
Expand All @@ -76,9 +74,13 @@

requires io.github.joeljeremy.deezpatch.core;

exports org.visual.app.api;
requires io.github.oshai.kotlinlogging;

provides org.visual.api.Lifecycle with org.visual.app.lifecycle.BackgroundServiceLifecycle;
exports org.visual.app.entity;
exports org.visual.app.lifecycle;
exports org.visual.app.repository;

provides org.visual.app.lifecycle.Lifecycle with org.visual.app.lifecycle.BackgroundServiceLifecycle;
provides io.avaje.inject.spi.InjectExtension with
org.visual.app.AppModule;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.visual.app.command.PicoFactory;
import org.visual.app.command.VisualCommand;
import org.visual.app.context.DIContext;
import org.visual.app.exception.GlobalExceptionHandler;
import picocli.CommandLine;

import static java.lang.System.exit;
import static java.lang.Thread.setDefaultUncaughtExceptionHandler;

@Slf4j
Expand All @@ -22,9 +19,6 @@ public class VisualApplication {

@SneakyThrows
public static void main(String[] args) {
log.atDebug().log("Visual Start");
val commandLine = new VisualCommand(args);
val exitCode = new CommandLine(commandLine, new PicoFactory()).execute(args);
exit(exitCode);
DIContext.INSTANCE.get(VisualCommand.class).run();
}
}
10 changes: 0 additions & 10 deletions visual-app/src/main/java/org/visual/app/api/HistoryRepository.java

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions visual-app/src/main/java/org/visual/app/command/OpenCommand.java

This file was deleted.

15 changes: 0 additions & 15 deletions visual-app/src/main/java/org/visual/app/command/PicoFactory.java

This file was deleted.

45 changes: 19 additions & 26 deletions visual-app/src/main/java/org/visual/app/command/VisualCommand.java
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
package org.visual.app.command;

import com.google.common.util.concurrent.ServiceManager;
import io.smallrye.mutiny.Uni;
import io.avaje.inject.PostConstruct;
import io.smallrye.mutiny.infrastructure.Infrastructure;
import io.vertx.mutiny.core.net.NetClient;
import jakarta.inject.Singleton;
import javafx.application.Application;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.visual.app.context.DIContext;
import org.visual.app.lifecycle.Lifecycle;
import org.visual.app.util.SPI;
import org.visual.app.view.VisualUI;
import picocli.CommandLine;

@CommandLine.Command(
name = "Visual",
mixinStandardHelpOptions = true,
helpCommand = true,
subcommands = {OpenCommand.class, CompileCommand.class})
import static io.smallrye.mutiny.Multi.createFrom;

@Singleton
@RequiredArgsConstructor
@Slf4j
public class VisualCommand implements Runnable {
private final String[] args;

@Override
public void run() {
Uni.createFrom().item(DIContext.INSTANCE)
.map((context) -> context.get(ServiceManager.class))

@PostConstruct
void init() {
createFrom()
.iterable(SPI.load(Lifecycle.class))
.emitOn(Infrastructure.getDefaultExecutor())
.log()
.invoke(ServiceManager::startAsync)
.onItem()
.invoke(Lifecycle::onStart)
.subscribe().with(t -> {
log.atInfo().log(t.toString());
});
DIContext.INSTANCE.get(NetClient.class)
.connect(19090, "localhost")
.subscribe().with(t -> {
t.handler(buffer -> {
log.atInfo().log(buffer.toString());
});
})
;
Application.launch(VisualUI.class, args);
}

@Override
public void run() {
Application.launch(VisualUI.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.github.gestalt.config.toml.TomlModuleConfigBuilder;
import org.github.gestalt.config.yaml.YamlModuleConfigBuilder;

import java.awt.*;
import java.util.Set;
import java.util.prefs.Preferences;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.visual.app.constant;

public interface PreferencesKey {
String STAGE_WIDTH = "stageWidth";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.visual.api.ObjectDI;

@Getter
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package org.visual.api;
package org.visual.app.context;


import org.jetbrains.annotations.NotNull;

Expand Down
17 changes: 17 additions & 0 deletions visual-app/src/main/java/org/visual/app/context/TabContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.visual.app.context;

import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import jakarta.inject.Singleton;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Singleton
@Slf4j
public class TabContext {

private final List<String> tabs = new ObjectArrayList<String>();

public void add() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.visual.app.constant.ViewConstant;
import org.visual.app.ui.FXMLHelper;
import org.visual.app.util.FXMLHelper;

import java.net.URL;
import java.util.ResourceBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.visual.app.constant.ViewConstant;
import org.visual.app.ui.FXMLHelper;
import org.visual.app.util.FXMLHelper;

import java.net.URL;
import java.util.ResourceBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.visual.app.constant.ViewConstant;
import org.visual.app.ui.DialogManager;
import org.visual.app.ui.FXMLHelper;
import org.visual.app.util.DialogManager;
import org.visual.app.util.FXMLHelper;

import java.net.URL;
import java.util.ResourceBundle;
Expand Down
Loading

0 comments on commit 46a923e

Please sign in to comment.