Implement library build

This commit is contained in:
Christopher Schnick 2022-01-02 00:51:06 +01:00
parent d63882c5ff
commit 08bd127695
11 changed files with 162 additions and 11 deletions

View file

@ -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"
}

View file

@ -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<String,String> 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) {

View file

@ -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;
}

View file

@ -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<String> determineDefaultName() {
return Optional.of(FilenameUtils.getBaseName(file.toString()));
return Optional.of(file.getFileName().toString());
}
@Override

View file

@ -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;
}

2
deps

@ -1 +1 @@
Subproject commit e7f63e92d05537cee82e320a2017ddc26b9e3d3e
Subproject commit 49a1ad06bc6872f72c1d20ea864d24f3df59b7c5

View file

@ -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

60
library/build.gradle Normal file
View file

@ -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")
}
}
}
}

18
library/module-info.java Normal file
View file

@ -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;
}

50
library/publish.gradle Normal file
View file

@ -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
}

View file

@ -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")