Skip to content

Commit 08766a7

Browse files
authored
Merge pull request #27 from Azim/dectalk-develop
Build java wrapper
2 parents c0521bb + 7b29774 commit 08766a7

29 files changed

Lines changed: 1181 additions & 1 deletion

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: "Build"
22

33
on:
44
workflow_dispatch:
5-
push:
65

76
concurrency:
87
group: "build"

.github/workflows/java.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: build Java wrapper
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- src/**
8+
- include/**
9+
- mman-win32/**
10+
- platforms/java/**
11+
- .github/workflows/java.yml
12+
13+
env:
14+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
15+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
- name: Set up Java 21
24+
uses: actions/setup-java@v5
25+
with:
26+
distribution: 'temurin'
27+
java-version: '21'
28+
server-id: hytalemodding.dev
29+
server-username: MAVEN_USERNAME
30+
server-password: MAVEN_PASSWORD
31+
- name: Setup zig
32+
uses: mlugg/setup-zig@v2
33+
with:
34+
version: 0.14.1
35+
- name: Build and publish
36+
run: |
37+
mkdir -p release
38+
cd platforms/java
39+
./gradlew publish --stacktrace
40+
cp $(find ./build/libs -maxdepth 1 -type f -name "*.jar") ../../release/
41+
- uses: actions/upload-artifact@v6
42+
with:
43+
name: java-test
44+
path: ./release/

platforms/java/.gitignore

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
target/
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
*.iml
10+
*.ipr
11+
*.iws
12+
13+
# IntelliJ
14+
out/
15+
# mpeltonen/sbt-idea plugin
16+
.idea_modules/
17+
18+
# JIRA plugin
19+
atlassian-ide-plugin.xml
20+
21+
# Compiled class file
22+
*.class
23+
24+
# Log file
25+
*.log
26+
27+
# BlueJ files
28+
*.ctxt
29+
30+
# Package Files #
31+
*.jar
32+
*.war
33+
*.nar
34+
*.ear
35+
*.zip
36+
*.tar.gz
37+
*.rar
38+
39+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
40+
hs_err_pid*
41+
42+
*~
43+
44+
# temporary files which can be created if a process still has a handle open of a deleted file
45+
.fuse_hidden*
46+
47+
# KDE directory preferences
48+
.directory
49+
50+
# Linux trash folder which might appear on any partition or disk
51+
.Trash-*
52+
53+
# .nfs files are created when an open file is removed but is still being accessed
54+
.nfs*
55+
56+
# General
57+
.DS_Store
58+
.AppleDouble
59+
.LSOverride
60+
61+
# Icon must end with two \r
62+
Icon
63+
64+
# Thumbnails
65+
._*
66+
67+
# Files that might appear in the root of a volume
68+
.DocumentRevisions-V100
69+
.fseventsd
70+
.Spotlight-V100
71+
.TemporaryItems
72+
.Trashes
73+
.VolumeIcon.icns
74+
.com.apple.timemachine.donotpresent
75+
76+
# Directories potentially created on remote AFP share
77+
.AppleDB
78+
.AppleDesktop
79+
Network Trash Folder
80+
Temporary Items
81+
.apdisk
82+
83+
# Windows thumbnail cache files
84+
Thumbs.db
85+
Thumbs.db:encryptable
86+
ehthumbs.db
87+
ehthumbs_vista.db
88+
89+
# Dump file
90+
*.stackdump
91+
92+
# Folder config file
93+
[Dd]esktop.ini
94+
95+
# Recycle Bin used on file shares
96+
$RECYCLE.BIN/
97+
98+
# Windows Installer files
99+
*.cab
100+
*.msi
101+
*.msix
102+
*.msm
103+
*.msp
104+
105+
# Windows shortcuts
106+
*.lnk
107+
108+
.gradle
109+
build/
110+
111+
# Ignore Gradle GUI config
112+
gradle-app.setting
113+
114+
# Cache of project
115+
.gradletasknamecache
116+
117+
**/build/
118+
119+
# Common working directory
120+
run/
121+
122+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
123+
!gradle-wrapper.jar

