diff --git a/api/build.gradle b/api/build.gradle index a347c1dbe..bfbc12b99 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -27,7 +27,7 @@ dependencies { implementation project(':beacon') testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' - testRuntimeOnly project(':app') + //testRuntimeOnly project(':app') testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' testRuntimeOnly "org.junit.platform:junit-platform-launcher" } diff --git a/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java b/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java index 942e2b300..b796a0b0c 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java @@ -10,6 +10,9 @@ import io.xpipe.beacon.ServerException; import io.xpipe.beacon.exchange.ReadInfoExchange; import io.xpipe.core.source.DataSourceId; +import java.net.URL; +import java.util.Map; + public abstract class DataSourceImpl implements DataSource { public static DataSource get(DataSourceId ds) { @@ -34,6 +37,28 @@ public abstract class DataSourceImpl implements DataSource { return source[0]; } + public static DataSource wrap(URL url, String type, Map config) { + final DataSource[] source = new DataSource[1]; + new XPipeApiConnector() { + @Override + protected void handle(BeaconClient sc) throws ClientException, ServerException, ConnectorException { + var req = ReadInfoExchange.Request.builder().sourceId(ds).build(); + ReadInfoExchange.Response res = performSimpleExchange(sc, req); + switch (res.getType()) { + case TABLE -> { + var data = res.getTableData(); + source[0] = new DataTableImpl(res.getSourceId(), data.getRowCount(), data.getDataType()); + } + case STRUCTURE -> { + } + case RAW -> { + } + } + } + }.execute(); + return source[0]; + } + private final DataSourceId sourceId; public DataSourceImpl(DataSourceId sourceId) { diff --git a/api/src/test/java/io/xpipe/api/test/DataTableTest.java b/api/src/test/java/io/xpipe/api/test/DataTableTest.java index 6f362d2c9..f1cb2d77f 100644 --- a/api/src/test/java/io/xpipe/api/test/DataTableTest.java +++ b/api/src/test/java/io/xpipe/api/test/DataTableTest.java @@ -1,5 +1,6 @@ package io.xpipe.api.test; +import io.xpipe.api.DataSource; import io.xpipe.api.DataTable; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -9,7 +10,7 @@ public class DataTableTest { @Test public void testGet() { - var table = DataTable.get("new folder:username"); + var table = DataSource.get("new folder:username").asTable(); var r = table.read(2); var a = 0; } diff --git a/core/src/main/java/io/xpipe/core/store/LocalFileDataStore.java b/core/src/main/java/io/xpipe/core/store/LocalFileDataStore.java index 9e904c613..4e1b2434a 100644 --- a/core/src/main/java/io/xpipe/core/store/LocalFileDataStore.java +++ b/core/src/main/java/io/xpipe/core/store/LocalFileDataStore.java @@ -3,7 +3,6 @@ package io.xpipe.core.store; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.apache.commons.io.FilenameUtils; import java.io.BufferedInputStream; import java.io.IOException; @@ -26,7 +25,7 @@ public class LocalFileDataStore extends FileDataStore { @Override public Optional determineDefaultName() { - return Optional.of(FilenameUtils.getBaseName(file.toString())); + return Optional.of(file.getFileName().toString()); } @Override diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index cb4e84c77..07e8485c1 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -24,7 +24,4 @@ module io.xpipe.core { uses com.fasterxml.jackson.databind.Module; provides com.fasterxml.jackson.databind.Module with CoreJacksonModule; - - requires org.apache.commons.lang; - requires org.apache.commons.io; } \ No newline at end of file diff --git a/deps b/deps index e7f63e92d..49a1ad06b 160000 --- a/deps +++ b/deps @@ -1 +1 @@ -Subproject commit e7f63e92d05537cee82e320a2017ddc26b9e3d3e +Subproject commit 49a1ad06bc6872f72c1d20ea864d24f3df59b7c5 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e0..fbce071a3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/library/build.gradle b/library/build.gradle new file mode 100644 index 000000000..6a75e733a --- /dev/null +++ b/library/build.gradle @@ -0,0 +1,60 @@ +plugins { + id 'java-library' + id 'maven-publish' + id 'signing' +} + +apply from: 'publish.gradle' +apply from: "$rootDir/deps/jackson.gradle" +apply from: "$rootDir/deps/lombok.gradle" +apply from: "$rootDir/deps/javafx-static.gradle" + +version '0.1' +group 'io.xpipe' +jar.archiveBaseName = 'xpipe' + +java { + modularity.inferModulePath = true + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +repositories { + mavenCentral() +} + +javadoc{ + source = sourceSets.main.allJava + options { + addStringOption('-release', '17') + addStringOption('link', 'https://docs.oracle.com/en/java/javase/17/docs/api/') + } +} + +sourceSets { + main { + java { + srcDir(projectDir) + + srcDir("$rootDir/api/src/main/java") + exclude { + return it.getFile() == file("$rootDir/api/src/main/java/module-info.java") + } + + srcDir("$rootDir/core/src/main/java") + exclude { + return it.getFile() == file("$rootDir/core/src/main/java/module-info.java") + } + + srcDir("$rootDir/beacon/src/main/java") + exclude { + return it.getFile() == file("$rootDir/beacon/src/main/java/module-info.java") + } + + srcDir("$rootDir/extension/src/main/java") + exclude { + return it.getFile() == file("$rootDir/extension/src/main/java/module-info.java") + } + } + } +} diff --git a/library/module-info.java b/library/module-info.java new file mode 100644 index 000000000..d92f44954 --- /dev/null +++ b/library/module-info.java @@ -0,0 +1,18 @@ +module io.xpipe { + exports io.xpipe.api; + + exports io.xpipe.beacon; + exports io.xpipe.beacon.exchange; + exports io.xpipe.beacon.message; + + requires com.fasterxml.jackson.core; + requires com.fasterxml.jackson.databind; + requires com.fasterxml.jackson.module.paramnames; + requires static lombok; + requires static javafx.base; + requires static javafx.graphics; + + opens io.xpipe.beacon; + opens io.xpipe.beacon.exchange; + opens io.xpipe.beacon.message; +} \ No newline at end of file diff --git a/library/publish.gradle b/library/publish.gradle new file mode 100644 index 000000000..ae3f0eb1c --- /dev/null +++ b/library/publish.gradle @@ -0,0 +1,50 @@ +java { + withJavadocJar() + withSourcesJar() +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + pom { + name = 'XPipe' + description = 'XPipe library.' + url = 'https://github.com/xpipe-io/xpipe_java' + licenses { + license { + name = 'The MIT License (MIT)' + url = 'https://github.com/xpipe-io/xpipe_java/LICENSE' + } + } + developers { + developer { + id = 'crschnick' + name = 'Christopher Schnick' + email = 'crschnick@xpipe.io' + } + } + scm { + connection = 'scm:git:git://github.com/xpipe-io/xpipe_java.git' + developerConnection = 'scm:git:ssh://github.com/xpipe-io/xpipe_java.git' + url = 'https://github.com/xpipe-io/xpipe_java' + } + } + } + } + + repositories { + maven { + url "https://oss.sonatype.org/service/local/staging/deploy/maven2" + credentials { + setUsername "${project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : ''}" + setPassword "${project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : ''}" + } + } + } +} + +signing { + sign publishing.publications.mavenJava +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 9828e4e96..f309654c6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,11 +4,12 @@ include 'core' include 'beacon' include 'api' include 'extension' +include 'library' include 'sample_extension' -project(":sample_extension").projectDir = file("$projectDir/samples/sample_extension") +project(":sample_extension").projectDir = file("samples/sample_extension") include 'sample_program' -project(":sample_program").projectDir = file("$projectDir/samples/sample_program") +project(":sample_program").projectDir = file("samples/sample_program")