Skip to content

Commit fceece0

Browse files
committed
add xtralink module
1 parent dff2d55 commit fceece0

15 files changed

Lines changed: 934 additions & 0 deletions

File tree

.github/workflows/snapshot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- if: ${{ matrix.os.platform != 'linux-amd64' }}
3939
name: java
4040
run: |
41+
./gradlew --no-parallel --no-configuration-cache :xtraplatform-xtralink:buildXtralinkJava -Pbranch=${{ github.ref_name }} -PdeployUser=${{ secrets.deploy_user }} -PdeployPassword=${{ secrets.deploy_password }}
4142
./gradlew --no-parallel --no-configuration-cache publish -Pbranch=${{ github.ref_name }} -PdeployUser=${{ secrets.deploy_user }} -PdeployPassword=${{ secrets.deploy_password }}
4243
4344
- if: ${{ matrix.os.platform == 'linux-amd64' }}
@@ -55,4 +56,5 @@ jobs:
5556
dnf install -y java-25-openjdk-devel g++ cmake
5657
pwd
5758
ls -l
59+
./gradlew --no-parallel --no-configuration-cache :xtraplatform-xtralink:buildXtralinkJava -Pbranch=${{ github.ref_name }} -PdeployUser=${{ secrets.deploy_user }} -PdeployPassword=${{ secrets.deploy_password }}
5860
./gradlew --no-parallel --no-configuration-cache publish -Pbranch=${{ github.ref_name }} -PdeployUser=${{ secrets.deploy_user }} -PdeployPassword=${{ secrets.deploy_password }}

settings.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ xtraplatform {
3838
}
3939

4040
rootProject.name = 'xtraplatform-native'
41+
42+
dependencyResolutionManagement {
43+
repositories {
44+
flatDir {
45+
dirs 'xtraplatform-xtralink/build/xtralink/ffi/java/build/libs/'
46+
}
47+
}
48+
}

