Skip to content

Commit f7c3528

Browse files
committed
build: add natives meta package to simplify consuming the lib
1 parent a220b2a commit f7c3528

File tree

7 files changed

+94
-2
lines changed

7 files changed

+94
-2
lines changed

.github/workflows/build.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ jobs:
2929
tests: false
3030
java-version: 17
3131
platform: ${{ github.job }}
32+
linux-arm64:
33+
runs-on: ubuntu-22.04
34+
steps:
35+
- uses: silenium-dev/actions/jni-natives/ubuntu@main
36+
with:
37+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
38+
snapshot-repo-url: "https://reposilite.silenium.dev/snapshots"
39+
release-repo-url: "https://reposilite.silenium.dev/releases"
40+
repo-username: ${{ secrets.REPOSILITE_USERNAME }}
41+
repo-password: ${{ secrets.REPOSILITE_PASSWORD }}
42+
tests: false
43+
java-version: 17
44+
platform: ${{ github.job }}
3245
windows-x86_64:
3346
runs-on: windows-latest
3447
steps:
@@ -42,8 +55,22 @@ jobs:
4255
tests: false
4356
java-version: 17
4457
platform: ${{ github.job }}
58+
windows-arm64:
59+
runs-on: windows-latest
60+
steps:
61+
- uses: silenium-dev/actions/jni-natives/windows@main
62+
with:
63+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
64+
snapshot-repo-url: "https://reposilite.silenium.dev/snapshots"
65+
release-repo-url: "https://reposilite.silenium.dev/releases"
66+
repo-username: ${{ secrets.REPOSILITE_USERNAME }}
67+
repo-password: ${{ secrets.REPOSILITE_PASSWORD }}
68+
tests: false
69+
java-version: 17
70+
platform: ${{ github.job }}
4571
kotlin:
4672
runs-on: ubuntu-22.04
73+
needs: [ linux-x86_64, linux-arm64, windows-x86_64, windows-arm64 ]
4774
steps:
4875
- uses: silenium-dev/actions/kotlin@main
4976
with:

buildSrc/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
`kotlin-dsl`
3+
`java-gradle-plugin`
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
maven("https://reposilite.silenium.dev/releases") {
9+
name = "silenium-releases"
10+
}
11+
}
12+
13+
dependencies {
14+
api(libs.jni.utils)
15+
}

buildSrc/settings.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dev.silenium.libs.jni.Platform
2+
import org.gradle.api.Project
3+
4+
fun Project.nativeArtifactId(platform: Platform): String {
5+
return "${rootProject.name}-natives-${platform.full}"
6+
}
7+
8+
val Project.allNativesArtifactId get() = rootProject.name + "-natives-all"

native-all/build.gradle.kts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import dev.silenium.libs.jni.Platform
2+
import dev.silenium.libs.jni.Platform.Arch
3+
import dev.silenium.libs.jni.Platform.OS
4+
5+
plugins {
6+
`java-library`
7+
}
8+
9+
val supportedPlatforms = listOf(
10+
Platform(OS.LINUX, Arch.X86_64),
11+
Platform(OS.LINUX, Arch.ARM64),
12+
Platform(OS.WINDOWS, Arch.X86_64),
13+
Platform(OS.WINDOWS, Arch.ARM64),
14+
)
15+
val libName = rootProject.name
16+
17+
dependencies {
18+
supportedPlatforms.forEach { platform ->
19+
api("${project.group}:${nativeArtifactId(platform)}:${project.version}")
20+
}
21+
}
22+
23+
publishing {
24+
publications {
25+
create<MavenPublication>("nativesAll") {
26+
artifactId = allNativesArtifactId
27+
}
28+
}
29+
}

native/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ publishing {
9393
if (deployNative) {
9494
create<MavenPublication>("natives${platform.capitalized}") {
9595
artifact(jar)
96-
artifactId = "$libName-natives-$platform"
96+
artifactId = nativeArtifactId(platform)
9797
}
9898
}
9999
}

settings.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ plugins {
1313
rootProject.name = "compose-gl"
1414

1515
val deployNative = if (extra.has("deploy.native")) {
16-
extra.get("deploy.native")?.toString()?.toBoolean() ?: true
16+
extra.get("deploy.native").toString().toBoolean()
1717
} else true
18+
val deployKotlin = if (extra.has("deploy.native")) {
19+
extra.get("deploy.kotlin").toString().toBoolean()
20+
} else false
1821
if (deployNative) {
1922
include(":native")
2023
}
24+
if (deployKotlin) {
25+
include(":native-all")
26+
}

0 commit comments

Comments
 (0)