From 965dfe04e8c5eff84c499fe3c15984cc5a41c9a3 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 7 Mar 2024 22:26:23 +0000 Subject: [PATCH] Remove api module --- api/LICENSE.md | 7 - api/README.md | 20 --- api/build.gradle | 38 ----- api/publish.gradle | 40 ----- .../main/java/io/xpipe/api/DataStores.java | 23 --- .../api/connector/XPipeApiConnection.java | 150 ------------------ .../io/xpipe/api/util/TypeDescriptor.java | 12 -- api/src/main/java/module-info.java | 8 - .../test/java/io/xpipe/api/test/ApiTest.java | 19 --- .../java/io/xpipe/api/test/StartupTest.java | 14 -- api/src/test/java/module-info.java | 9 -- .../resources/io/xpipe/api/test/username.csv | 6 - build.gradle | 1 - settings.gradle | 1 - 14 files changed, 348 deletions(-) delete mode 100644 api/LICENSE.md delete mode 100644 api/README.md delete mode 100644 api/build.gradle delete mode 100644 api/publish.gradle delete mode 100644 api/src/main/java/io/xpipe/api/DataStores.java delete mode 100644 api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java delete mode 100644 api/src/main/java/io/xpipe/api/util/TypeDescriptor.java delete mode 100644 api/src/main/java/module-info.java delete mode 100644 api/src/test/java/io/xpipe/api/test/ApiTest.java delete mode 100644 api/src/test/java/io/xpipe/api/test/StartupTest.java delete mode 100644 api/src/test/java/module-info.java delete mode 100644 api/src/test/resources/io/xpipe/api/test/username.csv diff --git a/api/LICENSE.md b/api/LICENSE.md deleted file mode 100644 index 4fe3f425..00000000 --- a/api/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2022 Christopher Schnick - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/api/README.md b/api/README.md deleted file mode 100644 index 62ecdec8..00000000 --- a/api/README.md +++ /dev/null @@ -1,20 +0,0 @@ -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.xpipe/xpipe-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.xpipe/xpipe-api) -[![javadoc](https://javadoc.io/badge2/io.xpipe/xpipe-api/javadoc.svg)](https://javadoc.io/doc/io.xpipe/xpipe-api) - -## XPipe Java API - -The XPipe API for Java allows you to use most of the XPipe functionality from Java applications: - -- Create data stores and data sources -- Query and work with the contents of data sources -- Write data to data sources - -## Setup - -Either install the [maven dependency](https://maven-badges.herokuapp.com/maven-central/io.xpipe/xpipe-api) from Maven Central -using your favourite build tool or alternatively download the `xpipe-api.jar`, `xpipe-core.jar`, and `xpipe-beacon.jar` -from the [releases page](https://github.com/xpipe-io/xpipe/releases/latest) and add them to the classpath. - -## Usage - -See [the API documentation](https://xpipe-io.readthedocs.io/en/latest/dev/api/java/index.html). \ No newline at end of file diff --git a/api/build.gradle b/api/build.gradle deleted file mode 100644 index 3dc3ea3d..00000000 --- a/api/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -plugins { - id 'java-library' - id 'maven-publish' - id 'signing' -} - -apply from: "$rootDir/gradle/gradle_scripts/java.gradle" -apply from: "$rootDir/gradle/gradle_scripts/junit.gradle" - -version = rootProject.versionString -group = 'io.xpipe' -archivesBaseName = 'xpipe-api' - -repositories { - mavenCentral() -} - -dependencies { - testImplementation project(':api') -} - -dependencies { - api project(':core') - implementation project(':beacon') - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.16.1" -} - -configurations { - testImplementation.extendsFrom(dep) -} - -task dist(type: Copy) { - from jar.archiveFile - into "${project(':dist').buildDir}/dist/libraries" -} - -apply from: 'publish.gradle' -apply from: "$rootDir/gradle/gradle_scripts/publish-base.gradle" \ No newline at end of file diff --git a/api/publish.gradle b/api/publish.gradle deleted file mode 100644 index bcea7f77..00000000 --- a/api/publish.gradle +++ /dev/null @@ -1,40 +0,0 @@ -publishing { - publications { - mavenJava(MavenPublication) { - artifactId = project.archivesBaseName - - from components.java - - pom.withXml { - def pomNode = asNode() - pomNode.dependencies.'*'.findAll().each() { - it.scope*.value = 'compile' - } - } - - pom { - name = 'XPipe Java API' - description = 'Contains everything necessary to interact with XPipe from Java applications.' - url = 'https://github.com/xpipe-io/xpipe/api' - licenses { - license { - name = 'The MIT License (MIT)' - url = 'https://github.com/xpipe-io/xpipe/LICENSE.md' - } - } - developers { - developer { - id = 'crschnick' - name = 'Christopher Schnick' - email = 'crschnick@xpipe.io' - } - } - scm { - connection = 'scm:git:git://github.com/xpipe-io/xpipe.git' - developerConnection = 'scm:git:ssh://github.com/xpipe-io/xpipe.git' - url = 'https://github.com/xpipe-io/xpipe' - } - } - } - } -} \ No newline at end of file diff --git a/api/src/main/java/io/xpipe/api/DataStores.java b/api/src/main/java/io/xpipe/api/DataStores.java deleted file mode 100644 index 17564584..00000000 --- a/api/src/main/java/io/xpipe/api/DataStores.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.xpipe.api; - -import io.xpipe.api.connector.XPipeApiConnection; -import io.xpipe.beacon.exchange.cli.StoreAddExchange; -import io.xpipe.beacon.util.QuietDialogHandler; -import io.xpipe.core.store.DataStore; - -import java.util.Map; - -public class DataStores { - - public static void addNamedStore(DataStore store, String name) { - XPipeApiConnection.execute(con -> { - var req = StoreAddExchange.Request.builder() - .storeInput(store) - .name(name) - .build(); - StoreAddExchange.Response res = con.performSimpleExchange(req); - - new QuietDialogHandler(res.getConfig(), con, Map.of()).handle(); - }); - } -} diff --git a/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java b/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java deleted file mode 100644 index 6e11cfd1..00000000 --- a/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java +++ /dev/null @@ -1,150 +0,0 @@ -package io.xpipe.api.connector; - -import io.xpipe.beacon.BeaconClient; -import io.xpipe.beacon.BeaconConnection; -import io.xpipe.beacon.BeaconException; -import io.xpipe.beacon.BeaconServer; -import io.xpipe.beacon.exchange.cli.DialogExchange; -import io.xpipe.core.dialog.DialogReference; -import io.xpipe.core.util.XPipeDaemonMode; -import io.xpipe.core.util.XPipeInstallation; - -import java.util.Optional; - -public final class XPipeApiConnection extends BeaconConnection { - - private XPipeApiConnection() {} - - public static XPipeApiConnection open() { - var con = new XPipeApiConnection(); - con.constructSocket(); - return con; - } - - public static void finishDialog(DialogReference reference) { - try (var con = new XPipeApiConnection()) { - con.constructSocket(); - var element = reference.getStart(); - while (true) { - if (element != null && element.requiresExplicitUserInput()) { - throw new IllegalStateException(); - } - - DialogExchange.Response response = con.performSimpleExchange(DialogExchange.Request.builder() - .dialogKey(reference.getDialogId()) - .build()); - element = response.getElement(); - if (response.getElement() == null) { - break; - } - } - } catch (BeaconException e) { - throw e; - } catch (Exception e) { - throw new BeaconException(e); - } - } - - public static void execute(Handler handler) { - try (var con = new XPipeApiConnection()) { - con.constructSocket(); - handler.handle(con); - } catch (BeaconException e) { - throw e; - } catch (Exception e) { - throw new BeaconException(e); - } - } - - public static T execute(Mapper mapper) { - try (var con = new XPipeApiConnection()) { - con.constructSocket(); - return mapper.handle(con); - } catch (BeaconException e) { - throw e; - } catch (Exception e) { - throw new BeaconException(e); - } - } - - public static Optional waitForStartup(Process process) { - for (int i = 0; i < 160; i++) { - if (process != null && !process.isAlive() && process.exitValue() != 0) { - return Optional.empty(); - } - - try { - Thread.sleep(500); - } catch (InterruptedException ignored) { - } - - var s = BeaconClient.tryEstablishConnection(BeaconClient.ApiClientInformation.builder() - .version("?") - .language("Java") - .build()); - if (s.isPresent()) { - return s; - } - } - return Optional.empty(); - } - - public static void waitForShutdown() { - for (int i = 0; i < 40; i++) { - try { - Thread.sleep(500); - } catch (InterruptedException ignored) { - } - - var r = BeaconServer.isReachable(); - if (!r) { - return; - } - } - } - - @Override - protected void constructSocket() { - if (!BeaconServer.isReachable()) { - try { - start(); - } catch (Exception ex) { - throw new BeaconException("Unable to start xpipe daemon", ex); - } - - var r = waitForStartup(null); - if (r.isEmpty()) { - throw new BeaconException("Wait for xpipe daemon timed out"); - } else { - beaconClient = r.get(); - return; - } - } - - try { - beaconClient = BeaconClient.establishConnection(BeaconClient.ApiClientInformation.builder() - .version("?") - .language("Java") - .build()); - } catch (Exception ex) { - throw new BeaconException("Unable to connect to running xpipe daemon", ex); - } - } - - private void start() throws Exception { - var installation = XPipeInstallation.getLocalDefaultInstallationBasePath(); - BeaconServer.start(installation, XPipeDaemonMode.TRAY); - } - - @FunctionalInterface - public interface Handler { - - void handle(BeaconConnection con); - } - - @FunctionalInterface - public interface Mapper { - - T handle(BeaconConnection con); - } -} diff --git a/api/src/main/java/io/xpipe/api/util/TypeDescriptor.java b/api/src/main/java/io/xpipe/api/util/TypeDescriptor.java deleted file mode 100644 index 2434da38..00000000 --- a/api/src/main/java/io/xpipe/api/util/TypeDescriptor.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.xpipe.api.util; - -import java.util.List; -import java.util.stream.Collectors; - -public class TypeDescriptor { - - public static String create(List names) { - return "[" + names.stream().map(n -> n != null ? "\"" + n + "\"" : null).collect(Collectors.joining(",")) - + "]\n"; - } -} diff --git a/api/src/main/java/module-info.java b/api/src/main/java/module-info.java deleted file mode 100644 index cd277a4b..00000000 --- a/api/src/main/java/module-info.java +++ /dev/null @@ -1,8 +0,0 @@ -module io.xpipe.api { - exports io.xpipe.api; - exports io.xpipe.api.connector; - exports io.xpipe.api.util; - - requires transitive io.xpipe.core; - requires io.xpipe.beacon; -} diff --git a/api/src/test/java/io/xpipe/api/test/ApiTest.java b/api/src/test/java/io/xpipe/api/test/ApiTest.java deleted file mode 100644 index b0899607..00000000 --- a/api/src/test/java/io/xpipe/api/test/ApiTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.xpipe.api.test; - -import io.xpipe.beacon.test.BeaconDaemonController; -import io.xpipe.core.util.XPipeDaemonMode; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; - -public class ApiTest { - - @BeforeAll - public static void setup() throws Exception { - BeaconDaemonController.start(XPipeDaemonMode.TRAY); - } - - @AfterAll - public static void teardown() throws Exception { - BeaconDaemonController.stop(); - } -} diff --git a/api/src/test/java/io/xpipe/api/test/StartupTest.java b/api/src/test/java/io/xpipe/api/test/StartupTest.java deleted file mode 100644 index 7c185dd2..00000000 --- a/api/src/test/java/io/xpipe/api/test/StartupTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.xpipe.api.test; - -import io.xpipe.beacon.test.BeaconDaemonController; -import io.xpipe.core.util.XPipeDaemonMode; -import org.junit.jupiter.api.Test; - -public class StartupTest { - - @Test - public void test() throws Exception { - BeaconDaemonController.start(XPipeDaemonMode.TRAY); - BeaconDaemonController.stop(); - } -} diff --git a/api/src/test/java/module-info.java b/api/src/test/java/module-info.java deleted file mode 100644 index f51c38c5..00000000 --- a/api/src/test/java/module-info.java +++ /dev/null @@ -1,9 +0,0 @@ -module io.xpipe.api.test { - requires io.xpipe.api; - requires io.xpipe.beacon; - requires org.junit.jupiter.api; - - opens io.xpipe.api.test; - - exports io.xpipe.api.test; -} diff --git a/api/src/test/resources/io/xpipe/api/test/username.csv b/api/src/test/resources/io/xpipe/api/test/username.csv deleted file mode 100644 index 87c0f122..00000000 --- a/api/src/test/resources/io/xpipe/api/test/username.csv +++ /dev/null @@ -1,6 +0,0 @@ -Username;Identifier ;First name;Last name -booker12;9012;Rachel;Booker -grey07;2070;Laura;Grey -johnson81;4081;Craig;Johnson -jenkins46;9346;Mary;Jenkins -smith79;5079;Jamie;Smith diff --git a/build.gradle b/build.gradle index 1105d7e1..40e9da84 100644 --- a/build.gradle +++ b/build.gradle @@ -130,7 +130,6 @@ def replaceVariablesInFile(String f, Map replacements) { def testTasks = [ project(':core').getTasksByName('test', true), - project(':api').getTasksByName('test', true), project(':app').getTasksByName('test', true), project(':base').getTasksByName('localTest', true), project(':jdbc').getTasksByName('localTest', true), diff --git a/settings.gradle b/settings.gradle index e583c472..ec9dd5ef 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,5 @@ rootProject.name = 'xpipe' -include 'api' include 'core' include 'beacon'