platforms/java/build.gradle

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'eclipse'
5+
id 'net.linguica.maven-settings' version '0.5'
6+
}
7+
8+
group = 'dev.bytesizedfox.dectalk'
9+
archivesBaseName = 'libdtc'
10+
version = '1.0.0'
11+
12+
java {
13+
sourceCompatibility = JavaVersion.VERSION_21
14+
targetCompatibility = JavaVersion.VERSION_21
15+
withSourcesJar()
16+
withJavadocJar()
17+
}
18+
19+
tasks.named('sourcesJar', Jar) {
20+
exclude 'natives/**'
21+
}
22+
23+
def generatedResourcesDir = layout.buildDirectory.dir("generated-resources")
24+
25+
sourceSets {
26+
main {
27+
resources {
28+
srcDir generatedResourcesDir
29+
}
30+
}
31+
}
32+
33+
publishing {
34+
publications {
35+
mavenJava(MavenPublication) {
36+
from components.java
37+
pom {
38+
name = 'libdtc'
39+
description = 'DECtalk Wrapper for Java'
40+
url = 'https://github.com/dectalk/DECtalkMini/tree/dectalk-develop/platforms/java'
41+
}
42+
}
43+
}
44+
repositories {
45+
maven {
46+
name = 'hytalemodding.dev'
47+
def releaseUrl = "https://maven.hytalemodding.dev/releases"
48+
def snapshotUrl = "https://maven.hytalemodding.dev/snapshots"
49+
50+
url = uri(version.toString().endsWith("SNAPSHOT") ? snapshotUrl : releaseUrl)
51+
}
52+
53+
}
54+
}
55+
56+
def platforms = [
57+
[
58+
name : 'windows-x64',
59+
file : 'zig-x86_64-windows-gnu.cmake',
60+
res : 'windows-x64',
61+
libExt: 'dll'
62+
],
63+
[
64+
name : 'windows-arm64',
65+
file : 'zig-aarch64-windows-gnu.cmake',
66+
res : 'windows-aarch64',
67+
libExt: 'dll'
68+
],
69+
[
70+
name : 'linux-x64',
71+
file : 'zig-x86_64-linux-gnu.cmake',
72+
res : 'linux-x64',
73+
libExt: 'so'
74+
],
75+
[
76+
name : 'linux-arm64',
77+
file : 'zig-aarch64-linux-gnu.cmake',
78+
res : 'linux-aarch64',
79+
libExt: 'so'
80+
],
81+
[
82+
name : 'macos-x64',
83+
file : 'zig-x86_64-macos.cmake',
84+
res : 'mac-x64',
85+
libExt: 'dylib'
86+
],
87+
[
88+
name : 'macos-arm64',
89+
file : 'zig-aarch64-macos.cmake',
90+
res : 'mac-aarch64',
91+
libExt: 'dylib'
92+
],
93+
]
94+
95+
platforms.each { target ->
96+
def safeName = target.name.capitalize().replace('-', '')
97+
def configureTask = "configureNatives${safeName}"
98+
def buildTask = "buildNatives${safeName}"
99+
def copyTask = "copyNatives${safeName}"
100+
101+
def buildDir = layout.projectDirectory.dir("native/build/${target.res}")
102+
103+
def cmakeListsPath = "../../CMakeLists.txt"
104+
def cmakePlatformPath = "../../cmake/${target.file}"
105+
def resourceDir = generatedResourcesDir.get().dir("natives/${target.res}")
106+
def cSourcesDir = layout.projectDirectory.dir('native/src')
107+
def outputName = "libdtc.${target.libExt}"
108+
109+
tasks.register(configureTask, Exec) {
110+
group = 'natives'
111+
description = "CMake configure for ${target.name}"
112+
workingDir = buildDir
113+
114+
inputs.file(buildDir.file(cmakeListsPath))
115+
inputs.file(buildDir.file(cmakePlatformPath))
116+
inputs.dir(cSourcesDir)
117+
outputs.dir(buildDir)
118+
119+
doFirst {
120+
def dir = buildDir.asFile
121+
if (dir.exists()) {
122+
logger.lifecycle("Cleaning ${dir}")
123+
project.delete(fileTree(dir: dir))
124+
}
125+
dir.mkdirs()
126+
}
127+
128+
commandLine 'cmake',
129+
"-DCMAKE_TOOLCHAIN_FILE=${cmakePlatformPath}",
130+
'-DCMAKE_BUILD_TYPE=Release',
131+
'-G', 'Ninja',
132+
'../..'
133+
}
134+
135+
tasks.register(buildTask, Exec) {
136+
group = 'natives'
137+
description = "Build natives for ${target.name}"
138+
workingDir = buildDir
139+
dependsOn configureTask
140+
141+
inputs.dir(buildDir)
142+
outputs.dir(buildDir)
143+
144+
commandLine 'cmake', '--build', '.', '--config', 'Release'
145+
}
146+
147+
tasks.register(copyTask, Copy) {
148+
group = 'natives'
149+
description = "Copy ${target.name} natives into resources"
150+
dependsOn buildTask
151+
152+
from buildDir.file(outputName)
153+
into resourceDir
154+
}
155+
}
156+
157+
tasks.register('buildAndCopyAllNatives') {
158+
group = 'natives'
159+
description = 'Build & copy all native libraries for every platform/arch'
160+
dependsOn platforms.collect { "copyNatives${it.name.capitalize().replace('-', '')}" }
161+
}
162+
163+
tasks.named('processResources') {
164+
dependsOn 'buildAndCopyAllNatives'
165+
}
166+
167+
tasks.named("clean", Delete).configure {
168+
delete("native/build")
169+
}

platforms/java/gradle.properties

Whitespace-only changes.
42.7 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)