xtraplatform-xtralink/build.gradle

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
plugins {
2+
id "de.undercouch.download" version "4.1.2"
3+
}
4+
5+
maturity = 'MATURE'
6+
maintenance = 'FULL'
7+
description = 'xtralink integration, jobs and store.'
8+
//docIgnore = true
9+
10+
ext {
11+
xtralinkVersion = '0.9.3'
12+
buildVersion = '0'
13+
xtralinkBuildDir = new File(buildDir, 'xtralink')
14+
xtralinkLibDir = new File(xtralinkBuildDir, 'dist')
15+
xtralinkLibName = project.osdetector.os == 'osx' ? 'libxtralink.dylib' : 'libxtralink.so'
16+
generatedResourcesDir = new File(buildDir, 'generated/src/main/resources/')
17+
embeddedLibDir = new File(generatedResourcesDir, "xtralink-${xtralinkVersion}-${buildVersion}/lib")
18+
}
19+
20+
dependencies {
21+
provided project(':xtraplatform-nativ-loader')
22+
23+
embedded name: "xtralink-${xtralinkVersion}"
24+
}
25+
26+
project.sourceSets.main.output.dir(generatedResourcesDir)
27+
28+
def downloadXtralink = tasks.register('downloadXtralink', Download, {
29+
src "https://github.com/ldproxy/xtralink/archive/refs/tags/v${xtralinkVersion}.tar.gz"
30+
dest new File(new File(System.getProperty("java.io.tmpdir")), "xtralink-${xtralinkVersion}.tar.gz")
31+
overwrite false
32+
})
33+
34+
def getXtralink = tasks.register('getXtralink', Copy, {
35+
dependsOn downloadXtralink
36+
from(tarTree(downloadXtralink.get().dest)) {
37+
eachFile { fcd ->
38+
fcd.relativePath = new RelativePath(true, fcd.relativePath.segments.drop(1))
39+
}
40+
includeEmptyDirs = false
41+
}
42+
//from(new File(projectDir, '../../../ws-xtrahub/xtralink'))
43+
//exclude 'data/**'
44+
45+
into xtralinkBuildDir
46+
def copyDetails = []
47+
eachFile { copyDetails << it }
48+
doLast {
49+
copyDetails.each { FileCopyDetails details ->
50+
def target = new File(destinationDir, details.path)
51+
if(target.exists()) { target.setLastModified(details.lastModified) }
52+
}
53+
}
54+
})
55+
56+
tasks.register('buildXtralink', Exec, {
57+
dependsOn(tasks.getXtralink)
58+
inputs.dir xtralinkBuildDir
59+
workingDir new File(xtralinkBuildDir, 'ffi/clib/main')
60+
commandLine 'make', 'shared', 'OUT=../../../dist/'
61+
})
62+
63+
def buildXtralinkJava= tasks.register('buildXtralinkJava', Exec, {
64+
dependsOn(tasks.getXtralink)
65+
inputs.dir xtralinkBuildDir
66+
workingDir new File(xtralinkBuildDir, 'ffi/java')
67+
commandLine './gradlew', 'build'
68+
})
69+
70+
def copyXtralinkLib = tasks.register('copyXtralinkLib', Copy, {
71+
dependsOn tasks.buildXtralink
72+
from(xtralinkLibDir) {
73+
include xtralinkLibName
74+
}
75+
into embeddedLibDir
76+
})
77+
78+
tasks.named('jar') {
79+
dependsOn copyXtralinkLib
80+
}
81+
tasks.named('cyclonedxDirectBom') {
82+
dependsOn buildXtralinkJava
83+
}
84+
tasks.withType(Pmd).configureEach {
85+
dependsOn copyXtralinkLib
86+
}
87+
88+
project.subprojects { Project subproject ->
89+
if (subproject.name.endsWith("-tpl")) {
90+
subproject.afterEvaluate {
91+
subproject.tasks.named("compileJava") {
92+
dependsOn buildXtralinkJava
93+
}
94+
subproject.tasks.named("cyclonedxDirectBom") {
95+
dependsOn buildXtralinkJava
96+
}
97+
subproject.tasks.named("javadocJar") {
98+
dependsOn buildXtralinkJava
99+
}
100+
subproject.tasks.named("sourcesJar") {
101+
dependsOn buildXtralinkJava
102+
}
103+
}
104+
}
105+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import type { Config } from "genffi";
2+
3+
export default {
4+
outDir: "./src/main",
5+
verbose: true,
6+
7+
//schema: { label: "Example JSON Schema" },
8+
9+
java: {
10+
pkg: "de.ii.xtraplatform.xtralink.domain.jobs",
11+
api: {
12+
pkg: "de.ii.xtraplatform.xtralink.app.jobs",
13+
},
14+
},
15+
16+
go: {
17+
path: "go",
18+
//pkgPrefix: "xtralink",
19+
module: "github.com/xtraplatform-native/xtralink",
20+
mod: {},
21+
api: {},
22+
cgo: {
23+
init: true,
24+
},
25+
impl: {},
26+
model: {},
27+
},
28+
} satisfies Config;
29+
30+
export namespace GenModel {
31+
export namespace Enums {
32+
export enum Status {
33+
ACCEPTED = "ACCEPTED",
34+
RUNNING = "RUNNING",
35+
SUCCESSFUL = "SUCCESSFUL",
36+
FAILED = "FAILED",
37+
DISMISSED = "DISMISSED",
38+
}
39+
}
40+
41+
export namespace Config {
42+
export type Job = {
43+
id: string;
44+
kind: string;
45+
createdAt: number;
46+
startedAt: number;
47+
updatedAt: number;
48+
finishedAt: number;
49+
status: Enums.Status;
50+
progress: number;
51+
errors: string[];
52+
};
53+
export type JobResult = {
54+
message: string;
55+
status: Enums.Status;
56+
errors: string[];
57+
};
58+
}
59+
}
60+
61+
export namespace GenApi {
62+
63+
export type int = number & { readonly __int: unique symbol };
64+
65+
/**
66+
* @listener
67+
*/
68+
export interface JobListener {
69+
onProgress: (job: GenModel.Config.Job) => void;
70+
}
71+
72+
/**
73+
* @listener
74+
*/
75+
export interface JobProcessor {
76+
/**
77+
* @throws
78+
*/
79+
process: (job: GenModel.Config.Job) => GenModel.Config.JobResult;
80+
}
81+
82+
/**
83+
* The one globally reachable object. `InitLibrary()` creates it by calling
84+
* `clib.NewInit()`, which you have to write by hand — it is the single obligation
85+
* genffi places on the implementation side.
86+
* @singleton
87+
*/
88+
export interface JobQueue {
89+
create: (jobType: string) => GenModel.Config.Job;
90+
91+
/**
92+
* The same thing through a `@scoped` listener, whose Java overload takes the interface
93+
* itself and manages the registration around the call. A single-method listener, so the
94+
* call site can be a lambda — which is the whole point of the tag and the one thing a
95+
* compile cannot prove is *usable*.
96+
* @scoped
97+
*/
98+
push: (
99+
cfg: GenModel.Config.Job,
100+
onProgress: JobListener,
101+
) => Promise<GenModel.Config.Job>;
102+
103+
get: (id: string) => GenModel.Config.Job;
104+
}
105+
106+
/**
107+
* The one globally reachable object. `InitLibrary()` creates it by calling
108+
* `clib.NewInit()`, which you have to write by hand — it is the single obligation
109+
* genffi places on the implementation side.
110+
* @singleton
111+
*/
112+
export interface JobProcessors {
113+
register: (jobType: string, processor: JobProcessor) => boolean;
114+
}
115+
}

xtraplatform-xtralink/package-lock.json

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xtraplatform-xtralink/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"type": "module",
3+
"private": true,
4+
"scripts": {
5+
"genffi": "genffi"
6+
},
7+
"devDependencies": {
8+
"genffi": "file:../../genffi"
9+
}
10+
}

0 commit comments

Comments
 (0)