From 146d1b5d6aab2254dd8a0daf175aa52b17a6fbec Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Wed, 9 Mar 2022 22:51:04 +0100 Subject: [PATCH] More preparation for proper release --- README.md | 17 +++++++++++++++ api/build.gradle | 11 ++++++++-- api/src/main/java/module-info.java | 1 + core/README.md | 15 +++++++++++++ extension/README.md | 16 ++++++++++++++ extension/build.gradle | 4 ++++ .../xpipe/extension/event/EventHandler.java | 21 ++++++++++++++++++- extension/src/main/java/module-info.java | 7 +++++-- 8 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 README.md create mode 100644 core/README.md create mode 100644 extension/README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..d2d0765d9 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +## X-Pipe Java + +This repository contains the following four modules: + +- Core - Shared core classes of the Java API and the X-Pipe daemon implementation +- API - The API that can be used to interact with X-Pipe from any JVM-based languages +- Beacon - The X-Pipe beacon component is responsible for handling all communications between the X-Pipe daemon + and the client applications, for example the various programming language APIs and the CLI +- Extension - An API to create all different kinds of extensions for the X-Pipe platform + +## Development + +All X-Pipe components target [JDK 17](https://openjdk.java.net/projects/jdk/17/) and make full use of the Java Module System (JPMS). +All components are modularized, including all their dependencies. +In case a dependency is (sadly) not modularized yet, module information is manually added using [moditect](https://github.com/moditect/moditect-gradle-plugin). +These dependency generation rules are accumulated in the [X-Pipe dependencies](https://github.com/xpipe-io/xpipe_java_deps) +repository, which is shared between all components and integrated as a git submodule. diff --git a/api/build.gradle b/api/build.gradle index 6b7f353e6..c80b96920 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -19,15 +19,22 @@ repositories { } dependencies { + // Fix warnings about missing annotations + compileOnly group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.13.0" + testCompileOnly group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.13.0" + implementation project(':core') implementation project(':beacon') } +def canTestWithDev = findProject(':app') != null +def daemonCommand = canTestWithDev ? "cmd.exe /c \"$rootDir\\gradlew.bat\" :app:run" : 'xpipe.exe' + test { workingDir = rootDir // Daemon properties - systemProperty "io.xpipe.beacon.exec", "cmd.exe /c \"$rootDir\\gradlew.bat\" :app:run" + + systemProperty "io.xpipe.beacon.exec", daemonCommand + " -Dio.xpipe.app.mode=tray" + " -Dio.xpipe.beacon.port=21722" + " -Dio.xpipe.app.dataDir=$projectDir/local/" + @@ -38,6 +45,6 @@ test { // API properties // systemProperty 'io.xpipe.beacon.debugOutput', "true" - systemProperty 'io.xpipe.beacon.debugExecOutput', "true" + // systemProperty 'io.xpipe.beacon.debugExecOutput', "true" systemProperty "io.xpipe.beacon.port", "21722" } diff --git a/api/src/main/java/module-info.java b/api/src/main/java/module-info.java index 72af4e21a..7868f1d60 100644 --- a/api/src/main/java/module-info.java +++ b/api/src/main/java/module-info.java @@ -1,5 +1,6 @@ module io.xpipe.api { exports io.xpipe.api; + exports io.xpipe.api.connector; requires transitive io.xpipe.core; requires io.xpipe.beacon; diff --git a/core/README.md b/core/README.md new file mode 100644 index 000000000..fb792a01f --- /dev/null +++ b/core/README.md @@ -0,0 +1,15 @@ +## X-Pipe Core + +The X-Pipe core component contains all the shared core classes used by the API, beacon, and daemon. + +The main part can be found in the [data package](). +It contains all definitions of the internal X-Pipe data model and all IO functionality for these data structures. + +The [source package]() contains the basic data source model classes. +These have to be used by every custom data source implementation. + +The [store package]() contains the basic data store model classes. +These have to be used by every custom data store implementation. + +Every class is expected to be potentially used in the context of files and message exchanges. +As a result, all data structures exchanged must be serializable/deserializable with jackson. \ No newline at end of file diff --git a/extension/README.md b/extension/README.md new file mode 100644 index 000000000..8238cfe83 --- /dev/null +++ b/extension/README.md @@ -0,0 +1,16 @@ +## X-Pipe Extension API + +The X-Pipe extension API allows you to create extensions of any kind for X-Pipe. + + +### Custom data sources + +A custom data source type can be implemented by creating a custom [DataSourceProvider](). +This provider contains all the information required for proper handling of your custom data sources, +whether you access it from the CLI, any API, or the X-Pipe commander gui. + +### Custom data sinks + +A custom data sink type can be implemented by creating a custom [DataSinkProvider](). +As the notion of a sink is abstract, it allows you to basically implement any type of sink you want. +Whether the target is a programming language, another application, a database, or a regular file. \ No newline at end of file diff --git a/extension/build.gradle b/extension/build.gradle index 5ba60cbb1..3a3cacce8 100644 --- a/extension/build.gradle +++ b/extension/build.gradle @@ -13,6 +13,7 @@ apply from: "$rootDir/deps/jackson.gradle" apply from: "$rootDir/deps/commons.gradle" apply from: "$rootDir/deps/lombok.gradle" apply from: "$rootDir/deps/ikonli.gradle" +apply from: "$rootDir/deps/slf4j.gradle" apply from: 'publish.gradle' apply from: "$rootDir/deps/publish-base.gradle" @@ -27,4 +28,7 @@ repositories { dependencies { implementation project(':core') implementation project(':fxcomps') + + implementation 'com.google.code.gson:gson:2.9.0' + implementation 'org.controlsfx:controlsfx:11.1.1' } diff --git a/extension/src/main/java/io/xpipe/extension/event/EventHandler.java b/extension/src/main/java/io/xpipe/extension/event/EventHandler.java index 240ea881b..7dbe611cd 100644 --- a/extension/src/main/java/io/xpipe/extension/event/EventHandler.java +++ b/extension/src/main/java/io/xpipe/extension/event/EventHandler.java @@ -1,15 +1,34 @@ package io.xpipe.extension.event; +import org.slf4j.LoggerFactory; + import java.util.List; import java.util.ServiceLoader; public abstract class EventHandler { + private static final EventHandler DEFAULT = new EventHandler() { + @Override + public List snapshotEvents() { + return List.of(); + } + + @Override + public void handle(TrackEvent te) { + LoggerFactory.getLogger(te.getCategory()).info(te.getMessage()); + } + + @Override + public void handle(ErrorEvent ee) { + LoggerFactory.getLogger(EventHandler.class).error(ee.getDescription(), ee.getThrowable()); + } + }; + private static EventHandler INSTANCE; private static void init() { if (INSTANCE == null) { - INSTANCE = ServiceLoader.load(EventHandler.class).findFirst().orElseThrow(); + INSTANCE = ServiceLoader.load(EventHandler.class).findFirst().orElse(DEFAULT); } } diff --git a/extension/src/main/java/module-info.java b/extension/src/main/java/module-info.java index b8eaec320..60ec87930 100644 --- a/extension/src/main/java/module-info.java +++ b/extension/src/main/java/module-info.java @@ -14,8 +14,11 @@ module io.xpipe.extension { requires io.xpipe.fxcomps; requires org.apache.commons.collections4; requires static lombok; - requires com.dlsc.preferencesfx; - requires com.dlsc.formsfx; + requires static com.dlsc.preferencesfx; + requires static com.dlsc.formsfx; + requires static org.slf4j; + requires static com.google.gson; + requires static org.controlsfx.controls; requires java.desktop; requires org.fxmisc.richtext; requires org.fxmisc.flowless;